@grfzhl/vue-hls-player 1.1.0 → 1.1.2
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.
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
:autoplay="autoplay && isMuted"
|
|
39
39
|
>
|
|
40
40
|
<source
|
|
41
|
-
:src="link"
|
|
42
41
|
type="application/x-mpegURL"
|
|
43
42
|
/>
|
|
44
43
|
<track
|
|
@@ -148,7 +147,7 @@ const hideInitialPlayButton = ref(false)
|
|
|
148
147
|
const link = toRef(props, 'link');
|
|
149
148
|
const previewImageLink = toRef(props, 'previewImageLink');
|
|
150
149
|
let currentTime = 0
|
|
151
|
-
let hls =
|
|
150
|
+
let hls = null
|
|
152
151
|
|
|
153
152
|
const videoElement = defineModel()
|
|
154
153
|
|
|
@@ -259,6 +258,7 @@ watch([props, videoElement], (a) => {
|
|
|
259
258
|
|
|
260
259
|
watch(link, (newLink, oldLink) => {
|
|
261
260
|
if (newLink !== oldLink) {
|
|
261
|
+
console.log("prepare new src " + newLink)
|
|
262
262
|
prepareVideoPlayer();
|
|
263
263
|
}
|
|
264
264
|
})
|
|
@@ -364,11 +364,15 @@ function seekVideo(time) {
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
function prepareVideoPlayer() {
|
|
367
|
-
let stream = props.link
|
|
368
|
-
hls.loadSource(stream)
|
|
369
|
-
hls.attachMedia(video.value)
|
|
370
|
-
|
|
371
367
|
if (video.value) {
|
|
368
|
+
if (hls) {
|
|
369
|
+
hls.destroy();
|
|
370
|
+
}
|
|
371
|
+
hls = new Hls();
|
|
372
|
+
let stream = props.link
|
|
373
|
+
hls.loadSource(stream)
|
|
374
|
+
hls.attachMedia(video.value)
|
|
375
|
+
|
|
372
376
|
hls.attachMedia(video.value)
|
|
373
377
|
video.value.muted = props.isMuted
|
|
374
378
|
video.value.currentTime = props.progress
|
|
@@ -161,6 +161,7 @@ watch(
|
|
|
161
161
|
watch(
|
|
162
162
|
() => props.cursor,
|
|
163
163
|
(currentTime) => {
|
|
164
|
+
console.log("cursor watch", currentTime)
|
|
164
165
|
highlightActiveCue(currentTime);
|
|
165
166
|
checkCurrentCue(currentTime)
|
|
166
167
|
}
|
|
@@ -207,11 +208,13 @@ function isTxtCueActive(txtCue) {
|
|
|
207
208
|
* @param txtIndex
|
|
208
209
|
*/
|
|
209
210
|
function isWordActive(txtCue, word, wordIndex, txtIndex) {
|
|
211
|
+
console.log("check word active ", txtCue, word, wordIndex, currentCue.value)
|
|
210
212
|
if(!currentCue.value || !word || !txtCue) {
|
|
211
213
|
return false
|
|
212
214
|
}
|
|
213
215
|
const startPos = txtCue.dialog[0].text.indexOf(currentCue.value)
|
|
214
216
|
const endPos = startPos + currentCue.value.length
|
|
217
|
+
console.log("can word marked", startPos, endPos, wordIndex)
|
|
215
218
|
if(wordIndex >= startPos && wordIndex < endPos) {
|
|
216
219
|
return true;
|
|
217
220
|
}
|
|
@@ -220,6 +223,7 @@ function isWordActive(txtCue, word, wordIndex, txtIndex) {
|
|
|
220
223
|
|
|
221
224
|
function checkCurrentCue(currentCursor) {
|
|
222
225
|
Array.from(vttCues.value).forEach((a, index) => {
|
|
226
|
+
console.log("current cue", a)
|
|
223
227
|
if(currentCursor >= a.start && currentCursor <= a.end) {
|
|
224
228
|
currentCue.value = a.text
|
|
225
229
|
}
|