@grfzhl/vue-hls-player 1.1.10 → 1.1.12

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
@@ -187,7 +187,36 @@ it makes the video muted
187
187
 
188
188
  it will set the native <video> autoplay property
189
189
 
190
+ **options**
191
+ 1. value: object with settings, type Object
192
+
193
+ It contains various options to customize
194
+ the player.
195
+ At the moment the following attribute are supported:
196
+ ```
197
+ ui: {
198
+ labels: {
199
+ play: 'Play',
200
+ pause: 'Pause',
201
+ fullscreen: 'Toggle fullscreen',
202
+ exitFullscreen: 'Toggle fullscreen',
203
+ mute: 'Mute',
204
+ unmute: 'Unmute',
205
+ }
206
+ }
207
+ ```
208
+
190
209
  ### Last release:
210
+ v1.0.12
211
+ - added component property to make it easier adding headers (like Authorization header into every hls request)
212
+
213
+ v1.0.14 - v1.1.11
214
+ - Fixes
215
+ - iOS specific improvements
216
+ - New Options to customize the component
217
+ - Fix problem with not updating transcript highlighting
218
+ - Extending overloaded functions for fullscreen mode (WIP)
219
+
191
220
  v1.0.9 - v1.0.14
192
221
  - Fixes
193
222
  - Small styling improvements
@@ -19,6 +19,7 @@
19
19
  </div>
20
20
  <slot name="before-media"></slot>
21
21
  <media-theme-sutro class="video-player-theme-container" :class="{'is-fullscreen': isFullscreen}">
22
+
22
23
  <video
23
24
  class="hls-player"
24
25
  slot="media"
@@ -49,6 +50,16 @@
49
50
  @error="onSubtitleError(subtitle.link)"
50
51
  :label="subtitle.label" :default="i === 0" />
51
52
  </video>
53
+ <media-control-bar>
54
+ <media-fullscreen-button>
55
+ <span slot="tooltip-enter" v-if="options?.ui?.labels?.fullscreen">
56
+ {{ options.ui.labels.fullscreen }}
57
+ </span>
58
+ <span slot="tooltip-exit" v-if="options?.ui?.labels?.exitFullscreen">
59
+ {{ options.ui.labels.exitFullscreen }}
60
+ </span>
61
+ </media-fullscreen-button>
62
+ </media-control-bar>
52
63
  </media-theme-sutro>
53
64
  <div class="custom-subtitles" v-show="(isFullscreen) || (!showTranscriptBlock)">
54
65
  <div class="subtitle-text" ref="subtitlesContainer" style="display: none;"></div>
@@ -60,7 +71,8 @@
60
71
  <SubtitleBlock
61
72
  ref="transcriptRef"
62
73
  :subtitle="currentSubtitle"
63
- :cursor="videoCursor"
74
+ :cursor="videoCursor"
75
+ :options="options"
64
76
  :showTranscriptBlock="showTranscriptBlock"
65
77
  @seek="seekVideo"
66
78
  @toggleTranscript="toggleTranscript">
@@ -104,6 +116,10 @@ const props = defineProps({
104
116
  type: Boolean,
105
117
  default: false
106
118
  },
119
+ additionHeaders: {
120
+ type: Object,
121
+ default: {}
122
+ }
107
123
  /**
108
124
  * array of object, for
109
125
  * subtitles to append:
@@ -132,6 +148,10 @@ const props = defineProps({
132
148
  fullScreenElement: {
133
149
  type: String,
134
150
  default: 'hls-player-media-container'
151
+ },
152
+ options: {
153
+ type: Object,
154
+ default: {}
135
155
  }
136
156
  })
137
157
 
@@ -150,6 +170,7 @@ const previewImageLink = toRef(props, 'previewImageLink');
150
170
  const link = toRef(props, 'link');
151
171
  let currentTime = 0
152
172
  let hls = null
173
+ let buttonElement = null
153
174
 
154
175
  const videoElement = defineModel()
155
176
 
@@ -217,9 +238,49 @@ async function startFullscreen() {
217
238
  document.webkitExitFullscreen();
218
239
  }
219
240
  isFullscreen.value = false;
241
+ buttonElement.setAttribute('aria-label', "Enter fullscreen mode")
242
+ const tooltip = buttonElement.querySelector('media-tooltip');
243
+
244
+ if (tooltip) {
245
+ console.log("Tooltip gefunden:", tooltip);
246
+
247
+ // Slots für Tooltip-Enter und Tooltip-Exit finden
248
+ const enterTooltip = tooltip.querySelector('slot[name="tooltip-enter"]');
249
+ const exitTooltip = tooltip.querySelector('slot[name="tooltip-exit"]');
250
+
251
+ if (enterTooltip && exitTooltip) {
252
+ enterTooltip.style.display = 'block';
253
+ exitTooltip.style.display = 'none';
254
+ } else {
255
+ console.warn("Tooltip-Slots nicht gefunden!");
256
+ }
257
+ } else {
258
+ console.warn("Kein media-tooltip gefunden!");
259
+ }
220
260
  } else {
221
261
  isFullscreen.value = true;
222
262
  try {
263
+ buttonElement.setAttribute('aria-label', "Exit fullscreen mode")
264
+
265
+ const tooltip = buttonElement.querySelector('media-tooltip');
266
+
267
+ if (tooltip) {
268
+ console.log("Tooltip gefunden:", tooltip);
269
+
270
+ // Slots für Tooltip-Enter und Tooltip-Exit finden
271
+ const enterTooltip = tooltip.querySelector('slot[name="tooltip-enter"]');
272
+ const exitTooltip = tooltip.querySelector('slot[name="tooltip-exit"]');
273
+
274
+ if (enterTooltip && exitTooltip) {
275
+ enterTooltip.style.display = 'none';
276
+ exitTooltip.style.display = 'block';
277
+ } else {
278
+ console.warn("Tooltip-Slots nicht gefunden!");
279
+ }
280
+ } else {
281
+ console.warn("Kein media-tooltip gefunden!");
282
+ }
283
+
223
284
  if (vpVideoBlock.requestFullscreen) {
224
285
  await vpVideoBlock.requestFullscreen();
225
286
  } else if (/iPhone|iPad|AppleWebKit/i.test(navigator.userAgent)) {
@@ -331,6 +392,21 @@ function prepareVideoPlayer(link) {
331
392
  hls.attachMedia(video.value)
332
393
  hls.recoverMediaError()
333
394
 
395
+ if(props.additionHeaders) {
396
+ /**
397
+ * inject additional headers
398
+ */
399
+ hls.config.fetchSetup = async (context, init) => {
400
+ init = init || {};
401
+ init.headers = new Headers(init.headers || {});
402
+ // set headers
403
+ for (const [key, value] of Object.entries(props.headers)) {
404
+ init.headers.set(key, value);
405
+ }
406
+ return new Request(context.url, init);
407
+ };
408
+ }
409
+
334
410
  video.value.muted = props.isMuted
335
411
  video.value.currentTime = props.progress
336
412
 
@@ -420,6 +496,7 @@ function initVideo() {
420
496
  const mediaTheme = document.querySelector('.video-player-theme-container');
421
497
  if (mediaTheme && mediaTheme.shadowRoot) {
422
498
  const fullscreenButton = mediaTheme.shadowRoot.querySelector('media-fullscreen-button');
499
+ buttonElement = fullscreenButton
423
500
  const playbackRateButton = mediaTheme.shadowRoot.querySelector('media-playback-rate-menu');
424
501
  playbackRateButton.setAttribute('rates', '0.25 0.5 0.75 1 1.5 2 3');
425
502
  if (fullscreenButton) {
@@ -8,6 +8,7 @@
8
8
  :autoplay="autoplay"
9
9
  :isControls="isControls"
10
10
  :onVideoEnd="onVideoEnd"
11
+ :additionHeaders="additionHeaders"
11
12
  :isFullscreen="isFullscreen"
12
13
  :showTranscriptBlock="showTranscriptBlock"
13
14
  :hideInitialPlayButton="hideInitialPlayButton"
@@ -77,6 +78,14 @@ const props = defineProps({
77
78
  fullScreenElement: {
78
79
  type: String,
79
80
  default: 'hls-player-media-container'
81
+ },
82
+ options: {
83
+ type: Object,
84
+ default: {}
85
+ },
86
+ additionHeaders: {
87
+ type: Object,
88
+ default: {}
80
89
  }
81
90
  })
82
91
 
@@ -4,6 +4,7 @@
4
4
  @pause="pause"
5
5
  @video-fullscreen-change="onVideoFullScreenChange"
6
6
  @video-ended="onVideoEnd"
7
+ :additionHeaders="additionHeaders"
7
8
  :introTitle="introTitle"
8
9
  :previewImageLink="previewImageLink"
9
10
  :showTranscriptBlock="showTranscriptBlock"
@@ -87,6 +88,14 @@ const props = defineProps({
87
88
  fullScreenElement: {
88
89
  type: String,
89
90
  default: 'hls-player-media-container'
91
+ },
92
+ options: {
93
+ type: Object,
94
+ default: {}
95
+ },
96
+ additionHeaders: {
97
+ type: Object,
98
+ default: {}
90
99
  }
91
100
  })
92
101
 
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.10",
4
+ "version": "1.1.12",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"