@srgssr/pillarbox-web 1.29.0 → 1.30.0

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.28.0";
96
+ const version$8 = "1.29.0";
97
97
 
98
98
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
99
99
 
@@ -74491,13 +74491,8 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74491
74491
  static addBlockedSegments(_x) {
74492
74492
  return _asyncToGenerator(function* (player, segments = []) {
74493
74493
  const trackId = 'srgssr-blocked-segments';
74494
- const segmentTrack = yield SrgSsr.createTextTrack(player, trackId);
74495
- if (!Array.isArray(segments) || !segments.length) return;
74496
- const blockedSegments = segments.filter(segment => segment.blockReason);
74497
- if (!blockedSegments.length) return;
74498
- blockedSegments.forEach(segment => {
74499
- SrgSsr.addTextTrackCue(segmentTrack, segment);
74500
- });
74494
+ const blockedSegmentsToAdd = SrgSsr.getBlockedSegments(segments);
74495
+ yield SrgSsr.createTextTrack(player, trackId, blockedSegmentsToAdd);
74501
74496
  }).apply(this, arguments);
74502
74497
  }
74503
74498
 
@@ -74540,6 +74535,23 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74540
74535
  textTrack.addCue(new VTTCue(startTime, endTime, JSON.stringify(data)));
74541
74536
  }
74542
74537
 
74538
+ /**
74539
+ * Add a new cues to a text track with the given array.
74540
+ *
74541
+ * @param {TextTrack} textTrack
74542
+ * @param {Array.<
74543
+ * Segment |
74544
+ * Chapter |
74545
+ * TimeInterval>
74546
+ * } cues SRG SSR's cues-like representation
74547
+ */
74548
+ static addTextTrackCues(textTrack, cues = []) {
74549
+ if (!Array.isArray(cues)) return;
74550
+ cues.forEach(cue => {
74551
+ SrgSsr.addTextTrackCue(textTrack, cue);
74552
+ });
74553
+ }
74554
+
74543
74555
  /**
74544
74556
  * Add multiple text tracks to the player.
74545
74557
  *
@@ -74565,12 +74577,8 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74565
74577
  static addChapters(_x2, _x3) {
74566
74578
  return _asyncToGenerator(function* (player, chapterUrn, chapters = []) {
74567
74579
  const trackId = 'srgssr-chapters';
74568
- const chapterTrack = yield SrgSsr.createTextTrack(player, trackId);
74569
- if (!Array.isArray(chapters) || !chapters.length) return;
74570
- chapters.forEach(chapter => {
74571
- if (chapterUrn !== chapter.fullLengthUrn) return;
74572
- SrgSsr.addTextTrackCue(chapterTrack, chapter);
74573
- });
74580
+ const chaptersToAdd = SrgSsr.getChapters(chapterUrn, chapters);
74581
+ yield SrgSsr.createTextTrack(player, trackId, chaptersToAdd);
74574
74582
  }).apply(this, arguments);
74575
74583
  }
74576
74584
 
@@ -74583,11 +74591,8 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74583
74591
  static addIntervals(_x4) {
74584
74592
  return _asyncToGenerator(function* (player, intervals = []) {
74585
74593
  const trackId = 'srgssr-intervals';
74586
- const intervalTrack = yield SrgSsr.createTextTrack(player, trackId);
74587
- if (!Array.isArray(intervals) || !intervals.length) return;
74588
- intervals.forEach(interval => {
74589
- SrgSsr.addTextTrackCue(intervalTrack, interval);
74590
- });
74594
+ const instervalsToAdd = SrgSsr.getIntervals(intervals);
74595
+ yield SrgSsr.createTextTrack(player, trackId, instervalsToAdd);
74591
74596
  }).apply(this, arguments);
74592
74597
  }
74593
74598
 
@@ -74698,11 +74703,16 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74698
74703
  *
74699
74704
  * @param {Player} player
74700
74705
  * @param {String} trackId Text track unique ID
74706
+ * @param {Array.<
74707
+ * Segment |
74708
+ * Chapter |
74709
+ * TimeInterval>
74710
+ * } cues SRG SSR's cues-like representation
74701
74711
  *
74702
74712
  * @returns {Promise<TextTrack>}
74703
74713
  */
74704
- static createTextTrack(player, trackId) {
74705
- return _asyncToGenerator(function* () {
74714
+ static createTextTrack(_x5, _x6) {
74715
+ return _asyncToGenerator(function* (player, trackId, cues = []) {
74706
74716
  const removeTrack = player.textTracks().getTrackById(trackId);
74707
74717
  if (removeTrack) {
74708
74718
  player.textTracks().removeTrack(removeTrack);
@@ -74719,9 +74729,10 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74719
74729
  }));
74720
74730
  }, 100);
74721
74731
  });
74732
+ SrgSsr.addTextTrackCues(textTrack, cues);
74722
74733
  player.textTracks().addTrack(textTrack);
74723
74734
  return textTrack;
74724
- })();
74735
+ }).apply(this, arguments);
74725
74736
  }
74726
74737
 
74727
74738
  /**
@@ -74856,6 +74867,44 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74856
74867
  return isBlocked ? blockedSegment : undefined;
74857
74868
  }
74858
74869
 
74870
+ /**
74871
+ * Get blocked segments.
74872
+ *
74873
+ * @param {Player} player
74874
+ * @param {Array<Segment>} [segments=[]]
74875
+ *
74876
+ * @returns {Array<Segment>}
74877
+ */
74878
+ static getBlockedSegments(segments = []) {
74879
+ if (!Array.isArray(segments) || !segments.length) return [];
74880
+ return segments.filter(segment => segment.blockReason);
74881
+ }
74882
+
74883
+ /**
74884
+ * Get chapters related to the main chapter.
74885
+ *
74886
+ * @param {string} chapterUrn The URN of the main chapter.
74887
+ * @param {Array.<Chapter>} [chapters=[]]
74888
+ *
74889
+ * @returns {Array.<Chapter>}
74890
+ */
74891
+ static getChapters(chapterUrn, chapters = []) {
74892
+ if (!Array.isArray(chapters) || !chapters.length) return [];
74893
+ return chapters.filter(chapter => chapterUrn === chapter.fullLengthUrn);
74894
+ }
74895
+
74896
+ /**
74897
+ * Get intervals.
74898
+ *
74899
+ * @param {Array<TimeInterval>} [segments=[]]
74900
+ *
74901
+ * @returns {Array<TimeInterval>}
74902
+ */
74903
+ static getIntervals(intervals = []) {
74904
+ if (!Array.isArray(intervals) || !intervals.length) return [];
74905
+ return intervals;
74906
+ }
74907
+
74859
74908
  /**
74860
74909
  * Get mediaComposition from an URN.
74861
74910
  *
@@ -74864,7 +74913,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74864
74913
  *
74865
74914
  * @returns {Promise<MediaComposition>}
74866
74915
  */
74867
- static getMediaComposition(_x5) {
74916
+ static getMediaComposition(_x7) {
74868
74917
  return _asyncToGenerator(function* (urn, handleRequest = new DataProvider().handleRequest()) {
74869
74918
  const data = yield handleRequest(urn);
74870
74919
  return Object.assign(new MediaComposition(), data);
@@ -75091,7 +75140,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75091
75140
  var _ref = _asyncToGenerator(function* (srcObj, next) {
75092
75141
  return SrgSsr.handleSetSource(player, srcObj, next);
75093
75142
  });
75094
- return function setSource(_x6, _x7) {
75143
+ return function setSource(_x8, _x9) {
75095
75144
  return _ref.apply(this, arguments);
75096
75145
  };
75097
75146
  }()