@srgssr/pillarbox-web 1.31.0 → 1.32.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.
@@ -94,7 +94,7 @@ function _toPropertyKey(t) {
94
94
  return "symbol" == typeof i ? i : i + "";
95
95
  }
96
96
 
97
- const version = "1.30.0";
97
+ const version = "1.32.0";
98
98
 
99
99
  /** @import VJSPlayer from 'video.js/dist/types/player' */
100
100
  /** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */
@@ -310,6 +310,151 @@ class Player extends vjsPlayer {
310
310
  }
311
311
  videojs.registerComponent('player', Player);
312
312
 
313
+ /** @import MenuItem from 'video.js/dist/types/menu/menu-item' */
314
+
315
+ /**
316
+ * @ignore
317
+ */
318
+ const VJSAudioTrackButton = videojs.getComponent('AudioTrackButton');
319
+
320
+ /**
321
+ * @ignore
322
+ * @type {typeof MenuItem}
323
+ */
324
+ const MenuItem = videojs.getComponent('MenuItem');
325
+
326
+ /**
327
+ * An {@link AudioTrack} {@link MenuItem}
328
+ *
329
+ * This is a temporary workaround.
330
+ *
331
+ * @extends MenuItem
332
+ */
333
+ class AudioTrackMenuItem extends MenuItem {
334
+ /**
335
+ * Creates an instance of this class.
336
+ *
337
+ * @param {Player} player
338
+ * The `Player` that this class should be attached to.
339
+ *
340
+ * @param {Object} [options]
341
+ * The key/value store of player options.
342
+ */
343
+ constructor(player, options) {
344
+ const track = options.track;
345
+ const tracks = player.audioTracks();
346
+
347
+ // Modify options for parent MenuItem class's init.
348
+ options.label = track.label || track.language || 'Unknown';
349
+ options.selected = track.enabled;
350
+ super(player, options);
351
+ this.track = track;
352
+ this.addClass(`vjs-${track.kind}-menu-item`);
353
+ const changeHandler = (...args) => {
354
+ this.handleTracksChange.apply(this, args);
355
+ };
356
+ tracks.addEventListener('change', changeHandler);
357
+ this.on('dispose', () => {
358
+ tracks.removeEventListener('change', changeHandler);
359
+ });
360
+ }
361
+ createEl(type, props, attrs) {
362
+ const el = super.createEl(type, props, attrs);
363
+ const parentSpan = el.querySelector('.vjs-menu-item-text');
364
+ if (['main-desc', 'descriptions', 'description'].indexOf(this.options_.track.kind) >= 0) {
365
+ parentSpan.appendChild(videojs.dom.createEl('span', {
366
+ className: 'vjs-icon-placeholder'
367
+ }, {
368
+ 'aria-hidden': true
369
+ }));
370
+ parentSpan.appendChild(videojs.dom.createEl('span', {
371
+ className: 'vjs-control-text',
372
+ textContent: ' ' + this.localize('Descriptions')
373
+ }));
374
+ }
375
+ return el;
376
+ }
377
+
378
+ /**
379
+ * This gets called when an `AudioTrackMenuItem is "clicked". See {@link ClickableComponent}
380
+ * for more detailed information on what a click can be.
381
+ *
382
+ * @param {Event} [event]
383
+ * The `keydown`, `tap`, or `click` event that caused this function to be
384
+ * called.
385
+ *
386
+ * @listens tap
387
+ * @listens click
388
+ */
389
+ handleClick(event) {
390
+ super.handleClick(event);
391
+
392
+ // the audio track list will automatically toggle other tracks
393
+ // off for us.
394
+ this.track.enabled = true;
395
+ if (!this.player_.tech_.featuresNativeAudioTracks) return;
396
+
397
+ // when native audio tracks are used, we want to make sure that other tracks are turned off
398
+ const tracks = this.player_.audioTracks();
399
+ for (let i = 0; i < tracks.length; i++) {
400
+ const track = tracks[i];
401
+
402
+ // skip the current track since we enabled it above
403
+ if (track === this.track) {
404
+ continue;
405
+ }
406
+ track.enabled = track === this.track;
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Handle any {@link AudioTrack} change.
412
+ *
413
+ * @param {Event} [event]
414
+ * The {@link AudioTrackList#change} event that caused this to run.
415
+ *
416
+ * @listens AudioTrackList#change
417
+ */
418
+ handleTracksChange() {
419
+ this.selected(this.track.enabled);
420
+ }
421
+ }
422
+
423
+ /**
424
+ * The base class for buttons that toggle specific {@link AudioTrack} types.
425
+ *
426
+ * @extends VJSAudioTrackButton
427
+ */
428
+ class AudioTrackButton extends VJSAudioTrackButton {
429
+ /**
430
+ * Create a menu item for each audio track
431
+ *
432
+ * @param {AudioTrackMenuItem[]} [items=[]]
433
+ * An array of existing menu items to use.
434
+ *
435
+ * @return {AudioTrackMenuItem[]}
436
+ * An array of menu items
437
+ */
438
+ createItems(items = []) {
439
+ // if there's only one audio track, there no point in showing it
440
+ this.hideThreshold_ = 1;
441
+ const tracks = this.player_.audioTracks();
442
+ for (let i = 0; i < tracks.length; i++) {
443
+ const track = tracks[i];
444
+ items.push(new AudioTrackMenuItem(this.player_, {
445
+ track,
446
+ // MenuItem is selectable
447
+ selectable: true,
448
+ // MenuItem is NOT multiSelectable (i.e. only one can be marked "selected" at a time)
449
+ multiSelectable: false
450
+ }));
451
+ }
452
+ return items;
453
+ }
454
+ }
455
+ videojs.registerComponent('AudioTrackMenuItem', AudioTrackMenuItem);
456
+ videojs.registerComponent('AudioTrackButton', AudioTrackButton);
457
+
313
458
  /**
314
459
  * Pillarbox is an alias for the video.js namespace with additional options.
315
460
  *
@@ -493,7 +638,7 @@ class Image {
493
638
  * @property {String} [image.format=jpg] is the format of the image, default value jpg.
494
639
  * @property {String} [imageServiceUrl] Url of the image service that needs to comply with the specification defined by the IL.
495
640
  *
496
- * @see https://confluence.srg.beecollaboration.com/pages/viewpage.action?spaceKey=SRGPLAY&title=Project+-+Image+Service
641
+ * @see https://srgssr-ch.atlassian.net/wiki/spaces/SRGPLAY/pages/799082429/Project+-+Image+Service
497
642
  *
498
643
  * @returns {String|undefined} the image scaling URL.
499
644
  */
@@ -1238,7 +1383,7 @@ class SRGAnalytics {
1238
1383
  * - pos should be sent when the media player is in "play mode".
1239
1384
  * - once the video is paused or stopped, the timer for sending these actions must be stopped.
1240
1385
  *
1241
- * @see https://confluence.srg.beecollaboration.com/display/INTFORSCHUNG/standard+streaming+events%3A+sequence+of+events+for+media+player+actions#standardstreamingevents:sequenceofeventsformediaplayeractions-mandatoryplayerevents
1386
+ * @see https://srgssr-ch.atlassian.net/wiki/spaces/INTFORSCHUNG/pages/795904171/standard+streaming+events+sequence+of+events+for+media+player+actions#mandatory-player-events
1242
1387
  */
1243
1388
  heartBeat() {
1244
1389
  this.heartBeatIntervalId = setInterval(() => {
@@ -1529,7 +1674,7 @@ class SRGAnalytics {
1529
1674
  * Sent to ComScore when the playback rate changes.
1530
1675
  *
1531
1676
  * @see https://github.com/SRGSSR/srgletterbox-web/issues/761
1532
- * @see https://jira.srg.beecollaboration.com/browse/ADI-256
1677
+ * @see https://srgssr-ch.atlassian.net/browse/ADI-256
1533
1678
  */
1534
1679
  rateChange() {
1535
1680
  this.notify('change_playback_rate');
@@ -1623,11 +1768,11 @@ class SRGAnalytics {
1623
1768
  * It's expected notifyBufferStart() to be called when the player starts buffering
1624
1769
  * and a call to notifyBufferStop() when content resumes after buffering.
1625
1770
  *
1626
- * @see Item 2: https://jira.srg.beecollaboration.com/browse/PLAY-2628
1771
+ * @see Item 2: https://srgssr-ch.atlassian.net/browse/PLAY-2628
1627
1772
  *
1628
1773
  * After the issue PLAYRTS-321
1629
- * @see Fix: https://jira.srg.beecollaboration.com/browse/PLAYRTS-321?focusedCommentId=201023&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-201023
1630
- * @see Fix: https://jira.srg.beecollaboration.com/browse/PLAYRTS-3065
1774
+ * @see Fix: https://srgssr-ch.atlassian.net/browse/PLAYRTS-321?focusedCommentId=201023&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-201023
1775
+ * @see Fix: https://srgssr-ch.atlassian.net/browse/PLAYRTS-3065
1631
1776
  */
1632
1777
  waiting() {
1633
1778
  if (!this.initialized || this.isWaiting) {
@@ -4228,6 +4373,7 @@ class SrgSsr {
4228
4373
  if (!player.options().trackers.srgAnalytics) {
4229
4374
  const srgAnalytics = new SRGAnalytics(player, {
4230
4375
  debug: player.debug(),
4376
+ environment: player.options().srgOptions.analyticsEnvironment,
4231
4377
  playerVersion: pillarbox.VERSION.pillarbox,
4232
4378
  tagCommanderScriptURL: player.options().srgOptions.tagCommanderScriptURL
4233
4379
  });
@@ -4321,6 +4467,7 @@ pillarbox.options.srgOptions = {
4321
4467
  dataProvider: undefined,
4322
4468
  dataProviderHost: undefined,
4323
4469
  dataProviderUrlHandler: undefined,
4470
+ analyticsEnvironment: undefined,
4324
4471
  tagCommanderScriptURL: undefined
4325
4472
  };
4326
4473