@srgssr/pillarbox-web 1.35.1 → 1.36.1

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.
@@ -93,7 +93,7 @@
93
93
  return "symbol" == typeof i ? i : i + "";
94
94
  }
95
95
 
96
- const version$8 = "1.35.0";
96
+ const version$8 = "1.36.0";
97
97
 
98
98
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
99
99
 
@@ -28404,7 +28404,7 @@
28404
28404
  *
28405
28405
  * @extends Button
28406
28406
  */
28407
- class PictureInPictureToggle extends Button {
28407
+ let PictureInPictureToggle$1 = class PictureInPictureToggle extends Button {
28408
28408
  /**
28409
28409
  * Creates an instance of this class.
28410
28410
  *
@@ -28524,7 +28524,7 @@
28524
28524
  }
28525
28525
  super.show();
28526
28526
  }
28527
- }
28527
+ };
28528
28528
 
28529
28529
  /**
28530
28530
  * The text that should display over the `PictureInPictureToggle`s controls. Added for localization.
@@ -28532,8 +28532,8 @@
28532
28532
  * @type {string}
28533
28533
  * @protected
28534
28534
  */
28535
- PictureInPictureToggle.prototype.controlText_ = 'Picture-in-Picture';
28536
- Component$1.registerComponent('PictureInPictureToggle', PictureInPictureToggle);
28535
+ PictureInPictureToggle$1.prototype.controlText_ = 'Picture-in-Picture';
28536
+ Component$1.registerComponent('PictureInPictureToggle', PictureInPictureToggle$1);
28537
28537
 
28538
28538
  /**
28539
28539
  * @file fullscreen-toggle.js
@@ -71215,6 +71215,79 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71215
71215
  return ranges;
71216
71216
  }
71217
71217
 
71218
+ /**
71219
+ * Create a floating video window always on top of other windows so that users may
71220
+ * continue consuming media while they interact with other content sites, or
71221
+ * applications on their device.
71222
+ *
71223
+ * This can use document picture-in-picture or element picture in picture
71224
+ *
71225
+ * Set `enableDocumentPictureInPicture` to `true` to use docPiP on a supported browser
71226
+ * Else set `disablePictureInPicture` to `false` to disable elPiP on a supported browser
71227
+ *
71228
+ *
71229
+ * @see [Spec]{@link https://w3c.github.io/picture-in-picture/}
71230
+ * @see [Spec]{@link https://wicg.github.io/document-picture-in-picture/}
71231
+ *
71232
+ * @fires Player#enterpictureinpicture
71233
+ *
71234
+ * @return {Promise}
71235
+ * A promise with a Picture-in-Picture window.
71236
+ */
71237
+ /* eslint-disable */
71238
+ requestPictureInPicture() {
71239
+ if (this.options_.enableDocumentPictureInPicture && window.documentPictureInPicture) {
71240
+ const pipContainer = document.createElement(this.el().tagName);
71241
+ pipContainer.classList = this.el().classList;
71242
+ pipContainer.classList.add('vjs-pip-container');
71243
+ if (this.posterImage) {
71244
+ pipContainer.appendChild(this.posterImage.el().cloneNode(true));
71245
+ }
71246
+ if (this.titleBar) {
71247
+ pipContainer.appendChild(this.titleBar.el().cloneNode(true));
71248
+ }
71249
+ pipContainer.appendChild(videojs.dom.createEl('p', {
71250
+ className: 'vjs-pip-text'
71251
+ }, {}, this.localize('Playing in picture-in-picture')));
71252
+ return window.documentPictureInPicture.requestWindow({
71253
+ // The aspect ratio won't be correct, Chrome bug https://crbug.com/1407629
71254
+ width: this.videoWidth(),
71255
+ height: this.videoHeight()
71256
+ }).then(pipWindow => {
71257
+ videojs.dom.copyStyleSheetsToWindow(pipWindow);
71258
+ this.el_.parentNode.insertBefore(pipContainer, this.el_);
71259
+ pipWindow.document.body.appendChild(this.el_);
71260
+ pipWindow.document.body.classList.add('vjs-pip-window');
71261
+ this.player_.isInPictureInPicture(true);
71262
+ this.player_.trigger({
71263
+ type: 'enterpictureinpicture',
71264
+ pipWindow
71265
+ });
71266
+
71267
+ // Listen for the PiP closing event to move the video back.
71268
+ pipWindow.addEventListener('pagehide', event => {
71269
+ console.log(event.target);
71270
+ const pipVideo = event.target.querySelector('.vjs-v8');
71271
+ pipContainer.parentNode.replaceChild(pipVideo, pipContainer);
71272
+ this.player_.isInPictureInPicture(false);
71273
+ this.player_.trigger('leavepictureinpicture');
71274
+ });
71275
+ return pipWindow;
71276
+ });
71277
+ }
71278
+ if ('pictureInPictureEnabled' in document && this.disablePictureInPicture() === false) {
71279
+ /**
71280
+ * This event fires when the player enters picture in picture mode
71281
+ *
71282
+ * @event Player#enterpictureinpicture
71283
+ * @type {Event}
71284
+ */
71285
+ return this.techGet_('requestPictureInPicture');
71286
+ }
71287
+ return Promise.reject('No PiP mode is available');
71288
+ }
71289
+ /* eslint-enable */
71290
+
71218
71291
  /**
71219
71292
  * Get the percent (as a decimal) of the media that's been played.
71220
71293
  * This method is not a part of the native HTML video API.
@@ -71479,6 +71552,45 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71479
71552
  videojs.registerComponent('AudioTrackMenuItem', AudioTrackMenuItem);
71480
71553
  videojs.registerComponent('AudioTrackButton', AudioTrackButton);
71481
71554
 
71555
+ /**
71556
+ * @ignore
71557
+ */
71558
+ const VJSPictureInPictureToggle = videojs.getComponent('PictureInPictureToggle');
71559
+ class PictureInPictureToggle extends VJSPictureInPictureToggle {
71560
+ /**
71561
+ * Displays or hides the button depending on the audio mode detection.
71562
+ * Exits picture-in-picture if it is enabled when switching to audio mode.
71563
+ */
71564
+ /* eslint-disable */
71565
+ handlePictureInPictureAudioModeChange() {
71566
+ // This audio detection will not detect HLS or DASH audio-only streams because there was no reliable way to detect them at the time
71567
+ const isSourceAudio = this.player_.currentType().substring(0, 5) === 'audio';
71568
+ const isAudioMode = isSourceAudio || this.player_.audioPosterMode() || this.player_.audioOnlyMode();
71569
+ if (!isAudioMode || this.player_.options_.enableDocumentPictureInPicture && 'documentPictureInPicture' in window) {
71570
+ this.show();
71571
+ return;
71572
+ }
71573
+ if (this.player_.isInPictureInPicture()) {
71574
+ this.player_.exitPictureInPicture();
71575
+ }
71576
+ this.hide();
71577
+ }
71578
+ /* eslint-enable */
71579
+
71580
+ /**
71581
+ * Show the `Component`s element if it is hidden by removing the
71582
+ * 'vjs-hidden' class name from it only in browsers that support the Picture-in-Picture API.
71583
+ */
71584
+ show() {
71585
+ // Does not allow to display the pictureInPictureToggle in browsers that do not support the Picture-in-Picture or DocumentPictureInPicture API.
71586
+ if (typeof document.exitPictureInPicture !== 'function' && !(this.player_.options_.enableDocumentPictureInPicture && 'documentPictureInPicture' in window)) {
71587
+ return;
71588
+ }
71589
+ this.removeClass('vjs-hidden');
71590
+ }
71591
+ }
71592
+ videojs.registerComponent('PictureInPictureToggle', PictureInPictureToggle);
71593
+
71482
71594
  /**
71483
71595
  * Pillarbox is an alias for the video.js namespace with additional options.
71484
71596
  *
@@ -75120,25 +75232,23 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75120
75232
  */
75121
75233
  static createTextTrack(_x5, _x6) {
75122
75234
  return _asyncToGenerator(function* (player, trackId, cues = []) {
75123
- const removeTrack = player.textTracks().getTrackById(trackId);
75235
+ const removeTrack = player.remoteTextTracks().getTrackById(trackId);
75124
75236
  if (removeTrack) {
75125
- player.textTracks().removeTrack(removeTrack);
75237
+ player.removeRemoteTextTrack(removeTrack);
75126
75238
  }
75239
+ const textTrack = player.addRemoteTextTrack({
75240
+ id: trackId,
75241
+ kind: 'metadata',
75242
+ label: trackId
75243
+ });
75244
+
75245
+ // Safari
75246
+ textTrack.track.mode = 'hidden';
75127
75247
 
75128
75248
  // See https://github.com/videojs/video.js/issues/8519
75129
- const textTrack = yield new Promise(resolve => {
75130
- setTimeout(() => {
75131
- resolve(new pillarbox.TextTrack({
75132
- id: trackId,
75133
- kind: 'metadata',
75134
- label: trackId,
75135
- tech: player.tech(true)
75136
- }));
75137
- }, 100);
75138
- });
75139
- SrgSsr.addTextTrackCues(textTrack, cues);
75140
- player.textTracks().addTrack(textTrack);
75141
- return textTrack;
75249
+ yield new Promise(resolve => setTimeout(resolve, 100));
75250
+ SrgSsr.addTextTrackCues(textTrack.track, cues);
75251
+ return textTrack.track;
75142
75252
  }).apply(this, arguments);
75143
75253
  }
75144
75254
 
@@ -75148,12 +75258,12 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75148
75258
  * @param {Player} player
75149
75259
  */
75150
75260
  static cuechangeEventProxy(player) {
75151
- player.textTracks().on('addtrack', ({
75261
+ player.textTracks().on('addtrack', /** @param {{ track: TextTrack }} */({
75152
75262
  track
75153
75263
  }) => {
75154
75264
  if (!['srgssr-chapters', 'srgssr-intervals'].includes(track.id)) return;
75155
- track.on('cuechange', () => {
75156
- const [cue] = Array.from(track.activeCues);
75265
+ track.addEventListener('cuechange', () => {
75266
+ const [cue] = Array.from(track.activeCues || []);
75157
75267
  const type = track.id.includes('srgssr-chapters') ? 'srgssr/chapter' : 'srgssr/interval';
75158
75268
  player.trigger({
75159
75269
  type,
@@ -75255,7 +75365,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75255
75365
  if (!blockedSegmentsTrack) return;
75256
75366
 
75257
75367
  /** @type {VTTCue} */
75258
- const [blockedCue] = Array.from(blockedSegmentsTrack.activeCues);
75368
+ const [blockedCue] = Array.from(blockedSegmentsTrack.activeCues || []);
75259
75369
  return blockedCue;
75260
75370
  }
75261
75371