@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.
@@ -3,7 +3,7 @@
3
3
  const videojs = require('video.js');
4
4
  require('videojs-contrib-eme');
5
5
 
6
- const version = "1.35.1";
6
+ const version = "1.36.1";
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.35.1";
4
+ const version = "1.36.1";
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.35.1";
97
+ const version = "1.36.1";
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,26 +4210,25 @@ 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
- const removeTrack = player.textTracks().getTrackById(trackId);
4215
+ const removeTrack = player.remoteTextTracks().getTrackById(trackId);
4212
4216
  if (removeTrack) {
4213
- player.textTracks().removeTrack(removeTrack);
4217
+ player.removeRemoteTextTrack(removeTrack);
4214
4218
  }
4219
+ const textTrack = player.addRemoteTextTrack({
4220
+ id: trackId,
4221
+ kind: 'metadata',
4222
+ label: trackId
4223
+ });
4224
+
4225
+ // Safari
4226
+ textTrack.track.mode = 'hidden';
4215
4227
 
4216
4228
  // See https://github.com/videojs/video.js/issues/8519
4217
- const textTrack = yield new Promise(resolve => {
4218
- setTimeout(() => {
4219
- resolve(new pillarbox.TextTrack({
4220
- id: trackId,
4221
- kind: 'metadata',
4222
- label: trackId,
4223
- tech: player.tech(true)
4224
- }));
4225
- }, 100);
4226
- });
4227
- SrgSsr.addTextTrackCues(textTrack, cues);
4228
- player.textTracks().addTrack(textTrack);
4229
- return textTrack;
4229
+ yield new Promise(resolve => setTimeout(resolve, 100));
4230
+ _this4.addTextTrackCues(textTrack.track, cues);
4231
+ return textTrack.track;
4230
4232
  }).apply(this, arguments);
4231
4233
  }
4232
4234
 
@@ -4236,12 +4238,12 @@ class SrgSsr {
4236
4238
  * @param {Player} player
4237
4239
  */
4238
4240
  static cuechangeEventProxy(player) {
4239
- player.textTracks().on('addtrack', ({
4241
+ player.textTracks().on('addtrack', /** @param {{ track: TextTrack }} */({
4240
4242
  track
4241
4243
  }) => {
4242
4244
  if (!['srgssr-chapters', 'srgssr-intervals'].includes(track.id)) return;
4243
- track.on('cuechange', () => {
4244
- const [cue] = Array.from(track.activeCues);
4245
+ track.addEventListener('cuechange', () => {
4246
+ const [cue] = Array.from(track.activeCues || []);
4245
4247
  const type = track.id.includes('srgssr-chapters') ? 'srgssr/chapter' : 'srgssr/interval';
4246
4248
  player.trigger({
4247
4249
  type,
@@ -4286,7 +4288,7 @@ class SrgSsr {
4286
4288
  static dataProviderError(player, error) {
4287
4289
  if (!error) return;
4288
4290
  const statusText = error.statusText ? error.statusText : error.message;
4289
- SrgSsr.error(player, {
4291
+ this.error(player, {
4290
4292
  code: 0,
4291
4293
  message: player.localize('UNKNOWN'),
4292
4294
  metadata: {
@@ -4343,7 +4345,7 @@ class SrgSsr {
4343
4345
  if (!blockedSegmentsTrack) return;
4344
4346
 
4345
4347
  /** @type {VTTCue} */
4346
- const [blockedCue] = Array.from(blockedSegmentsTrack.activeCues);
4348
+ const [blockedCue] = Array.from(blockedSegmentsTrack.activeCues || []);
4347
4349
  return blockedCue;
4348
4350
  }
4349
4351
 
@@ -4356,7 +4358,7 @@ class SrgSsr {
4356
4358
  * @returns {VTTCue|undefined} The VTT cue of a blocked segment, or undefined
4357
4359
  */
4358
4360
  static getBlockedSegmentByTime(player, currentTime) {
4359
- const blockedSegment = SrgSsr.getBlockedSegment(player);
4361
+ const blockedSegment = this.getBlockedSegment(player);
4360
4362
  if (!blockedSegment) return;
4361
4363
  const isBlocked = currentTime >= blockedSegment.startTime && currentTime < blockedSegment.endTime;
4362
4364
  return isBlocked ? blockedSegment : undefined;
@@ -4440,24 +4442,25 @@ class SrgSsr {
4440
4442
  * @returns {Promise<ComposedSrcMediaData>} - The composed source media data.
4441
4443
  */
4442
4444
  static getSrcMediaObj(player, srcObj) {
4445
+ var _this5 = this;
4443
4446
  return _asyncToGenerator(function* () {
4444
- if (SrgSsr.pillarboxMonitoring(player)) {
4445
- SrgSsr.pillarboxMonitoring(player).sessionStart();
4447
+ if (_this5.pillarboxMonitoring(player)) {
4448
+ _this5.pillarboxMonitoring(player).sessionStart();
4446
4449
  }
4447
4450
  const {
4448
4451
  src: urn
4449
4452
  } = srcObj,
4450
4453
  srcOptions = _objectWithoutProperties(srcObj, _excluded2);
4451
- const mediaComposition = yield SrgSsr.getMediaComposition(urn, SrgSsr.dataProvider(player));
4452
- const mainResources = yield SrgSsr.composeMainResources(mediaComposition);
4453
- let mediaData = SrgSsr.getMediaData(mainResources);
4454
+ const mediaComposition = yield _this5.getMediaComposition(urn, _this5.dataProvider(player));
4455
+ const mainResources = yield _this5.composeMainResources(mediaComposition);
4456
+ let mediaData = _this5.getMediaData(mainResources);
4454
4457
  if (!mediaData) {
4455
4458
  mediaData = {
4456
4459
  blockReason: mediaComposition.getMainChapter().blockReason,
4457
4460
  imageUrl: mediaComposition.getMainChapterImageUrl()
4458
4461
  };
4459
4462
  }
4460
- return SrgSsr.composeSrcMediaData(srcOptions, mediaData);
4463
+ return _this5.composeSrcMediaData(srcOptions, mediaData);
4461
4464
  })();
4462
4465
  }
4463
4466
 
@@ -4530,17 +4533,18 @@ class SrgSsr {
4530
4533
  * @returns {Promise<any>}
4531
4534
  */
4532
4535
  static handleSetSource(player, srcObj, next) {
4536
+ var _this6 = this;
4533
4537
  return _asyncToGenerator(function* () {
4534
4538
  try {
4535
- const srcMediaObj = yield SrgSsr.getSrcMediaObj(player, srcObj);
4536
- SrgSsr.srgAnalytics(player);
4537
- SrgSsr.updateTitleBar(player, srcMediaObj);
4538
- SrgSsr.updatePoster(player, srcMediaObj);
4539
- if (SrgSsr.blockingReason(player, srcMediaObj)) return;
4540
- SrgSsr.addTextTracks(player, srcMediaObj);
4539
+ const srcMediaObj = yield _this6.getSrcMediaObj(player, srcObj);
4540
+ _this6.srgAnalytics(player);
4541
+ _this6.updateTitleBar(player, srcMediaObj);
4542
+ _this6.updatePoster(player, srcMediaObj);
4543
+ if (_this6.blockingReason(player, srcMediaObj)) return;
4544
+ _this6.addTextTracks(player, srcMediaObj);
4541
4545
  return next(null, srcMediaObj);
4542
4546
  } catch (error) {
4543
- if (SrgSsr.dataProviderError(player, error)) return;
4547
+ if (_this6.dataProviderError(player, error)) return;
4544
4548
  return next(error);
4545
4549
  }
4546
4550
  })();
@@ -4627,14 +4631,15 @@ class SrgSsr {
4627
4631
  * @returns {Object}
4628
4632
  */
4629
4633
  static middleware(player) {
4630
- SrgSsr.pillarboxMonitoring(player);
4631
- SrgSsr.cuechangeEventProxy(player);
4634
+ var _this7 = this;
4635
+ this.pillarboxMonitoring(player);
4636
+ this.cuechangeEventProxy(player);
4632
4637
  return {
4633
- currentTime: currentTime => SrgSsr.handleCurrentTime(player, currentTime),
4634
- setCurrentTime: currentTime => SrgSsr.handleSetCurrentTime(player, currentTime),
4638
+ currentTime: currentTime => this.handleCurrentTime(player, currentTime),
4639
+ setCurrentTime: currentTime => this.handleSetCurrentTime(player, currentTime),
4635
4640
  setSource: function () {
4636
4641
  var _ref = _asyncToGenerator(function* (srcObj, next) {
4637
- return SrgSsr.handleSetSource(player, srcObj, next);
4642
+ return _this7.handleSetSource(player, srcObj, next);
4638
4643
  });
4639
4644
  return function setSource(_x8, _x9) {
4640
4645
  return _ref.apply(this, arguments);
@@ -4643,7 +4648,7 @@ class SrgSsr {
4643
4648
  };
4644
4649
  }
4645
4650
  }
4646
- pillarbox.use('srgssr/urn', SrgSsr.middleware);
4651
+ pillarbox.use('srgssr/urn', player => SrgSsr.middleware(player));
4647
4652
 
4648
4653
  // Add Middleware specific options
4649
4654
  pillarbox.options.srgOptions = {