@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.
@@ -3,7 +3,7 @@
3
3
  const videojs = require('video.js');
4
4
  require('videojs-contrib-eme');
5
5
 
6
- const version = "1.36.0";
6
+ const version = "1.36.2";
7
7
 
8
8
  /** @import VJSPlayer from 'video.js/dist/types/player' */
9
9
  /** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */
@@ -1,7 +1,7 @@
1
1
  import videojs from 'video.js';
2
2
  import 'videojs-contrib-eme';
3
3
 
4
- const version = "1.36.0";
4
+ const version = "1.36.2";
5
5
 
6
6
  /** @import VJSPlayer from 'video.js/dist/types/player' */
7
7
  /** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */
@@ -94,7 +94,7 @@ function _toPropertyKey(t) {
94
94
  return "symbol" == typeof i ? i : i + "";
95
95
  }
96
96
 
97
- const version = "1.36.0";
97
+ const version = "1.36.2";
98
98
 
99
99
  /** @import VJSPlayer from 'video.js/dist/types/player' */
100
100
  /** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */
@@ -3979,10 +3979,11 @@ class SrgSsr {
3979
3979
  * @param {Array<Segment>} [segments=[]]
3980
3980
  */
3981
3981
  static addBlockedSegments(_x) {
3982
+ var _this = this;
3982
3983
  return _asyncToGenerator(function* (player, segments = []) {
3983
3984
  const trackId = 'srgssr-blocked-segments';
3984
- const blockedSegmentsToAdd = SrgSsr.getBlockedSegments(segments);
3985
- yield SrgSsr.createTextTrack(player, trackId, blockedSegmentsToAdd);
3985
+ const blockedSegmentsToAdd = _this.getBlockedSegments(segments);
3986
+ yield _this.createTextTrack(player, trackId, blockedSegmentsToAdd);
3986
3987
  }).apply(this, arguments);
3987
3988
  }
3988
3989
 
@@ -4043,7 +4044,7 @@ class SrgSsr {
4043
4044
  static addTextTrackCues(textTrack, cues = []) {
4044
4045
  if (!Array.isArray(cues)) return;
4045
4046
  cues.forEach(cue => {
4046
- SrgSsr.addTextTrackCue(textTrack, cue);
4047
+ this.addTextTrackCue(textTrack, cue);
4047
4048
  });
4048
4049
  }
4049
4050
 
@@ -4056,10 +4057,10 @@ class SrgSsr {
4056
4057
  static addTextTracks(player, {
4057
4058
  mediaData
4058
4059
  }) {
4059
- SrgSsr.addRemoteTextTracks(player, mediaData.subtitles);
4060
- SrgSsr.addChapters(player, mediaData.urn, mediaData.chapters);
4061
- SrgSsr.addBlockedSegments(player, mediaData.blockedSegments);
4062
- SrgSsr.addIntervals(player, mediaData.intervals);
4060
+ this.addRemoteTextTracks(player, mediaData.subtitles);
4061
+ this.addChapters(player, mediaData.urn, mediaData.chapters);
4062
+ this.addBlockedSegments(player, mediaData.blockedSegments);
4063
+ this.addIntervals(player, mediaData.intervals);
4063
4064
  }
4064
4065
 
4065
4066
  /**
@@ -4070,10 +4071,11 @@ class SrgSsr {
4070
4071
  * @param {Array.<Chapter>} [chapters=[]]
4071
4072
  */
4072
4073
  static addChapters(_x2, _x3) {
4074
+ var _this2 = this;
4073
4075
  return _asyncToGenerator(function* (player, chapterUrn, chapters = []) {
4074
4076
  const trackId = 'srgssr-chapters';
4075
- const chaptersToAdd = SrgSsr.getChapters(chapterUrn, chapters);
4076
- yield SrgSsr.createTextTrack(player, trackId, chaptersToAdd);
4077
+ const chaptersToAdd = _this2.getChapters(chapterUrn, chapters);
4078
+ yield _this2.createTextTrack(player, trackId, chaptersToAdd);
4077
4079
  }).apply(this, arguments);
4078
4080
  }
4079
4081
 
@@ -4084,10 +4086,11 @@ class SrgSsr {
4084
4086
  * @param {Array.<TimeInterval>} [intervals=[]]
4085
4087
  */
4086
4088
  static addIntervals(_x4) {
4089
+ var _this3 = this;
4087
4090
  return _asyncToGenerator(function* (player, intervals = []) {
4088
4091
  const trackId = 'srgssr-intervals';
4089
- const instervalsToAdd = SrgSsr.getIntervals(intervals);
4090
- yield SrgSsr.createTextTrack(player, trackId, instervalsToAdd);
4092
+ const instervalsToAdd = _this3.getIntervals(intervals);
4093
+ yield _this3.createTextTrack(player, trackId, instervalsToAdd);
4091
4094
  }).apply(this, arguments);
4092
4095
  }
4093
4096
 
@@ -4103,7 +4106,7 @@ class SrgSsr {
4103
4106
  static blockingReason(player, srcMediaObj) {
4104
4107
  if (!srcMediaObj.mediaData.blockReason) return;
4105
4108
  const message = player.localize(srcMediaObj.mediaData.blockReason);
4106
- SrgSsr.error(player, {
4109
+ this.error(player, {
4107
4110
  code: MediaError.MEDIA_ERR_ABORTED,
4108
4111
  message,
4109
4112
  metadata: {
@@ -4157,7 +4160,7 @@ class SrgSsr {
4157
4160
  * @returns {Promise<Array.<MainResourceWithKeySystems>>}
4158
4161
  */
4159
4162
  static composeMainResources(mediaComposition) {
4160
- return SrgSsr.composeAkamaiResources(SrgSsr.composeKeySystemsResources(SrgSsr.filterIncompatibleResources(mediaComposition.getMainResources())));
4163
+ return this.composeAkamaiResources(this.composeKeySystemsResources(this.filterIncompatibleResources(mediaComposition.getMainResources())));
4161
4164
  }
4162
4165
 
4163
4166
  /**
@@ -4207,6 +4210,7 @@ class SrgSsr {
4207
4210
  * @returns {Promise<TextTrack>}
4208
4211
  */
4209
4212
  static createTextTrack(_x5, _x6) {
4213
+ var _this4 = this;
4210
4214
  return _asyncToGenerator(function* (player, trackId, cues = []) {
4211
4215
  const removeTrack = player.remoteTextTracks().getTrackById(trackId);
4212
4216
  if (removeTrack) {
@@ -4218,12 +4222,15 @@ class SrgSsr {
4218
4222
  label: trackId
4219
4223
  });
4220
4224
 
4225
+ // See https://github.com/videojs/video.js/issues/8519
4226
+ yield new Promise(resolve => setTimeout(resolve, 100));
4227
+
4221
4228
  // Safari
4222
4229
  textTrack.track.mode = 'hidden';
4223
4230
 
4224
4231
  // See https://github.com/videojs/video.js/issues/8519
4225
4232
  yield new Promise(resolve => setTimeout(resolve, 100));
4226
- SrgSsr.addTextTrackCues(textTrack.track, cues);
4233
+ _this4.addTextTrackCues(textTrack.track, cues);
4227
4234
  return textTrack.track;
4228
4235
  }).apply(this, arguments);
4229
4236
  }
@@ -4284,7 +4291,7 @@ class SrgSsr {
4284
4291
  static dataProviderError(player, error) {
4285
4292
  if (!error) return;
4286
4293
  const statusText = error.statusText ? error.statusText : error.message;
4287
- SrgSsr.error(player, {
4294
+ this.error(player, {
4288
4295
  code: 0,
4289
4296
  message: player.localize('UNKNOWN'),
4290
4297
  metadata: {
@@ -4354,7 +4361,7 @@ class SrgSsr {
4354
4361
  * @returns {VTTCue|undefined} The VTT cue of a blocked segment, or undefined
4355
4362
  */
4356
4363
  static getBlockedSegmentByTime(player, currentTime) {
4357
- const blockedSegment = SrgSsr.getBlockedSegment(player);
4364
+ const blockedSegment = this.getBlockedSegment(player);
4358
4365
  if (!blockedSegment) return;
4359
4366
  const isBlocked = currentTime >= blockedSegment.startTime && currentTime < blockedSegment.endTime;
4360
4367
  return isBlocked ? blockedSegment : undefined;
@@ -4438,24 +4445,25 @@ class SrgSsr {
4438
4445
  * @returns {Promise<ComposedSrcMediaData>} - The composed source media data.
4439
4446
  */
4440
4447
  static getSrcMediaObj(player, srcObj) {
4448
+ var _this5 = this;
4441
4449
  return _asyncToGenerator(function* () {
4442
- if (SrgSsr.pillarboxMonitoring(player)) {
4443
- SrgSsr.pillarboxMonitoring(player).sessionStart();
4450
+ if (_this5.pillarboxMonitoring(player)) {
4451
+ _this5.pillarboxMonitoring(player).sessionStart();
4444
4452
  }
4445
4453
  const {
4446
4454
  src: urn
4447
4455
  } = srcObj,
4448
4456
  srcOptions = _objectWithoutProperties(srcObj, _excluded2);
4449
- const mediaComposition = yield SrgSsr.getMediaComposition(urn, SrgSsr.dataProvider(player));
4450
- const mainResources = yield SrgSsr.composeMainResources(mediaComposition);
4451
- let mediaData = SrgSsr.getMediaData(mainResources);
4457
+ const mediaComposition = yield _this5.getMediaComposition(urn, _this5.dataProvider(player));
4458
+ const mainResources = yield _this5.composeMainResources(mediaComposition);
4459
+ let mediaData = _this5.getMediaData(mainResources);
4452
4460
  if (!mediaData) {
4453
4461
  mediaData = {
4454
4462
  blockReason: mediaComposition.getMainChapter().blockReason,
4455
4463
  imageUrl: mediaComposition.getMainChapterImageUrl()
4456
4464
  };
4457
4465
  }
4458
- return SrgSsr.composeSrcMediaData(srcOptions, mediaData);
4466
+ return _this5.composeSrcMediaData(srcOptions, mediaData);
4459
4467
  })();
4460
4468
  }
4461
4469
 
@@ -4528,17 +4536,18 @@ class SrgSsr {
4528
4536
  * @returns {Promise<any>}
4529
4537
  */
4530
4538
  static handleSetSource(player, srcObj, next) {
4539
+ var _this6 = this;
4531
4540
  return _asyncToGenerator(function* () {
4532
4541
  try {
4533
- const srcMediaObj = yield SrgSsr.getSrcMediaObj(player, srcObj);
4534
- SrgSsr.srgAnalytics(player);
4535
- SrgSsr.updateTitleBar(player, srcMediaObj);
4536
- SrgSsr.updatePoster(player, srcMediaObj);
4537
- if (SrgSsr.blockingReason(player, srcMediaObj)) return;
4538
- SrgSsr.addTextTracks(player, srcMediaObj);
4542
+ const srcMediaObj = yield _this6.getSrcMediaObj(player, srcObj);
4543
+ _this6.srgAnalytics(player);
4544
+ _this6.updateTitleBar(player, srcMediaObj);
4545
+ _this6.updatePoster(player, srcMediaObj);
4546
+ if (_this6.blockingReason(player, srcMediaObj)) return;
4547
+ _this6.addTextTracks(player, srcMediaObj);
4539
4548
  return next(null, srcMediaObj);
4540
4549
  } catch (error) {
4541
- if (SrgSsr.dataProviderError(player, error)) return;
4550
+ if (_this6.dataProviderError(player, error)) return;
4542
4551
  return next(error);
4543
4552
  }
4544
4553
  })();
@@ -4625,14 +4634,15 @@ class SrgSsr {
4625
4634
  * @returns {Object}
4626
4635
  */
4627
4636
  static middleware(player) {
4628
- SrgSsr.pillarboxMonitoring(player);
4629
- SrgSsr.cuechangeEventProxy(player);
4637
+ var _this7 = this;
4638
+ this.pillarboxMonitoring(player);
4639
+ this.cuechangeEventProxy(player);
4630
4640
  return {
4631
- currentTime: currentTime => SrgSsr.handleCurrentTime(player, currentTime),
4632
- setCurrentTime: currentTime => SrgSsr.handleSetCurrentTime(player, currentTime),
4641
+ currentTime: currentTime => this.handleCurrentTime(player, currentTime),
4642
+ setCurrentTime: currentTime => this.handleSetCurrentTime(player, currentTime),
4633
4643
  setSource: function () {
4634
4644
  var _ref = _asyncToGenerator(function* (srcObj, next) {
4635
- return SrgSsr.handleSetSource(player, srcObj, next);
4645
+ return _this7.handleSetSource(player, srcObj, next);
4636
4646
  });
4637
4647
  return function setSource(_x8, _x9) {
4638
4648
  return _ref.apply(this, arguments);
@@ -4641,7 +4651,7 @@ class SrgSsr {
4641
4651
  };
4642
4652
  }
4643
4653
  }
4644
- pillarbox.use('srgssr/urn', SrgSsr.middleware);
4654
+ pillarbox.use('srgssr/urn', player => SrgSsr.middleware(player));
4645
4655
 
4646
4656
  // Add Middleware specific options
4647
4657
  pillarbox.options.srgOptions = {