@srgssr/pillarbox-web 1.29.0 → 1.31.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.
- package/dist/pillarbox-core.cjs +1 -1
- package/dist/pillarbox-core.es.js +1 -1
- package/dist/pillarbox.cjs +79 -25
- package/dist/pillarbox.cjs.map +1 -1
- package/dist/pillarbox.es.js +79 -25
- package/dist/pillarbox.es.js.map +1 -1
- package/dist/pillarbox.umd.js +79 -25
- package/dist/pillarbox.umd.js.map +1 -1
- package/dist/pillarbox.umd.min.js +1 -1
- package/dist/pillarbox.umd.min.js.map +1 -1
- package/dist/types/src/middleware/srgssr.d.ts +44 -2
- package/dist/types/src/middleware/srgssr.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/pillarbox.umd.js
CHANGED
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
return "symbol" == typeof i ? i : i + "";
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
const version$8 = "1.
|
|
96
|
+
const version$8 = "1.30.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
|
|
74495
|
-
|
|
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
|
|
|
@@ -74537,7 +74532,29 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
|
|
|
74537
74532
|
static addTextTrackCue(textTrack, data) {
|
|
74538
74533
|
const startTime = (Number.isFinite(data.markIn) ? data.markIn : data.fullLengthMarkIn) / 1000;
|
|
74539
74534
|
const endTime = (Number.isFinite(data.markOut) ? data.markOut : data.fullLengthMarkOut) / 1000;
|
|
74540
|
-
|
|
74535
|
+
const text = JSON.stringify(data);
|
|
74536
|
+
const cue = new VTTCue(startTime, endTime, text);
|
|
74537
|
+
if (data.urn) {
|
|
74538
|
+
cue.id = data.urn;
|
|
74539
|
+
}
|
|
74540
|
+
textTrack.addCue(cue);
|
|
74541
|
+
}
|
|
74542
|
+
|
|
74543
|
+
/**
|
|
74544
|
+
* Add a new cues to a text track with the given array.
|
|
74545
|
+
*
|
|
74546
|
+
* @param {TextTrack} textTrack
|
|
74547
|
+
* @param {Array.<
|
|
74548
|
+
* Segment |
|
|
74549
|
+
* Chapter |
|
|
74550
|
+
* TimeInterval>
|
|
74551
|
+
* } cues SRG SSR's cues-like representation
|
|
74552
|
+
*/
|
|
74553
|
+
static addTextTrackCues(textTrack, cues = []) {
|
|
74554
|
+
if (!Array.isArray(cues)) return;
|
|
74555
|
+
cues.forEach(cue => {
|
|
74556
|
+
SrgSsr.addTextTrackCue(textTrack, cue);
|
|
74557
|
+
});
|
|
74541
74558
|
}
|
|
74542
74559
|
|
|
74543
74560
|
/**
|
|
@@ -74565,12 +74582,8 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
|
|
|
74565
74582
|
static addChapters(_x2, _x3) {
|
|
74566
74583
|
return _asyncToGenerator(function* (player, chapterUrn, chapters = []) {
|
|
74567
74584
|
const trackId = 'srgssr-chapters';
|
|
74568
|
-
const
|
|
74569
|
-
|
|
74570
|
-
chapters.forEach(chapter => {
|
|
74571
|
-
if (chapterUrn !== chapter.fullLengthUrn) return;
|
|
74572
|
-
SrgSsr.addTextTrackCue(chapterTrack, chapter);
|
|
74573
|
-
});
|
|
74585
|
+
const chaptersToAdd = SrgSsr.getChapters(chapterUrn, chapters);
|
|
74586
|
+
yield SrgSsr.createTextTrack(player, trackId, chaptersToAdd);
|
|
74574
74587
|
}).apply(this, arguments);
|
|
74575
74588
|
}
|
|
74576
74589
|
|
|
@@ -74583,11 +74596,8 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
|
|
|
74583
74596
|
static addIntervals(_x4) {
|
|
74584
74597
|
return _asyncToGenerator(function* (player, intervals = []) {
|
|
74585
74598
|
const trackId = 'srgssr-intervals';
|
|
74586
|
-
const
|
|
74587
|
-
|
|
74588
|
-
intervals.forEach(interval => {
|
|
74589
|
-
SrgSsr.addTextTrackCue(intervalTrack, interval);
|
|
74590
|
-
});
|
|
74599
|
+
const instervalsToAdd = SrgSsr.getIntervals(intervals);
|
|
74600
|
+
yield SrgSsr.createTextTrack(player, trackId, instervalsToAdd);
|
|
74591
74601
|
}).apply(this, arguments);
|
|
74592
74602
|
}
|
|
74593
74603
|
|
|
@@ -74698,11 +74708,16 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
|
|
|
74698
74708
|
*
|
|
74699
74709
|
* @param {Player} player
|
|
74700
74710
|
* @param {String} trackId Text track unique ID
|
|
74711
|
+
* @param {Array.<
|
|
74712
|
+
* Segment |
|
|
74713
|
+
* Chapter |
|
|
74714
|
+
* TimeInterval>
|
|
74715
|
+
* } cues SRG SSR's cues-like representation
|
|
74701
74716
|
*
|
|
74702
74717
|
* @returns {Promise<TextTrack>}
|
|
74703
74718
|
*/
|
|
74704
|
-
static createTextTrack(
|
|
74705
|
-
return _asyncToGenerator(function* () {
|
|
74719
|
+
static createTextTrack(_x5, _x6) {
|
|
74720
|
+
return _asyncToGenerator(function* (player, trackId, cues = []) {
|
|
74706
74721
|
const removeTrack = player.textTracks().getTrackById(trackId);
|
|
74707
74722
|
if (removeTrack) {
|
|
74708
74723
|
player.textTracks().removeTrack(removeTrack);
|
|
@@ -74719,9 +74734,10 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
|
|
|
74719
74734
|
}));
|
|
74720
74735
|
}, 100);
|
|
74721
74736
|
});
|
|
74737
|
+
SrgSsr.addTextTrackCues(textTrack, cues);
|
|
74722
74738
|
player.textTracks().addTrack(textTrack);
|
|
74723
74739
|
return textTrack;
|
|
74724
|
-
})();
|
|
74740
|
+
}).apply(this, arguments);
|
|
74725
74741
|
}
|
|
74726
74742
|
|
|
74727
74743
|
/**
|
|
@@ -74856,6 +74872,44 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
|
|
|
74856
74872
|
return isBlocked ? blockedSegment : undefined;
|
|
74857
74873
|
}
|
|
74858
74874
|
|
|
74875
|
+
/**
|
|
74876
|
+
* Get blocked segments.
|
|
74877
|
+
*
|
|
74878
|
+
* @param {Player} player
|
|
74879
|
+
* @param {Array<Segment>} [segments=[]]
|
|
74880
|
+
*
|
|
74881
|
+
* @returns {Array<Segment>}
|
|
74882
|
+
*/
|
|
74883
|
+
static getBlockedSegments(segments = []) {
|
|
74884
|
+
if (!Array.isArray(segments) || !segments.length) return [];
|
|
74885
|
+
return segments.filter(segment => segment.blockReason);
|
|
74886
|
+
}
|
|
74887
|
+
|
|
74888
|
+
/**
|
|
74889
|
+
* Get chapters related to the main chapter.
|
|
74890
|
+
*
|
|
74891
|
+
* @param {string} chapterUrn The URN of the main chapter.
|
|
74892
|
+
* @param {Array.<Chapter>} [chapters=[]]
|
|
74893
|
+
*
|
|
74894
|
+
* @returns {Array.<Chapter>}
|
|
74895
|
+
*/
|
|
74896
|
+
static getChapters(chapterUrn, chapters = []) {
|
|
74897
|
+
if (!Array.isArray(chapters) || !chapters.length) return [];
|
|
74898
|
+
return chapters.filter(chapter => chapterUrn === chapter.fullLengthUrn);
|
|
74899
|
+
}
|
|
74900
|
+
|
|
74901
|
+
/**
|
|
74902
|
+
* Get intervals.
|
|
74903
|
+
*
|
|
74904
|
+
* @param {Array<TimeInterval>} [segments=[]]
|
|
74905
|
+
*
|
|
74906
|
+
* @returns {Array<TimeInterval>}
|
|
74907
|
+
*/
|
|
74908
|
+
static getIntervals(intervals = []) {
|
|
74909
|
+
if (!Array.isArray(intervals) || !intervals.length) return [];
|
|
74910
|
+
return intervals;
|
|
74911
|
+
}
|
|
74912
|
+
|
|
74859
74913
|
/**
|
|
74860
74914
|
* Get mediaComposition from an URN.
|
|
74861
74915
|
*
|
|
@@ -74864,7 +74918,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
|
|
|
74864
74918
|
*
|
|
74865
74919
|
* @returns {Promise<MediaComposition>}
|
|
74866
74920
|
*/
|
|
74867
|
-
static getMediaComposition(
|
|
74921
|
+
static getMediaComposition(_x7) {
|
|
74868
74922
|
return _asyncToGenerator(function* (urn, handleRequest = new DataProvider().handleRequest()) {
|
|
74869
74923
|
const data = yield handleRequest(urn);
|
|
74870
74924
|
return Object.assign(new MediaComposition(), data);
|
|
@@ -75091,7 +75145,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
|
|
|
75091
75145
|
var _ref = _asyncToGenerator(function* (srcObj, next) {
|
|
75092
75146
|
return SrgSsr.handleSetSource(player, srcObj, next);
|
|
75093
75147
|
});
|
|
75094
|
-
return function setSource(
|
|
75148
|
+
return function setSource(_x8, _x9) {
|
|
75095
75149
|
return _ref.apply(this, arguments);
|
|
75096
75150
|
};
|
|
75097
75151
|
}()
|