@grfzhl/vue-hls-player 1.0.6 → 1.0.7

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/README.md CHANGED
@@ -39,24 +39,26 @@ npm i vue-hls-player
39
39
  </script>
40
40
 
41
41
  <template>
42
- <VideoPlayer
43
- type="default"
44
- @pause="processPause"
45
- previewImageLink="poster.webp"
46
- link="videoLink.m3u8"
47
- :progress="30"
48
- :isMuted="false"
49
- :isControls="true"
50
- :subtitles="subtitles"
51
- class="customClassName"
52
- />
53
-
54
- <VideoPlayer
55
- type="preview"
56
- previewImageLink="poster.webp"
57
- link="videoLink.m3u8"
58
- class="customClassName"
59
- />
42
+ <div id="video-container">
43
+ <VideoPlayer
44
+ type="default"
45
+ @pause="processPause"
46
+ previewImageLink="poster.webp"
47
+ link="videoLink.m3u8"
48
+ :progress="30"
49
+ :isMuted="false"
50
+ :isControls="true"
51
+ :subtitles="subtitles"
52
+ class="customClassName"
53
+ />
54
+
55
+ <VideoPlayer
56
+ type="preview"
57
+ previewImageLink="poster.webp"
58
+ link="videoLink.m3u8"
59
+ class="customClassName"
60
+ />
61
+ </div>
60
62
  </template>
61
63
  ```
62
64
  For **nuxt 3**, try to wrap this component in ClientOnly, images for previewImageLink need to store in public folder
@@ -97,6 +99,49 @@ function processPause(progress: number) {
97
99
  console.log(progress)
98
100
  }
99
101
  ```
102
+
103
+ **@video-ended**:
104
+ 1. Event, called if the video has ended
105
+ @video-ended="videoEnded"
106
+ ```
107
+ const videoEnded = (data) => {
108
+ console.log("video ended at time: ", data.currentTime)
109
+ console.log("video element ", data.video)
110
+ }
111
+ ```
112
+
113
+ **@video-fullscreen-change**:
114
+ 1. Event, event dispatcher for detecting fullscreen change
115
+ @video-fullscreen-change="fullscreenChange"
116
+ ```
117
+ const fullScreenAction = (fullScreenElement) => {
118
+ if(fullScreenElement === null) {
119
+ console.log("fullscreen is off")
120
+ } else {
121
+ console.log("fullscreen is on")
122
+ }
123
+ }
124
+ ```
125
+
126
+ **@video-fullscreen-action**:
127
+ 1. Event, handling the fullscreen action of the player
128
+ @video-fullscreen-action="fullScreenAction"
129
+ ```
130
+ const fullScreenAction = (data) => {
131
+ if(isFullscreen.value) {
132
+ document.exitFullscreen();
133
+ } else {
134
+ document.getElementById("video-container").requestFullscreen()
135
+ }
136
+ }
137
+ ```
138
+ **showTranscriptBlock**:
139
+ 1. value: true or false, type: Boolean
140
+
141
+ pass true, if you want to show the transcript block.
142
+ To make transcripts work, your need to provide `.txt` files
143
+ in the same path and base-filename like the passed `subtitles` prop.
144
+
100
145
  **previewImageLink**:
101
146
  1. value: 'poster.webp', type: String
102
147
 
@@ -118,19 +163,34 @@ it can show and hide the video control panel
118
163
  1. value: array of object, for subtitles to append: object has link, lang
119
164
 
120
165
  subtitles to add as tracks to the video
166
+ example:
167
+ ```
168
+ [{
169
+ link: `https://url-to-your/subtitles.vtt`,
170
+ label: 'English',
171
+ lang: 'en'
172
+ }]
173
+ ```
121
174
 
122
175
  ### Last release:
176
+ v1.0.7
177
+ - Add function to handle own logic for fullscreen
178
+
179
+ v1.0.6
180
+ - Small fixes
181
+ - Remove debug log
182
+
123
183
  v1.0.5
124
- 1. Load transcriptions additionally to subtitles
125
- 2. Add styled transcription block for better readability
126
- 3. Improve interaction and dynamic params
184
+ - Load transcriptions additionally to subtitles
185
+ - Add styled transcription block for better readability
186
+ - Improve interaction and dynamic params
127
187
 
128
188
  v1.0.4
129
- 1. Make subtitles dynamic
130
- 2. Add new switch to disable the subtitle block
131
- 3. Fix some minor issues
189
+ - Make subtitles dynamic
190
+ - Add new switch to disable the subtitle block
191
+ - Fix some minor issues
132
192
 
133
193
  v1.0.3
134
- 1. Removed controls in favour of themable overlay by `player.style`.
135
- 2. Updated hls library
136
- 3. Added styled caption overlays. Added separate container to show all captions.
194
+ - Removed controls in favour of themable overlay by `player.style`.
195
+ - Updated hls library
196
+ - Added styled caption overlays. Added separate container to show all captions.
@@ -92,7 +92,7 @@ const props = defineProps({
92
92
  }
93
93
  })
94
94
 
95
- const emit = defineEmits(['pause', 'video-ended', 'video-fullscreen-change'])
95
+ const emit = defineEmits(['pause', 'video-ended', 'video-fullscreen-change', 'video-fullscreen-action'])
96
96
  const video = ref(null)
97
97
  const subtitlesContainer = ref(null)
98
98
  const currentSubtitleLang = ref(null)
@@ -105,6 +105,32 @@ onMounted(() => {
105
105
  checkFullscreen();
106
106
  video.value.addEventListener('timeupdate', updateCurrentTime);
107
107
  document.addEventListener('fullscreenchange', onFullscreenChange);
108
+
109
+ /**
110
+ * overwrite player.style video fullscreen button
111
+ * to inject own fullscreen logic
112
+ */
113
+ const observer = new MutationObserver((mutationsList, observer) => {
114
+ const mediaTheme = document.querySelector('.video-player-theme-container');
115
+
116
+ if (mediaTheme && mediaTheme.shadowRoot) {
117
+ const fullscreenButton = mediaTheme.shadowRoot.querySelector('media-fullscreen-button');
118
+ if (fullscreenButton) {
119
+ fullscreenButton.handleClick = (event) => {
120
+ event.preventDefault();
121
+ event.stopPropagation();
122
+ event.stopImmediatePropagation();
123
+ emit('video-fullscreen-action', event)
124
+ }
125
+ observer.disconnect();
126
+ } else {
127
+ console.error('Button not found in Shadow DOM!');
128
+ }
129
+ } else {
130
+ console.error('Shadow Root not found!');
131
+ }
132
+ })
133
+ observer.observe(document.body, { childList: true, subtree: true });
108
134
  }
109
135
  })
110
136
 
@@ -11,6 +11,7 @@
11
11
  @pause="pause"
12
12
  @video-ended="onVideoEnd"
13
13
  @video-fullscreen-change="onFullscreenChange"
14
+ @video-fullscreen-action="oVideoFullscreenAction"
14
15
  />
15
16
  </template>
16
17
 
@@ -62,4 +63,8 @@ function onVideoEnd(data) {
62
63
  function onFullscreenChange(data) {
63
64
  emit('video-fullscreen-change', data);
64
65
  }
66
+
67
+ function oVideoFullscreenAction(data) {
68
+ emit('video-fullscreen-action', data)
69
+ }
65
70
  </script>
@@ -4,6 +4,7 @@
4
4
  @pause="pause"
5
5
  @video-fullscreen-change="onVideoFullScreenChange"
6
6
  @video-ended="onVideoEnd"
7
+ @video-fullscreen-action="oVideoFullscreenAction"
7
8
  :previewImageLink="previewImageLink"
8
9
  :showTranscriptBlock="showTranscriptBlock"
9
10
  :isFullscreen="isFullscreen"
@@ -23,7 +24,7 @@
23
24
  import VDefaultVideoPlayer from './VDefaultVideoPlayer.vue'
24
25
  import VPreviewVideoPlayer from './VPreviewVideoPlayer.vue'
25
26
 
26
- const emit = defineEmits(['pause', 'video-ended', 'video-fullscreen-change'])
27
+ const emit = defineEmits(['pause', 'video-ended', 'video-fullscreen-change', 'video-fullscreen-action'])
27
28
 
28
29
  defineProps({
29
30
  previewImageLink: {
@@ -69,4 +70,7 @@ function onVideoFullScreenChange(data) {
69
70
  function onVideoEnd(data) {
70
71
  emit('video-ended', data);
71
72
  }
73
+ function oVideoFullscreenAction(data) {
74
+ emit('video-fullscreen-action', data)
75
+ }
72
76
  </script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@grfzhl/vue-hls-player",
3
3
  "private": false,
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"