@grfzhl/vue-hls-player 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/VideoPlayer/BasePlayer.vue +67 -64
- package/package.json +1 -1
|
@@ -153,69 +153,6 @@ const videoElement = defineModel()
|
|
|
153
153
|
|
|
154
154
|
onMounted(() => {
|
|
155
155
|
prepareVideoPlayer()
|
|
156
|
-
if (video.value) {
|
|
157
|
-
|
|
158
|
-
// pass video element as reference to model
|
|
159
|
-
if (!videoElement.value) {
|
|
160
|
-
videoElement.value = video.value;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
video.value.addEventListener('timeupdate', updateCurrentTime);
|
|
164
|
-
document.addEventListener('fullscreenchange', onFullscreenChange);
|
|
165
|
-
document.addEventListener('orientationchange', onOrientationChange);
|
|
166
|
-
window.screen.orientation.addEventListener("change", onOrientationChange);
|
|
167
|
-
|
|
168
|
-
if(video.value.paused || video.value.currentTime === 0) {
|
|
169
|
-
initialPlayButton.value = true
|
|
170
|
-
|
|
171
|
-
if(props.hideInitialPlayButton) {
|
|
172
|
-
setTimeout(() => {
|
|
173
|
-
hideInitialPlayButton.value = true
|
|
174
|
-
}, 1200)
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* detect initial display orientation
|
|
180
|
-
*/
|
|
181
|
-
if (typeof window.orientation === "undefined") {
|
|
182
|
-
orientation.value = window.screen.orientation.angle === 0 || window.screen.orientation.angle === 180
|
|
183
|
-
? "portrait"
|
|
184
|
-
: "landscape";
|
|
185
|
-
} else {
|
|
186
|
-
orientation.value = window.orientation === 0 || window.orientation === 180
|
|
187
|
-
? "portrait"
|
|
188
|
-
: "landscape"; // for safari
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* overwrite player.style video fullscreen button
|
|
193
|
-
* to inject own fullscreen logic
|
|
194
|
-
*/
|
|
195
|
-
const observer = new MutationObserver((mutationsList, observer) => {
|
|
196
|
-
const mediaTheme = document.querySelector('.video-player-theme-container');
|
|
197
|
-
|
|
198
|
-
if (mediaTheme && mediaTheme.shadowRoot) {
|
|
199
|
-
const fullscreenButton = mediaTheme.shadowRoot.querySelector('media-fullscreen-button');
|
|
200
|
-
const playbackRateButton = mediaTheme.shadowRoot.querySelector('media-playback-rate-menu');
|
|
201
|
-
playbackRateButton.setAttribute('rates', '0.25 0.5 0.75 1 1.5 2 3');
|
|
202
|
-
if (fullscreenButton) {
|
|
203
|
-
fullscreenButton.handleClick = async (event) => {
|
|
204
|
-
event.preventDefault();
|
|
205
|
-
event.stopPropagation();
|
|
206
|
-
event.stopImmediatePropagation();
|
|
207
|
-
startFullscreen();
|
|
208
|
-
}
|
|
209
|
-
observer.disconnect();
|
|
210
|
-
} else {
|
|
211
|
-
console.error('Button not found in Shadow DOM!');
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
console.error('Shadow Root not found!');
|
|
215
|
-
}
|
|
216
|
-
})
|
|
217
|
-
observer.observe(document.body, { childList: true, subtree: true });
|
|
218
|
-
}
|
|
219
156
|
})
|
|
220
157
|
|
|
221
158
|
onUpdated(() => {
|
|
@@ -373,7 +310,6 @@ function prepareVideoPlayer() {
|
|
|
373
310
|
hls.loadSource(stream)
|
|
374
311
|
hls.attachMedia(video.value)
|
|
375
312
|
|
|
376
|
-
hls.attachMedia(video.value)
|
|
377
313
|
video.value.muted = props.isMuted
|
|
378
314
|
video.value.currentTime = props.progress
|
|
379
315
|
|
|
@@ -415,6 +351,73 @@ function prepareVideoPlayer() {
|
|
|
415
351
|
});
|
|
416
352
|
}
|
|
417
353
|
setInterval(checkTrackModeChanges, 100);
|
|
354
|
+
initVideo();
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function initVideo() {
|
|
359
|
+
if (video.value) {
|
|
360
|
+
|
|
361
|
+
// pass video element as reference to model
|
|
362
|
+
if (!videoElement.value) {
|
|
363
|
+
videoElement.value = video.value;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
video.value.addEventListener('timeupdate', updateCurrentTime);
|
|
367
|
+
document.addEventListener('fullscreenchange', onFullscreenChange);
|
|
368
|
+
document.addEventListener('orientationchange', onOrientationChange);
|
|
369
|
+
window.screen.orientation.addEventListener("change", onOrientationChange);
|
|
370
|
+
|
|
371
|
+
if(video.value.paused || video.value.currentTime === 0) {
|
|
372
|
+
initialPlayButton.value = true
|
|
373
|
+
|
|
374
|
+
if(props.hideInitialPlayButton) {
|
|
375
|
+
setTimeout(() => {
|
|
376
|
+
hideInitialPlayButton.value = true
|
|
377
|
+
}, 1200)
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* detect initial display orientation
|
|
383
|
+
*/
|
|
384
|
+
if (typeof window.orientation === "undefined") {
|
|
385
|
+
orientation.value = window.screen.orientation.angle === 0 || window.screen.orientation.angle === 180
|
|
386
|
+
? "portrait"
|
|
387
|
+
: "landscape";
|
|
388
|
+
} else {
|
|
389
|
+
orientation.value = window.orientation === 0 || window.orientation === 180
|
|
390
|
+
? "portrait"
|
|
391
|
+
: "landscape"; // for safari
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* overwrite player.style video fullscreen button
|
|
396
|
+
* to inject own fullscreen logic
|
|
397
|
+
*/
|
|
398
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
399
|
+
const mediaTheme = document.querySelector('.video-player-theme-container');
|
|
400
|
+
|
|
401
|
+
if (mediaTheme && mediaTheme.shadowRoot) {
|
|
402
|
+
const fullscreenButton = mediaTheme.shadowRoot.querySelector('media-fullscreen-button');
|
|
403
|
+
const playbackRateButton = mediaTheme.shadowRoot.querySelector('media-playback-rate-menu');
|
|
404
|
+
playbackRateButton.setAttribute('rates', '0.25 0.5 0.75 1 1.5 2 3');
|
|
405
|
+
if (fullscreenButton) {
|
|
406
|
+
fullscreenButton.handleClick = async (event) => {
|
|
407
|
+
event.preventDefault();
|
|
408
|
+
event.stopPropagation();
|
|
409
|
+
event.stopImmediatePropagation();
|
|
410
|
+
startFullscreen();
|
|
411
|
+
}
|
|
412
|
+
observer.disconnect();
|
|
413
|
+
} else {
|
|
414
|
+
console.error('Button not found in Shadow DOM!');
|
|
415
|
+
}
|
|
416
|
+
} else {
|
|
417
|
+
console.error('Shadow Root not found!');
|
|
418
|
+
}
|
|
419
|
+
})
|
|
420
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
418
421
|
}
|
|
419
422
|
}
|
|
420
423
|
|