@grfzhl/vue-hls-player 1.0.19 → 1.0.20
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.
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
:src="subtitle.link"
|
|
47
47
|
kind="subtitles"
|
|
48
48
|
:srclang="subtitle.lang"
|
|
49
|
+
@error="onSubtitleError(subtitle.link)"
|
|
49
50
|
:label="subtitle.label" :default="i === 0" />
|
|
50
51
|
</video>
|
|
51
52
|
</media-theme-sutro>
|
|
@@ -141,6 +142,7 @@ const initialPlayButton = ref(false);
|
|
|
141
142
|
const hideInitialPlayButton = ref(false)
|
|
142
143
|
const link = toRef(props, 'link');
|
|
143
144
|
const previewImageLink = toRef(props, 'previewImageLink');
|
|
145
|
+
let hls = new Hls()
|
|
144
146
|
|
|
145
147
|
const videoElement = defineModel()
|
|
146
148
|
|
|
@@ -218,10 +220,10 @@ onUpdated(() => {
|
|
|
218
220
|
onUnmounted(() => {
|
|
219
221
|
if (video.value) {
|
|
220
222
|
video.value.removeEventListener('timeupdate', updateCurrentTime);
|
|
221
|
-
document.removeEventListener('fullscreenchange', onFullscreenChange);
|
|
222
|
-
document.removeEventListener('orientationchange', onOrientationChange);
|
|
223
|
-
window.screen.orientation.addEventListener("change", onOrientationChange);
|
|
224
223
|
}
|
|
224
|
+
document.removeEventListener('fullscreenchange', onFullscreenChange);
|
|
225
|
+
document.removeEventListener('orientationchange', onOrientationChange);
|
|
226
|
+
window.screen.orientation.removeEventListener("change", onOrientationChange);
|
|
225
227
|
});
|
|
226
228
|
|
|
227
229
|
const mutedAttr = computed(() => {
|
|
@@ -240,15 +242,23 @@ const currentSubtitle = computed(() => {
|
|
|
240
242
|
})
|
|
241
243
|
|
|
242
244
|
watch([props, videoElement], (a) => {
|
|
243
|
-
if(a[0].autoplay && a[1]) {
|
|
245
|
+
if(a[0].autoplay && a[1] && a[1].paused) {
|
|
244
246
|
// autoplay is only possible when muted
|
|
245
247
|
a[1].muted = true
|
|
246
248
|
setTimeout(() => {
|
|
247
|
-
a[1].play();
|
|
249
|
+
a[1].play().catch(err => console.warn("Autoplay-Error:", err));
|
|
248
250
|
}, 200)
|
|
249
251
|
}
|
|
250
252
|
})
|
|
251
253
|
|
|
254
|
+
watch(link, (v) => {
|
|
255
|
+
prepareVideoPlayer();
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
function onSubtitleError(link) {
|
|
259
|
+
console.error(`Error on loading subtitles: ${link}`);
|
|
260
|
+
}
|
|
261
|
+
|
|
252
262
|
function onFullscreenChange() {
|
|
253
263
|
isFullscreen.value = !!document.fullscreenElement
|
|
254
264
|
emit('video-fullscreen-change', document.fullscreenElement)
|
|
@@ -297,9 +307,9 @@ function seekVideo(time) {
|
|
|
297
307
|
}
|
|
298
308
|
|
|
299
309
|
function prepareVideoPlayer() {
|
|
300
|
-
let hls = new Hls()
|
|
301
310
|
let stream = props.link
|
|
302
311
|
hls.loadSource(stream)
|
|
312
|
+
hls.attachMedia(video.value)
|
|
303
313
|
|
|
304
314
|
if (video.value) {
|
|
305
315
|
hls.attachMedia(video.value)
|