@srgssr/pillarbox-web 1.36.1 → 1.36.3

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.
@@ -90,7 +90,7 @@ function _toPropertyKey(t) {
90
90
  return "symbol" == typeof i ? i : i + "";
91
91
  }
92
92
 
93
- const version = "1.36.0";
93
+ const version = "1.36.2";
94
94
 
95
95
  /** @import VJSPlayer from 'video.js/dist/types/player' */
96
96
  /** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */
@@ -3975,10 +3975,11 @@ class SrgSsr {
3975
3975
  * @param {Array<Segment>} [segments=[]]
3976
3976
  */
3977
3977
  static addBlockedSegments(_x) {
3978
+ var _this = this;
3978
3979
  return _asyncToGenerator(function* (player, segments = []) {
3979
3980
  const trackId = 'srgssr-blocked-segments';
3980
- const blockedSegmentsToAdd = SrgSsr.getBlockedSegments(segments);
3981
- yield SrgSsr.createTextTrack(player, trackId, blockedSegmentsToAdd);
3981
+ const blockedSegmentsToAdd = _this.getBlockedSegments(segments);
3982
+ yield _this.createTextTrack(player, trackId, blockedSegmentsToAdd);
3982
3983
  }).apply(this, arguments);
3983
3984
  }
3984
3985
 
@@ -4039,7 +4040,7 @@ class SrgSsr {
4039
4040
  static addTextTrackCues(textTrack, cues = []) {
4040
4041
  if (!Array.isArray(cues)) return;
4041
4042
  cues.forEach(cue => {
4042
- SrgSsr.addTextTrackCue(textTrack, cue);
4043
+ this.addTextTrackCue(textTrack, cue);
4043
4044
  });
4044
4045
  }
4045
4046
 
@@ -4052,10 +4053,10 @@ class SrgSsr {
4052
4053
  static addTextTracks(player, {
4053
4054
  mediaData
4054
4055
  }) {
4055
- SrgSsr.addRemoteTextTracks(player, mediaData.subtitles);
4056
- SrgSsr.addChapters(player, mediaData.urn, mediaData.chapters);
4057
- SrgSsr.addBlockedSegments(player, mediaData.blockedSegments);
4058
- SrgSsr.addIntervals(player, mediaData.intervals);
4056
+ this.addRemoteTextTracks(player, mediaData.subtitles);
4057
+ this.addChapters(player, mediaData.urn, mediaData.chapters);
4058
+ this.addBlockedSegments(player, mediaData.blockedSegments);
4059
+ this.addIntervals(player, mediaData.intervals);
4059
4060
  }
4060
4061
 
4061
4062
  /**
@@ -4066,10 +4067,11 @@ class SrgSsr {
4066
4067
  * @param {Array.<Chapter>} [chapters=[]]
4067
4068
  */
4068
4069
  static addChapters(_x2, _x3) {
4070
+ var _this2 = this;
4069
4071
  return _asyncToGenerator(function* (player, chapterUrn, chapters = []) {
4070
4072
  const trackId = 'srgssr-chapters';
4071
- const chaptersToAdd = SrgSsr.getChapters(chapterUrn, chapters);
4072
- yield SrgSsr.createTextTrack(player, trackId, chaptersToAdd);
4073
+ const chaptersToAdd = _this2.getChapters(chapterUrn, chapters);
4074
+ yield _this2.createTextTrack(player, trackId, chaptersToAdd);
4073
4075
  }).apply(this, arguments);
4074
4076
  }
4075
4077
 
@@ -4080,10 +4082,11 @@ class SrgSsr {
4080
4082
  * @param {Array.<TimeInterval>} [intervals=[]]
4081
4083
  */
4082
4084
  static addIntervals(_x4) {
4085
+ var _this3 = this;
4083
4086
  return _asyncToGenerator(function* (player, intervals = []) {
4084
4087
  const trackId = 'srgssr-intervals';
4085
- const instervalsToAdd = SrgSsr.getIntervals(intervals);
4086
- yield SrgSsr.createTextTrack(player, trackId, instervalsToAdd);
4088
+ const instervalsToAdd = _this3.getIntervals(intervals);
4089
+ yield _this3.createTextTrack(player, trackId, instervalsToAdd);
4087
4090
  }).apply(this, arguments);
4088
4091
  }
4089
4092
 
@@ -4099,7 +4102,7 @@ class SrgSsr {
4099
4102
  static blockingReason(player, srcMediaObj) {
4100
4103
  if (!srcMediaObj.mediaData.blockReason) return;
4101
4104
  const message = player.localize(srcMediaObj.mediaData.blockReason);
4102
- SrgSsr.error(player, {
4105
+ this.error(player, {
4103
4106
  code: MediaError.MEDIA_ERR_ABORTED,
4104
4107
  message,
4105
4108
  metadata: {
@@ -4153,7 +4156,7 @@ class SrgSsr {
4153
4156
  * @returns {Promise<Array.<MainResourceWithKeySystems>>}
4154
4157
  */
4155
4158
  static composeMainResources(mediaComposition) {
4156
- return SrgSsr.composeAkamaiResources(SrgSsr.composeKeySystemsResources(SrgSsr.filterIncompatibleResources(mediaComposition.getMainResources())));
4159
+ return this.composeAkamaiResources(this.composeKeySystemsResources(this.filterIncompatibleResources(mediaComposition.getMainResources())));
4157
4160
  }
4158
4161
 
4159
4162
  /**
@@ -4203,6 +4206,7 @@ class SrgSsr {
4203
4206
  * @returns {Promise<TextTrack>}
4204
4207
  */
4205
4208
  static createTextTrack(_x5, _x6) {
4209
+ var _this4 = this;
4206
4210
  return _asyncToGenerator(function* (player, trackId, cues = []) {
4207
4211
  const removeTrack = player.remoteTextTracks().getTrackById(trackId);
4208
4212
  if (removeTrack) {
@@ -4214,12 +4218,15 @@ class SrgSsr {
4214
4218
  label: trackId
4215
4219
  });
4216
4220
 
4221
+ // See https://github.com/videojs/video.js/issues/8519
4222
+ yield new Promise(resolve => setTimeout(resolve, 100));
4223
+
4217
4224
  // Safari
4218
4225
  textTrack.track.mode = 'hidden';
4219
4226
 
4220
4227
  // See https://github.com/videojs/video.js/issues/8519
4221
4228
  yield new Promise(resolve => setTimeout(resolve, 100));
4222
- SrgSsr.addTextTrackCues(textTrack.track, cues);
4229
+ _this4.addTextTrackCues(textTrack.track, cues);
4223
4230
  return textTrack.track;
4224
4231
  }).apply(this, arguments);
4225
4232
  }
@@ -4280,7 +4287,7 @@ class SrgSsr {
4280
4287
  static dataProviderError(player, error) {
4281
4288
  if (!error) return;
4282
4289
  const statusText = error.statusText ? error.statusText : error.message;
4283
- SrgSsr.error(player, {
4290
+ this.error(player, {
4284
4291
  code: 0,
4285
4292
  message: player.localize('UNKNOWN'),
4286
4293
  metadata: {
@@ -4350,7 +4357,7 @@ class SrgSsr {
4350
4357
  * @returns {VTTCue|undefined} The VTT cue of a blocked segment, or undefined
4351
4358
  */
4352
4359
  static getBlockedSegmentByTime(player, currentTime) {
4353
- const blockedSegment = SrgSsr.getBlockedSegment(player);
4360
+ const blockedSegment = this.getBlockedSegment(player);
4354
4361
  if (!blockedSegment) return;
4355
4362
  const isBlocked = currentTime >= blockedSegment.startTime && currentTime < blockedSegment.endTime;
4356
4363
  return isBlocked ? blockedSegment : undefined;
@@ -4434,24 +4441,25 @@ class SrgSsr {
4434
4441
  * @returns {Promise<ComposedSrcMediaData>} - The composed source media data.
4435
4442
  */
4436
4443
  static getSrcMediaObj(player, srcObj) {
4444
+ var _this5 = this;
4437
4445
  return _asyncToGenerator(function* () {
4438
- if (SrgSsr.pillarboxMonitoring(player)) {
4439
- SrgSsr.pillarboxMonitoring(player).sessionStart();
4446
+ if (_this5.pillarboxMonitoring(player)) {
4447
+ _this5.pillarboxMonitoring(player).sessionStart();
4440
4448
  }
4441
4449
  const {
4442
4450
  src: urn
4443
4451
  } = srcObj,
4444
4452
  srcOptions = _objectWithoutProperties(srcObj, _excluded2);
4445
- const mediaComposition = yield SrgSsr.getMediaComposition(urn, SrgSsr.dataProvider(player));
4446
- const mainResources = yield SrgSsr.composeMainResources(mediaComposition);
4447
- let mediaData = SrgSsr.getMediaData(mainResources);
4453
+ const mediaComposition = yield _this5.getMediaComposition(urn, _this5.dataProvider(player));
4454
+ const mainResources = yield _this5.composeMainResources(mediaComposition);
4455
+ let mediaData = _this5.getMediaData(mainResources);
4448
4456
  if (!mediaData) {
4449
4457
  mediaData = {
4450
4458
  blockReason: mediaComposition.getMainChapter().blockReason,
4451
4459
  imageUrl: mediaComposition.getMainChapterImageUrl()
4452
4460
  };
4453
4461
  }
4454
- return SrgSsr.composeSrcMediaData(srcOptions, mediaData);
4462
+ return _this5.composeSrcMediaData(srcOptions, mediaData);
4455
4463
  })();
4456
4464
  }
4457
4465
 
@@ -4524,17 +4532,18 @@ class SrgSsr {
4524
4532
  * @returns {Promise<any>}
4525
4533
  */
4526
4534
  static handleSetSource(player, srcObj, next) {
4535
+ var _this6 = this;
4527
4536
  return _asyncToGenerator(function* () {
4528
4537
  try {
4529
- const srcMediaObj = yield SrgSsr.getSrcMediaObj(player, srcObj);
4530
- SrgSsr.srgAnalytics(player);
4531
- SrgSsr.updateTitleBar(player, srcMediaObj);
4532
- SrgSsr.updatePoster(player, srcMediaObj);
4533
- if (SrgSsr.blockingReason(player, srcMediaObj)) return;
4534
- SrgSsr.addTextTracks(player, srcMediaObj);
4538
+ const srcMediaObj = yield _this6.getSrcMediaObj(player, srcObj);
4539
+ _this6.srgAnalytics(player);
4540
+ _this6.updateTitleBar(player, srcMediaObj);
4541
+ _this6.updatePoster(player, srcMediaObj);
4542
+ if (_this6.blockingReason(player, srcMediaObj)) return;
4543
+ _this6.addTextTracks(player, srcMediaObj);
4535
4544
  return next(null, srcMediaObj);
4536
4545
  } catch (error) {
4537
- if (SrgSsr.dataProviderError(player, error)) return;
4546
+ if (_this6.dataProviderError(player, error)) return;
4538
4547
  return next(error);
4539
4548
  }
4540
4549
  })();
@@ -4621,14 +4630,15 @@ class SrgSsr {
4621
4630
  * @returns {Object}
4622
4631
  */
4623
4632
  static middleware(player) {
4624
- SrgSsr.pillarboxMonitoring(player);
4625
- SrgSsr.cuechangeEventProxy(player);
4633
+ var _this7 = this;
4634
+ this.pillarboxMonitoring(player);
4635
+ this.cuechangeEventProxy(player);
4626
4636
  return {
4627
- currentTime: currentTime => SrgSsr.handleCurrentTime(player, currentTime),
4628
- setCurrentTime: currentTime => SrgSsr.handleSetCurrentTime(player, currentTime),
4637
+ currentTime: currentTime => this.handleCurrentTime(player, currentTime),
4638
+ setCurrentTime: currentTime => this.handleSetCurrentTime(player, currentTime),
4629
4639
  setSource: function () {
4630
4640
  var _ref = _asyncToGenerator(function* (srcObj, next) {
4631
- return SrgSsr.handleSetSource(player, srcObj, next);
4641
+ return _this7.handleSetSource(player, srcObj, next);
4632
4642
  });
4633
4643
  return function setSource(_x8, _x9) {
4634
4644
  return _ref.apply(this, arguments);
@@ -4637,7 +4647,7 @@ class SrgSsr {
4637
4647
  };
4638
4648
  }
4639
4649
  }
4640
- pillarbox.use('srgssr/urn', SrgSsr.middleware);
4650
+ pillarbox.use('srgssr/urn', player => SrgSsr.middleware(player));
4641
4651
 
4642
4652
  // Add Middleware specific options
4643
4653
  pillarbox.options.srgOptions = {