@srgssr/pillarbox-web 1.35.0 → 1.36.0

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.35.1";
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
  *
@@ -73337,7 +73449,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73337
73449
 
73338
73450
  // Calculate the position timestamp from the start date on Safari
73339
73451
  if (pillarbox.browser.IS_ANY_SAFARI) {
73340
- const startDate = Date.parse(this.player.$('video').getStartDate());
73452
+ const startDate = Date.parse(this.player.tech(true).el().getStartDate());
73341
73453
  position_timestamp = !isNaN(startDate) ? startDate + position : undefined;
73342
73454
  }
73343
73455
  return {