@grfzhl/vue-hls-player 1.1.1 → 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.
@@ -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
@@ -154,69 +153,6 @@ const videoElement = defineModel()
154
153
 
155
154
  onMounted(() => {
156
155
  prepareVideoPlayer()
157
- if (video.value) {
158
-
159
- // pass video element as reference to model
160
- if (!videoElement.value) {
161
- videoElement.value = video.value;
162
- }
163
-
164
- video.value.addEventListener('timeupdate', updateCurrentTime);
165
- document.addEventListener('fullscreenchange', onFullscreenChange);
166
- document.addEventListener('orientationchange', onOrientationChange);
167
- window.screen.orientation.addEventListener("change", onOrientationChange);
168
-
169
- if(video.value.paused || video.value.currentTime === 0) {
170
- initialPlayButton.value = true
171
-
172
- if(props.hideInitialPlayButton) {
173
- setTimeout(() => {
174
- hideInitialPlayButton.value = true
175
- }, 1200)
176
- }
177
- }
178
-
179
- /**
180
- * detect initial display orientation
181
- */
182
- if (typeof window.orientation === "undefined") {
183
- orientation.value = window.screen.orientation.angle === 0 || window.screen.orientation.angle === 180
184
- ? "portrait"
185
- : "landscape";
186
- } else {
187
- orientation.value = window.orientation === 0 || window.orientation === 180
188
- ? "portrait"
189
- : "landscape"; // for safari
190
- }
191
-
192
- /**
193
- * overwrite player.style video fullscreen button
194
- * to inject own fullscreen logic
195
- */
196
- const observer = new MutationObserver((mutationsList, observer) => {
197
- const mediaTheme = document.querySelector('.video-player-theme-container');
198
-
199
- if (mediaTheme && mediaTheme.shadowRoot) {
200
- const fullscreenButton = mediaTheme.shadowRoot.querySelector('media-fullscreen-button');
201
- const playbackRateButton = mediaTheme.shadowRoot.querySelector('media-playback-rate-menu');
202
- playbackRateButton.setAttribute('rates', '0.25 0.5 0.75 1 1.5 2 3');
203
- if (fullscreenButton) {
204
- fullscreenButton.handleClick = async (event) => {
205
- event.preventDefault();
206
- event.stopPropagation();
207
- event.stopImmediatePropagation();
208
- startFullscreen();
209
- }
210
- observer.disconnect();
211
- } else {
212
- console.error('Button not found in Shadow DOM!');
213
- }
214
- } else {
215
- console.error('Shadow Root not found!');
216
- }
217
- })
218
- observer.observe(document.body, { childList: true, subtree: true });
219
- }
220
156
  })
221
157
 
222
158
  onUpdated(() => {
@@ -374,7 +310,6 @@ function prepareVideoPlayer() {
374
310
  hls.loadSource(stream)
375
311
  hls.attachMedia(video.value)
376
312
 
377
- hls.attachMedia(video.value)
378
313
  video.value.muted = props.isMuted
379
314
  video.value.currentTime = props.progress
380
315
 
@@ -416,6 +351,73 @@ function prepareVideoPlayer() {
416
351
  });
417
352
  }
418
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 });
419
421
  }
420
422
  }
421
423
 
@@ -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,7 +208,7 @@ function isTxtCueActive(txtCue) {
207
208
  * @param txtIndex
208
209
  */
209
210
  function isWordActive(txtCue, word, wordIndex, txtIndex) {
210
- console.log("check word active ", txtCue, word, wordIndex, txtIndex)
211
+ console.log("check word active ", txtCue, word, wordIndex, currentCue.value)
211
212
  if(!currentCue.value || !word || !txtCue) {
212
213
  return false
213
214
  }
@@ -222,6 +223,7 @@ function isWordActive(txtCue, word, wordIndex, txtIndex) {
222
223
 
223
224
  function checkCurrentCue(currentCursor) {
224
225
  Array.from(vttCues.value).forEach((a, index) => {
226
+ console.log("current cue", a)
225
227
  if(currentCursor >= a.start && currentCursor <= a.end) {
226
228
  currentCue.value = a.text
227
229
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@grfzhl/vue-hls-player",
3
3
  "private": false,
4
- "version": "1.1.1",
4
+ "version": "1.1.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"