shaka-player 4.10.13 → 4.11.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/README.md +5 -1
- package/dist/controls.css +3 -3
- package/dist/controls.css.map +1 -1
- package/dist/deps.js +11 -11
- package/dist/locales.js +38 -34
- package/dist/shaka-player.compiled.d.ts +68 -33
- package/dist/shaka-player.compiled.debug.d.ts +68 -33
- package/dist/shaka-player.compiled.debug.externs.js +584 -544
- package/dist/shaka-player.compiled.debug.js +715 -676
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +584 -544
- package/dist/shaka-player.compiled.js +1394 -1371
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +76 -34
- package/dist/shaka-player.ui.debug.d.ts +76 -34
- package/dist/shaka-player.ui.debug.externs.js +77 -26
- package/dist/shaka-player.ui.debug.js +774 -720
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +77 -26
- package/dist/shaka-player.ui.js +1649 -1617
- package/dist/shaka-player.ui.map +4 -4
- package/externs/mediasession.js +10 -1
- package/externs/shaka/ads.js +79 -2
- package/externs/shaka/manifest.js +6 -1
- package/externs/shaka/manifest_parser.js +6 -2
- package/externs/shaka/net.js +23 -2
- package/externs/shaka/player.js +414 -103
- package/externs/shaka/text.js +2 -1
- package/lib/abr/simple_abr_manager.js +5 -0
- package/lib/ads/ad_manager.js +45 -1
- package/lib/ads/ad_utils.js +124 -1
- package/lib/ads/interstitial_ad.js +9 -2
- package/lib/ads/interstitial_ad_manager.js +216 -101
- package/lib/ads/media_tailor_ad.js +1 -39
- package/lib/ads/media_tailor_ad_manager.js +32 -16
- package/lib/cea/cea608_data_channel.js +40 -8
- package/lib/cea/cea608_memory.js +28 -0
- package/lib/dash/dash_parser.js +162 -25
- package/lib/dash/segment_base.js +3 -2
- package/lib/dash/segment_list.js +6 -3
- package/lib/dash/segment_template.js +104 -20
- package/lib/hls/hls_parser.js +319 -215
- package/lib/media/drm_engine.js +11 -3
- package/lib/media/media_source_engine.js +0 -8
- package/lib/media/preload_manager.js +16 -4
- package/lib/media/segment_reference.js +3 -0
- package/lib/media/segment_utils.js +8 -1
- package/lib/media/streaming_engine.js +10 -6
- package/lib/mss/mss_parser.js +14 -2
- package/lib/net/http_fetch_plugin.js +12 -5
- package/lib/net/http_xhr_plugin.js +7 -3
- package/lib/net/networking_engine.js +21 -1
- package/lib/offline/manifest_converter.js +1 -0
- package/lib/offline/storage.js +1 -0
- package/lib/player.js +336 -121
- package/lib/text/cue.js +373 -0
- package/lib/text/mp4_ttml_parser.js +51 -1
- package/lib/text/mp4_vtt_parser.js +2 -5
- package/lib/text/sbv_text_parser.js +2 -31
- package/lib/text/srt_text_parser.js +1 -1
- package/lib/text/text_engine.js +1 -1
- package/lib/text/text_utils.js +1 -0
- package/lib/text/ttml_text_parser.js +14 -4
- package/lib/text/ui_text_displayer.js +0 -4
- package/lib/text/vtt_text_parser.js +10 -415
- package/lib/util/abortable_operation.js +8 -0
- package/lib/util/cmcd_manager.js +38 -0
- package/lib/util/error.js +16 -0
- package/lib/util/fake_event.js +1 -0
- package/lib/util/manifest_parser_utils.js +12 -3
- package/lib/util/player_configuration.js +4 -2
- package/lib/util/stream_utils.js +57 -2
- package/lib/util/tXml.js +2 -1
- package/lib/util/text_parser.js +46 -0
- package/lib/util/ts_parser.js +32 -3
- package/package.json +1 -1
- package/shaka-player.uncompiled.js +1 -1
- package/ui/chapter_selection.js +179 -0
- package/ui/controls.js +151 -0
- package/ui/enums.js +1 -0
- package/ui/externs/ui.js +7 -1
- package/ui/less/containers.less +3 -4
- package/ui/less/overflow_menu.less +5 -0
- package/ui/less/tooltip.less +1 -1
- package/ui/locales/en.json +1 -0
- package/ui/locales/es.json +1 -0
- package/ui/locales/fr.json +1 -0
- package/ui/locales/source.json +4 -0
- package/ui/seek_bar.js +3 -2
- package/ui/ui.js +2 -0
- package/lib/polyfill/abort_controller.js +0 -158
package/externs/shaka/text.js
CHANGED
|
@@ -38,11 +38,12 @@ shaka.extern.TextParser = class {
|
|
|
38
38
|
* for each cue.
|
|
39
39
|
* @param {?(string|undefined)} uri
|
|
40
40
|
* The media uri.
|
|
41
|
+
* @param {!Array.<string>} images
|
|
41
42
|
* @return {!Array.<!shaka.text.Cue>}
|
|
42
43
|
*
|
|
43
44
|
* @exportDoc
|
|
44
45
|
*/
|
|
45
|
-
parseMedia(data, timeContext, uri) {}
|
|
46
|
+
parseMedia(data, timeContext, uri, images) {}
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* Notifies the stream if the manifest is in sequence mode or not.
|
|
@@ -344,6 +344,11 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
344
344
|
*/
|
|
345
345
|
getBandwidthEstimate() {
|
|
346
346
|
const defaultBandwidthEstimate = this.getDefaultBandwidth_();
|
|
347
|
+
if (navigator.connection && navigator.connection.downlink &&
|
|
348
|
+
this.config_.useNetworkInformation &&
|
|
349
|
+
this.config_.preferNetworkInformationBandwidth) {
|
|
350
|
+
return defaultBandwidthEstimate;
|
|
351
|
+
}
|
|
347
352
|
const bandwidthEstimate = this.bandwidthEstimator_.getBandwidthEstimate(
|
|
348
353
|
defaultBandwidthEstimate);
|
|
349
354
|
if (this.cmsdManager_) {
|
package/lib/ads/ad_manager.js
CHANGED
|
@@ -823,7 +823,7 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
|
|
|
823
823
|
* @override
|
|
824
824
|
* @export
|
|
825
825
|
*/
|
|
826
|
-
|
|
826
|
+
onHLSInterstitialMetadata(basePlayer, baseVideo, interstitial) {
|
|
827
827
|
if (!this.interstitialAdManager_) {
|
|
828
828
|
this.initInterstitial(/* adContainer= */ null, basePlayer, baseVideo);
|
|
829
829
|
}
|
|
@@ -832,6 +832,50 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
|
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
+
/**
|
|
836
|
+
* @override
|
|
837
|
+
* @export
|
|
838
|
+
*/
|
|
839
|
+
onDASHInterstitialMetadata(basePlayer, baseVideo, region) {
|
|
840
|
+
if (region.schemeIdUri != 'urn:mpeg:dash:event:alternativeMPD:2022') {
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
if (!this.interstitialAdManager_) {
|
|
844
|
+
this.initInterstitial(/* adContainer= */ null, basePlayer, baseVideo);
|
|
845
|
+
}
|
|
846
|
+
if (this.interstitialAdManager_) {
|
|
847
|
+
this.interstitialAdManager_.addRegion(region);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* @override
|
|
853
|
+
* @export
|
|
854
|
+
*/
|
|
855
|
+
addCustomInterstitial(interstitial) {
|
|
856
|
+
if (!this.interstitialAdManager_) {
|
|
857
|
+
throw new shaka.util.Error(
|
|
858
|
+
shaka.util.Error.Severity.RECOVERABLE,
|
|
859
|
+
shaka.util.Error.Category.ADS,
|
|
860
|
+
shaka.util.Error.Code.INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED);
|
|
861
|
+
}
|
|
862
|
+
this.interstitialAdManager_.addInterstitials([interstitial]);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* @override
|
|
867
|
+
* @export
|
|
868
|
+
*/
|
|
869
|
+
addAdUrlInterstitial(url) {
|
|
870
|
+
if (!this.interstitialAdManager_) {
|
|
871
|
+
throw new shaka.util.Error(
|
|
872
|
+
shaka.util.Error.Severity.RECOVERABLE,
|
|
873
|
+
shaka.util.Error.Category.ADS,
|
|
874
|
+
shaka.util.Error.Code.INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED);
|
|
875
|
+
}
|
|
876
|
+
return this.interstitialAdManager_.addAdUrlInterstitial(url);
|
|
877
|
+
}
|
|
878
|
+
|
|
835
879
|
/**
|
|
836
880
|
* @param {!shaka.util.FakeEvent} event
|
|
837
881
|
* @private
|
package/lib/ads/ad_utils.js
CHANGED
|
@@ -7,13 +7,136 @@
|
|
|
7
7
|
|
|
8
8
|
goog.provide('shaka.ads.Utils');
|
|
9
9
|
|
|
10
|
+
goog.require('shaka.util.TextParser');
|
|
11
|
+
goog.require('shaka.util.TXml');
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* A class responsible for ad utils.
|
|
13
16
|
* @export
|
|
14
17
|
*/
|
|
15
18
|
shaka.ads.Utils = class {
|
|
16
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @param {!shaka.extern.xml.Node} vast
|
|
21
|
+
* @param {?number} currentTime
|
|
22
|
+
* @return {!Array.<shaka.extern.AdInterstitial>}
|
|
23
|
+
*/
|
|
24
|
+
static parseVastToInterstitials(vast, currentTime) {
|
|
25
|
+
const TXml = shaka.util.TXml;
|
|
26
|
+
/** @type {!Array.<shaka.extern.AdInterstitial>} */
|
|
27
|
+
const interstitials = [];
|
|
28
|
+
|
|
29
|
+
let startTime = 0;
|
|
30
|
+
if (currentTime != null) {
|
|
31
|
+
startTime = currentTime;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (const ad of TXml.findChildren(vast, 'Ad')) {
|
|
35
|
+
const inline = TXml.findChild(ad, 'InLine');
|
|
36
|
+
if (!inline) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const creatives = TXml.findChild(inline, 'Creatives');
|
|
40
|
+
if (!creatives) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
for (const creative of TXml.findChildren(creatives, 'Creative')) {
|
|
44
|
+
const linear = TXml.findChild(creative, 'Linear');
|
|
45
|
+
if (!linear) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
let skipOffset = null;
|
|
49
|
+
if (linear.attributes['skipoffset']) {
|
|
50
|
+
skipOffset = shaka.util.TextParser.parseTime(
|
|
51
|
+
linear.attributes['skipoffset']);
|
|
52
|
+
if (isNaN(skipOffset)) {
|
|
53
|
+
skipOffset = null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const mediaFiles = TXml.findChild(linear, 'MediaFiles');
|
|
57
|
+
if (!mediaFiles) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const medias = TXml.findChildren(mediaFiles, 'MediaFile');
|
|
61
|
+
let checkMedias = medias;
|
|
62
|
+
const streamingMedias = medias.filter((media) => {
|
|
63
|
+
return media.attributes['delivery'] == 'streaming';
|
|
64
|
+
});
|
|
65
|
+
if (streamingMedias.length) {
|
|
66
|
+
checkMedias = streamingMedias;
|
|
67
|
+
}
|
|
68
|
+
const sortedMedias = checkMedias.sort((a, b) => {
|
|
69
|
+
const aHeight = parseInt(a.attributes['height'], 10) || 0;
|
|
70
|
+
const bHeight = parseInt(b.attributes['height'], 10) || 0;
|
|
71
|
+
return bHeight - aHeight;
|
|
72
|
+
});
|
|
73
|
+
for (const media of sortedMedias) {
|
|
74
|
+
const adUrl = TXml.getTextContents(media);
|
|
75
|
+
if (!adUrl) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
interstitials.push({
|
|
79
|
+
id: null,
|
|
80
|
+
startTime: startTime,
|
|
81
|
+
endTime: null,
|
|
82
|
+
uri: adUrl,
|
|
83
|
+
isSkippable: skipOffset != null,
|
|
84
|
+
skipOffset,
|
|
85
|
+
canJump: false,
|
|
86
|
+
resumeOffset: 0,
|
|
87
|
+
playoutLimit: null,
|
|
88
|
+
once: true,
|
|
89
|
+
pre: currentTime == null,
|
|
90
|
+
post: currentTime == Infinity,
|
|
91
|
+
timelineRange: false,
|
|
92
|
+
});
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return interstitials;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {!shaka.extern.xml.Node} vmap
|
|
102
|
+
* @return {!Array.<{time: ?number, uri: string}>}
|
|
103
|
+
*/
|
|
104
|
+
static parseVMAP(vmap) {
|
|
105
|
+
const TXml = shaka.util.TXml;
|
|
106
|
+
/** @type {!Array.<{time: ?number, uri: string}>} */
|
|
107
|
+
const ads = [];
|
|
108
|
+
for (const adBreak of TXml.findChildren(vmap, 'vmap:AdBreak')) {
|
|
109
|
+
const timeOffset = adBreak.attributes['timeOffset'];
|
|
110
|
+
if (!timeOffset) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
let time = null;
|
|
114
|
+
if (timeOffset == 'start') {
|
|
115
|
+
time = 0;
|
|
116
|
+
} else if (timeOffset == 'end') {
|
|
117
|
+
time = Infinity;
|
|
118
|
+
} else {
|
|
119
|
+
time = shaka.util.TextParser.parseTime(timeOffset);
|
|
120
|
+
}
|
|
121
|
+
const adSource = TXml.findChild(adBreak, 'vmap:AdSource');
|
|
122
|
+
if (!adSource) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const adTagURI = TXml.findChild(adSource, 'vmap:AdTagURI');
|
|
126
|
+
if (!adTagURI) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const uri = TXml.getTextContents(adTagURI);
|
|
130
|
+
if (!uri) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
ads.push({
|
|
134
|
+
time,
|
|
135
|
+
uri,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return ads;
|
|
139
|
+
}
|
|
17
140
|
};
|
|
18
141
|
|
|
19
142
|
/**
|
|
@@ -15,17 +15,22 @@ shaka.ads.InterstitialAd = class {
|
|
|
15
15
|
/**
|
|
16
16
|
* @param {HTMLMediaElement} video
|
|
17
17
|
* @param {boolean} isSkippable
|
|
18
|
+
* @param {?number} skipOffset
|
|
18
19
|
* @param {function()} onSkip
|
|
19
20
|
* @param {number} sequenceLength
|
|
20
21
|
* @param {number} adPosition
|
|
21
22
|
*/
|
|
22
|
-
constructor(video, isSkippable,
|
|
23
|
+
constructor(video, isSkippable, skipOffset, onSkip,
|
|
24
|
+
sequenceLength, adPosition) {
|
|
23
25
|
/** @private {HTMLMediaElement} */
|
|
24
26
|
this.video_ = video;
|
|
25
27
|
|
|
26
28
|
/** @private {boolean} */
|
|
27
29
|
this.isSkippable_ = isSkippable;
|
|
28
30
|
|
|
31
|
+
/** @private {?number} */
|
|
32
|
+
this.skipOffset_ = skipOffset;
|
|
33
|
+
|
|
29
34
|
/** @private {function()} */
|
|
30
35
|
this.onSkip_ = onSkip;
|
|
31
36
|
|
|
@@ -98,7 +103,9 @@ shaka.ads.InterstitialAd = class {
|
|
|
98
103
|
*/
|
|
99
104
|
getTimeUntilSkippable() {
|
|
100
105
|
if (this.isSkippable_) {
|
|
101
|
-
|
|
106
|
+
const canSkipIn =
|
|
107
|
+
this.getRemainingTime() + this.skipOffset_ - this.getDuration();
|
|
108
|
+
return Math.max(canSkipIn, 0);
|
|
102
109
|
}
|
|
103
110
|
return Math.max(this.getRemainingTime(), 0);
|
|
104
111
|
}
|