@srgssr/pillarbox-web 1.36.0 → 1.36.2

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.1";
96
+ const version$8 = "1.36.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
 
@@ -75003,10 +75003,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75003
75003
  * @param {Array<Segment>} [segments=[]]
75004
75004
  */
75005
75005
  static addBlockedSegments(_x) {
75006
+ var _this = this;
75006
75007
  return _asyncToGenerator(function* (player, segments = []) {
75007
75008
  const trackId = 'srgssr-blocked-segments';
75008
- const blockedSegmentsToAdd = SrgSsr.getBlockedSegments(segments);
75009
- yield SrgSsr.createTextTrack(player, trackId, blockedSegmentsToAdd);
75009
+ const blockedSegmentsToAdd = _this.getBlockedSegments(segments);
75010
+ yield _this.createTextTrack(player, trackId, blockedSegmentsToAdd);
75010
75011
  }).apply(this, arguments);
75011
75012
  }
75012
75013
 
@@ -75067,7 +75068,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75067
75068
  static addTextTrackCues(textTrack, cues = []) {
75068
75069
  if (!Array.isArray(cues)) return;
75069
75070
  cues.forEach(cue => {
75070
- SrgSsr.addTextTrackCue(textTrack, cue);
75071
+ this.addTextTrackCue(textTrack, cue);
75071
75072
  });
75072
75073
  }
75073
75074
 
@@ -75080,10 +75081,10 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75080
75081
  static addTextTracks(player, {
75081
75082
  mediaData
75082
75083
  }) {
75083
- SrgSsr.addRemoteTextTracks(player, mediaData.subtitles);
75084
- SrgSsr.addChapters(player, mediaData.urn, mediaData.chapters);
75085
- SrgSsr.addBlockedSegments(player, mediaData.blockedSegments);
75086
- SrgSsr.addIntervals(player, mediaData.intervals);
75084
+ this.addRemoteTextTracks(player, mediaData.subtitles);
75085
+ this.addChapters(player, mediaData.urn, mediaData.chapters);
75086
+ this.addBlockedSegments(player, mediaData.blockedSegments);
75087
+ this.addIntervals(player, mediaData.intervals);
75087
75088
  }
75088
75089
 
75089
75090
  /**
@@ -75094,10 +75095,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75094
75095
  * @param {Array.<Chapter>} [chapters=[]]
75095
75096
  */
75096
75097
  static addChapters(_x2, _x3) {
75098
+ var _this2 = this;
75097
75099
  return _asyncToGenerator(function* (player, chapterUrn, chapters = []) {
75098
75100
  const trackId = 'srgssr-chapters';
75099
- const chaptersToAdd = SrgSsr.getChapters(chapterUrn, chapters);
75100
- yield SrgSsr.createTextTrack(player, trackId, chaptersToAdd);
75101
+ const chaptersToAdd = _this2.getChapters(chapterUrn, chapters);
75102
+ yield _this2.createTextTrack(player, trackId, chaptersToAdd);
75101
75103
  }).apply(this, arguments);
75102
75104
  }
75103
75105
 
@@ -75108,10 +75110,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75108
75110
  * @param {Array.<TimeInterval>} [intervals=[]]
75109
75111
  */
75110
75112
  static addIntervals(_x4) {
75113
+ var _this3 = this;
75111
75114
  return _asyncToGenerator(function* (player, intervals = []) {
75112
75115
  const trackId = 'srgssr-intervals';
75113
- const instervalsToAdd = SrgSsr.getIntervals(intervals);
75114
- yield SrgSsr.createTextTrack(player, trackId, instervalsToAdd);
75116
+ const instervalsToAdd = _this3.getIntervals(intervals);
75117
+ yield _this3.createTextTrack(player, trackId, instervalsToAdd);
75115
75118
  }).apply(this, arguments);
75116
75119
  }
75117
75120
 
@@ -75127,7 +75130,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75127
75130
  static blockingReason(player, srcMediaObj) {
75128
75131
  if (!srcMediaObj.mediaData.blockReason) return;
75129
75132
  const message = player.localize(srcMediaObj.mediaData.blockReason);
75130
- SrgSsr.error(player, {
75133
+ this.error(player, {
75131
75134
  code: MediaError.MEDIA_ERR_ABORTED,
75132
75135
  message,
75133
75136
  metadata: {
@@ -75181,7 +75184,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75181
75184
  * @returns {Promise<Array.<MainResourceWithKeySystems>>}
75182
75185
  */
75183
75186
  static composeMainResources(mediaComposition) {
75184
- return SrgSsr.composeAkamaiResources(SrgSsr.composeKeySystemsResources(SrgSsr.filterIncompatibleResources(mediaComposition.getMainResources())));
75187
+ return this.composeAkamaiResources(this.composeKeySystemsResources(this.filterIncompatibleResources(mediaComposition.getMainResources())));
75185
75188
  }
75186
75189
 
75187
75190
  /**
@@ -75231,26 +75234,25 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75231
75234
  * @returns {Promise<TextTrack>}
75232
75235
  */
75233
75236
  static createTextTrack(_x5, _x6) {
75237
+ var _this4 = this;
75234
75238
  return _asyncToGenerator(function* (player, trackId, cues = []) {
75235
- const removeTrack = player.textTracks().getTrackById(trackId);
75239
+ const removeTrack = player.remoteTextTracks().getTrackById(trackId);
75236
75240
  if (removeTrack) {
75237
- player.textTracks().removeTrack(removeTrack);
75241
+ player.removeRemoteTextTrack(removeTrack);
75238
75242
  }
75243
+ const textTrack = player.addRemoteTextTrack({
75244
+ id: trackId,
75245
+ kind: 'metadata',
75246
+ label: trackId
75247
+ });
75248
+
75249
+ // Safari
75250
+ textTrack.track.mode = 'hidden';
75239
75251
 
75240
75252
  // See https://github.com/videojs/video.js/issues/8519
75241
- const textTrack = yield new Promise(resolve => {
75242
- setTimeout(() => {
75243
- resolve(new pillarbox.TextTrack({
75244
- id: trackId,
75245
- kind: 'metadata',
75246
- label: trackId,
75247
- tech: player.tech(true)
75248
- }));
75249
- }, 100);
75250
- });
75251
- SrgSsr.addTextTrackCues(textTrack, cues);
75252
- player.textTracks().addTrack(textTrack);
75253
- return textTrack;
75253
+ yield new Promise(resolve => setTimeout(resolve, 100));
75254
+ _this4.addTextTrackCues(textTrack.track, cues);
75255
+ return textTrack.track;
75254
75256
  }).apply(this, arguments);
75255
75257
  }
75256
75258
 
@@ -75260,12 +75262,12 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75260
75262
  * @param {Player} player
75261
75263
  */
75262
75264
  static cuechangeEventProxy(player) {
75263
- player.textTracks().on('addtrack', ({
75265
+ player.textTracks().on('addtrack', /** @param {{ track: TextTrack }} */({
75264
75266
  track
75265
75267
  }) => {
75266
75268
  if (!['srgssr-chapters', 'srgssr-intervals'].includes(track.id)) return;
75267
- track.on('cuechange', () => {
75268
- const [cue] = Array.from(track.activeCues);
75269
+ track.addEventListener('cuechange', () => {
75270
+ const [cue] = Array.from(track.activeCues || []);
75269
75271
  const type = track.id.includes('srgssr-chapters') ? 'srgssr/chapter' : 'srgssr/interval';
75270
75272
  player.trigger({
75271
75273
  type,
@@ -75310,7 +75312,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75310
75312
  static dataProviderError(player, error) {
75311
75313
  if (!error) return;
75312
75314
  const statusText = error.statusText ? error.statusText : error.message;
75313
- SrgSsr.error(player, {
75315
+ this.error(player, {
75314
75316
  code: 0,
75315
75317
  message: player.localize('UNKNOWN'),
75316
75318
  metadata: {
@@ -75367,7 +75369,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75367
75369
  if (!blockedSegmentsTrack) return;
75368
75370
 
75369
75371
  /** @type {VTTCue} */
75370
- const [blockedCue] = Array.from(blockedSegmentsTrack.activeCues);
75372
+ const [blockedCue] = Array.from(blockedSegmentsTrack.activeCues || []);
75371
75373
  return blockedCue;
75372
75374
  }
75373
75375
 
@@ -75380,7 +75382,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75380
75382
  * @returns {VTTCue|undefined} The VTT cue of a blocked segment, or undefined
75381
75383
  */
75382
75384
  static getBlockedSegmentByTime(player, currentTime) {
75383
- const blockedSegment = SrgSsr.getBlockedSegment(player);
75385
+ const blockedSegment = this.getBlockedSegment(player);
75384
75386
  if (!blockedSegment) return;
75385
75387
  const isBlocked = currentTime >= blockedSegment.startTime && currentTime < blockedSegment.endTime;
75386
75388
  return isBlocked ? blockedSegment : undefined;
@@ -75464,24 +75466,25 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75464
75466
  * @returns {Promise<ComposedSrcMediaData>} - The composed source media data.
75465
75467
  */
75466
75468
  static getSrcMediaObj(player, srcObj) {
75469
+ var _this5 = this;
75467
75470
  return _asyncToGenerator(function* () {
75468
- if (SrgSsr.pillarboxMonitoring(player)) {
75469
- SrgSsr.pillarboxMonitoring(player).sessionStart();
75471
+ if (_this5.pillarboxMonitoring(player)) {
75472
+ _this5.pillarboxMonitoring(player).sessionStart();
75470
75473
  }
75471
75474
  const {
75472
75475
  src: urn
75473
75476
  } = srcObj,
75474
75477
  srcOptions = _objectWithoutProperties(srcObj, _excluded2);
75475
- const mediaComposition = yield SrgSsr.getMediaComposition(urn, SrgSsr.dataProvider(player));
75476
- const mainResources = yield SrgSsr.composeMainResources(mediaComposition);
75477
- let mediaData = SrgSsr.getMediaData(mainResources);
75478
+ const mediaComposition = yield _this5.getMediaComposition(urn, _this5.dataProvider(player));
75479
+ const mainResources = yield _this5.composeMainResources(mediaComposition);
75480
+ let mediaData = _this5.getMediaData(mainResources);
75478
75481
  if (!mediaData) {
75479
75482
  mediaData = {
75480
75483
  blockReason: mediaComposition.getMainChapter().blockReason,
75481
75484
  imageUrl: mediaComposition.getMainChapterImageUrl()
75482
75485
  };
75483
75486
  }
75484
- return SrgSsr.composeSrcMediaData(srcOptions, mediaData);
75487
+ return _this5.composeSrcMediaData(srcOptions, mediaData);
75485
75488
  })();
75486
75489
  }
75487
75490
 
@@ -75554,17 +75557,18 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75554
75557
  * @returns {Promise<any>}
75555
75558
  */
75556
75559
  static handleSetSource(player, srcObj, next) {
75560
+ var _this6 = this;
75557
75561
  return _asyncToGenerator(function* () {
75558
75562
  try {
75559
- const srcMediaObj = yield SrgSsr.getSrcMediaObj(player, srcObj);
75560
- SrgSsr.srgAnalytics(player);
75561
- SrgSsr.updateTitleBar(player, srcMediaObj);
75562
- SrgSsr.updatePoster(player, srcMediaObj);
75563
- if (SrgSsr.blockingReason(player, srcMediaObj)) return;
75564
- SrgSsr.addTextTracks(player, srcMediaObj);
75563
+ const srcMediaObj = yield _this6.getSrcMediaObj(player, srcObj);
75564
+ _this6.srgAnalytics(player);
75565
+ _this6.updateTitleBar(player, srcMediaObj);
75566
+ _this6.updatePoster(player, srcMediaObj);
75567
+ if (_this6.blockingReason(player, srcMediaObj)) return;
75568
+ _this6.addTextTracks(player, srcMediaObj);
75565
75569
  return next(null, srcMediaObj);
75566
75570
  } catch (error) {
75567
- if (SrgSsr.dataProviderError(player, error)) return;
75571
+ if (_this6.dataProviderError(player, error)) return;
75568
75572
  return next(error);
75569
75573
  }
75570
75574
  })();
@@ -75651,14 +75655,15 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75651
75655
  * @returns {Object}
75652
75656
  */
75653
75657
  static middleware(player) {
75654
- SrgSsr.pillarboxMonitoring(player);
75655
- SrgSsr.cuechangeEventProxy(player);
75658
+ var _this7 = this;
75659
+ this.pillarboxMonitoring(player);
75660
+ this.cuechangeEventProxy(player);
75656
75661
  return {
75657
- currentTime: currentTime => SrgSsr.handleCurrentTime(player, currentTime),
75658
- setCurrentTime: currentTime => SrgSsr.handleSetCurrentTime(player, currentTime),
75662
+ currentTime: currentTime => this.handleCurrentTime(player, currentTime),
75663
+ setCurrentTime: currentTime => this.handleSetCurrentTime(player, currentTime),
75659
75664
  setSource: function () {
75660
75665
  var _ref = _asyncToGenerator(function* (srcObj, next) {
75661
- return SrgSsr.handleSetSource(player, srcObj, next);
75666
+ return _this7.handleSetSource(player, srcObj, next);
75662
75667
  });
75663
75668
  return function setSource(_x8, _x9) {
75664
75669
  return _ref.apply(this, arguments);
@@ -75667,7 +75672,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75667
75672
  };
75668
75673
  }
75669
75674
  }
75670
- pillarbox.use('srgssr/urn', SrgSsr.middleware);
75675
+ pillarbox.use('srgssr/urn', player => SrgSsr.middleware(player));
75671
75676
 
75672
75677
  // Add Middleware specific options
75673
75678
  pillarbox.options.srgOptions = {