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/lib/media/drm_engine.js
CHANGED
|
@@ -142,6 +142,9 @@ shaka.media.DrmEngine = class {
|
|
|
142
142
|
|
|
143
143
|
/** @private {?shaka.extern.InitDataOverride} */
|
|
144
144
|
this.manifestInitData_ = null;
|
|
145
|
+
|
|
146
|
+
/** @private {function():boolean} */
|
|
147
|
+
this.isPreload_ = () => false;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
/** @override */
|
|
@@ -213,9 +216,13 @@ shaka.media.DrmEngine = class {
|
|
|
213
216
|
* Must be called at least once before init().
|
|
214
217
|
*
|
|
215
218
|
* @param {shaka.extern.DrmConfiguration} config
|
|
219
|
+
* @param {(function():boolean)=} isPreload
|
|
216
220
|
*/
|
|
217
|
-
configure(config) {
|
|
221
|
+
configure(config, isPreload) {
|
|
218
222
|
this.config_ = config;
|
|
223
|
+
if (isPreload) {
|
|
224
|
+
this.isPreload_ = isPreload;
|
|
225
|
+
}
|
|
219
226
|
if (this.expirationTimer_) {
|
|
220
227
|
this.expirationTimer_.tickEvery(
|
|
221
228
|
/* seconds= */ this.config_.updateExpirationTime);
|
|
@@ -584,7 +591,7 @@ shaka.media.DrmEngine = class {
|
|
|
584
591
|
try {
|
|
585
592
|
const operation = this.playerInterface_.netEngine.request(
|
|
586
593
|
shaka.net.NetworkingEngine.RequestType.SERVER_CERTIFICATE,
|
|
587
|
-
request);
|
|
594
|
+
request, {isPreload: this.isPreload_()});
|
|
588
595
|
const response = await operation.promise;
|
|
589
596
|
|
|
590
597
|
this.currentDrmInfo_.serverCertificate =
|
|
@@ -1489,7 +1496,8 @@ shaka.media.DrmEngine = class {
|
|
|
1489
1496
|
|
|
1490
1497
|
let response;
|
|
1491
1498
|
try {
|
|
1492
|
-
const req = this.playerInterface_.netEngine.request(
|
|
1499
|
+
const req = this.playerInterface_.netEngine.request(
|
|
1500
|
+
requestType, request, {isPreload: this.isPreload_()});
|
|
1493
1501
|
response = await req.promise;
|
|
1494
1502
|
} catch (error) {
|
|
1495
1503
|
if (this.destroyer_.destroyed()) {
|
|
@@ -407,9 +407,6 @@ shaka.media.MediaSourceEngine = class {
|
|
|
407
407
|
if (this.textEngine_) {
|
|
408
408
|
cleanup.push(this.textEngine_.destroy());
|
|
409
409
|
}
|
|
410
|
-
if (this.textDisplayer_) {
|
|
411
|
-
cleanup.push(this.textDisplayer_.destroy());
|
|
412
|
-
}
|
|
413
410
|
|
|
414
411
|
for (const contentType in this.transmuxers_) {
|
|
415
412
|
cleanup.push(this.transmuxers_[contentType].destroy());
|
|
@@ -1748,12 +1745,7 @@ shaka.media.MediaSourceEngine = class {
|
|
|
1748
1745
|
* @param {!shaka.extern.TextDisplayer} textDisplayer
|
|
1749
1746
|
*/
|
|
1750
1747
|
setTextDisplayer(textDisplayer) {
|
|
1751
|
-
const oldTextDisplayer = this.textDisplayer_;
|
|
1752
1748
|
this.textDisplayer_ = textDisplayer;
|
|
1753
|
-
if (oldTextDisplayer) {
|
|
1754
|
-
textDisplayer.setTextVisibility(oldTextDisplayer.isTextVisible());
|
|
1755
|
-
oldTextDisplayer.destroy();
|
|
1756
|
-
}
|
|
1757
1749
|
if (this.textEngine_) {
|
|
1758
1750
|
this.textEngine_.setDisplayer(textDisplayer);
|
|
1759
1751
|
}
|
|
@@ -153,6 +153,17 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
|
|
|
153
153
|
|
|
154
154
|
/** @private {?Array.<function()>} */
|
|
155
155
|
this.latePhaseQueuedOperations_ = [];
|
|
156
|
+
|
|
157
|
+
/** @private {boolean} */
|
|
158
|
+
this.isPreload_ = true;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Makes it so that net requests launched from this load will no longer be
|
|
163
|
+
* marked as "isPreload"
|
|
164
|
+
*/
|
|
165
|
+
markIsLoad() {
|
|
166
|
+
this.isPreload_ = false;
|
|
156
167
|
}
|
|
157
168
|
|
|
158
169
|
/**
|
|
@@ -478,7 +489,7 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
|
|
|
478
489
|
goog.asserts.assert(this.parserFactory_, 'Must have manifest parser');
|
|
479
490
|
this.parser_ = this.parserFactory_();
|
|
480
491
|
|
|
481
|
-
this.parser_.configure(this.config_.manifest);
|
|
492
|
+
this.parser_.configure(this.config_.manifest, () => this.isPreload_);
|
|
482
493
|
}
|
|
483
494
|
|
|
484
495
|
const startTime = Date.now() / 1000;
|
|
@@ -530,7 +541,7 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
|
|
|
530
541
|
this.drmEngine_ = this.createDrmEngine_();
|
|
531
542
|
this.manifestFilterer_.setDrmEngine(this.drmEngine_);
|
|
532
543
|
|
|
533
|
-
this.drmEngine_.configure(this.config_.drm);
|
|
544
|
+
this.drmEngine_.configure(this.config_.drm, () => this.isPreload_);
|
|
534
545
|
|
|
535
546
|
const tracksChangedInitial = this.manifestFilterer_.applyRestrictions(
|
|
536
547
|
this.manifest_);
|
|
@@ -660,7 +671,8 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
|
|
|
660
671
|
prefetchLimit, stream, (reference, stream, streamDataCallback) => {
|
|
661
672
|
return shaka.media.StreamingEngine.dispatchFetch(
|
|
662
673
|
reference, stream, streamDataCallback || null,
|
|
663
|
-
this.config_.streaming.retryParameters, this.networkingEngine_
|
|
674
|
+
this.config_.streaming.retryParameters, this.networkingEngine_,
|
|
675
|
+
this.isPreload_);
|
|
664
676
|
}, /* reverse= */ false);
|
|
665
677
|
this.segmentPrefetchById_.set(stream.id, prefetch);
|
|
666
678
|
|
|
@@ -674,7 +686,7 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
|
|
|
674
686
|
if (!prefetchSegment) {
|
|
675
687
|
// If we can't get a segment at the desired spot, at least get a segment,
|
|
676
688
|
// so we can get the init segment.
|
|
677
|
-
prefetchSegment = stream.segmentIndex.
|
|
689
|
+
prefetchSegment = stream.segmentIndex.earliestReference();
|
|
678
690
|
}
|
|
679
691
|
if (prefetchSegment) {
|
|
680
692
|
if (isLive) {
|
|
@@ -42,6 +42,7 @@ shaka.media.SegmentUtils = class {
|
|
|
42
42
|
closedCaptions: new Map(),
|
|
43
43
|
videoRange: null,
|
|
44
44
|
colorGamut: null,
|
|
45
|
+
frameRate: null,
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -127,6 +128,7 @@ shaka.media.SegmentUtils = class {
|
|
|
127
128
|
closedCaptions: closedCaptions,
|
|
128
129
|
videoRange: null,
|
|
129
130
|
colorGamut: null,
|
|
131
|
+
frameRate: videoInfo.frameRate,
|
|
130
132
|
};
|
|
131
133
|
}
|
|
132
134
|
|
|
@@ -204,6 +206,8 @@ shaka.media.SegmentUtils = class {
|
|
|
204
206
|
let realVideoRange = null;
|
|
205
207
|
/** @type {?string} */
|
|
206
208
|
let realColorGamut = null;
|
|
209
|
+
/** @type {?string} */
|
|
210
|
+
const realFrameRate = null;
|
|
207
211
|
|
|
208
212
|
/** @type {?string} */
|
|
209
213
|
let baseBox;
|
|
@@ -432,6 +436,7 @@ shaka.media.SegmentUtils = class {
|
|
|
432
436
|
closedCaptions: closedCaptions,
|
|
433
437
|
videoRange: realVideoRange,
|
|
434
438
|
colorGamut: realColorGamut,
|
|
439
|
+
frameRate: realFrameRate,
|
|
435
440
|
};
|
|
436
441
|
}
|
|
437
442
|
|
|
@@ -594,7 +599,8 @@ shaka.media.SegmentUtils = class {
|
|
|
594
599
|
* sampleRate: ?number,
|
|
595
600
|
* closedCaptions: Map.<string, string>,
|
|
596
601
|
* videoRange: ?string,
|
|
597
|
-
* colorGamut: ?string
|
|
602
|
+
* colorGamut: ?string,
|
|
603
|
+
* frameRate: ?string
|
|
598
604
|
* }}
|
|
599
605
|
*
|
|
600
606
|
* @property {string} type
|
|
@@ -608,5 +614,6 @@ shaka.media.SegmentUtils = class {
|
|
|
608
614
|
* @property {Map.<string, string>} closedCaptions
|
|
609
615
|
* @property {?string} videoRange
|
|
610
616
|
* @property {?string} colorGamut
|
|
617
|
+
* @property {?string} frameRate
|
|
611
618
|
*/
|
|
612
619
|
shaka.media.SegmentUtils.BasicInfo;
|
|
@@ -1965,8 +1965,8 @@ shaka.media.StreamingEngine = class {
|
|
|
1965
1965
|
reference.startTime <= appendWindowEnd,
|
|
1966
1966
|
logPrefix + ' segment should start before append window end');
|
|
1967
1967
|
|
|
1968
|
-
const
|
|
1969
|
-
|
|
1968
|
+
const fullCodecs = (reference.codecs || mediaState.stream.codecs);
|
|
1969
|
+
const codecs = MimeUtils.getCodecBase(fullCodecs);
|
|
1970
1970
|
const mimeType = MimeUtils.getBasicType(
|
|
1971
1971
|
reference.mimeType || mediaState.stream.mimeType);
|
|
1972
1972
|
const timestampOffset = reference.timestampOffset;
|
|
@@ -1984,7 +1984,7 @@ shaka.media.StreamingEngine = class {
|
|
|
1984
1984
|
const isResetMediaSourceNecessary =
|
|
1985
1985
|
mediaState.lastCodecs && mediaState.lastMimeType &&
|
|
1986
1986
|
this.playerInterface_.mediaSourceEngine.isResetMediaSourceNecessary(
|
|
1987
|
-
mediaState.type, mediaState.stream, mimeType,
|
|
1987
|
+
mediaState.type, mediaState.stream, mimeType, fullCodecs);
|
|
1988
1988
|
if (isResetMediaSourceNecessary) {
|
|
1989
1989
|
let otherState = null;
|
|
1990
1990
|
if (mediaState.type === ContentType.VIDEO) {
|
|
@@ -2616,11 +2616,12 @@ shaka.media.StreamingEngine = class {
|
|
|
2616
2616
|
* @param {(!shaka.media.InitSegmentReference|!shaka.media.SegmentReference)}
|
|
2617
2617
|
* reference
|
|
2618
2618
|
* @param {?function(BufferSource):!Promise=} streamDataCallback
|
|
2619
|
+
* @param {boolean=} isPreload
|
|
2619
2620
|
*
|
|
2620
2621
|
* @return {!shaka.net.NetworkingEngine.PendingRequest}
|
|
2621
2622
|
* @private
|
|
2622
2623
|
*/
|
|
2623
|
-
dispatchFetch_(reference, stream, streamDataCallback) {
|
|
2624
|
+
dispatchFetch_(reference, stream, streamDataCallback, isPreload = false) {
|
|
2624
2625
|
goog.asserts.assert(
|
|
2625
2626
|
this.playerInterface_.netEngine, 'Must have net engine');
|
|
2626
2627
|
return shaka.media.StreamingEngine.dispatchFetch(
|
|
@@ -2637,11 +2638,13 @@ shaka.media.StreamingEngine = class {
|
|
|
2637
2638
|
* @param {?function(BufferSource):!Promise} streamDataCallback
|
|
2638
2639
|
* @param {shaka.extern.RetryParameters} retryParameters
|
|
2639
2640
|
* @param {!shaka.net.NetworkingEngine} netEngine
|
|
2641
|
+
* @param {boolean=} isPreload
|
|
2640
2642
|
*
|
|
2641
2643
|
* @return {!shaka.net.NetworkingEngine.PendingRequest}
|
|
2642
2644
|
*/
|
|
2643
2645
|
static dispatchFetch(
|
|
2644
|
-
reference, stream, streamDataCallback, retryParameters, netEngine
|
|
2646
|
+
reference, stream, streamDataCallback, retryParameters, netEngine,
|
|
2647
|
+
isPreload = false) {
|
|
2645
2648
|
const requestType = shaka.net.NetworkingEngine.RequestType.SEGMENT;
|
|
2646
2649
|
const segment = reference instanceof shaka.media.SegmentReference ?
|
|
2647
2650
|
reference : undefined;
|
|
@@ -2658,7 +2661,8 @@ shaka.media.StreamingEngine = class {
|
|
|
2658
2661
|
|
|
2659
2662
|
shaka.log.v2('fetching: reference=', reference);
|
|
2660
2663
|
|
|
2661
|
-
return netEngine.request(
|
|
2664
|
+
return netEngine.request(
|
|
2665
|
+
requestType, request, {type, stream, segment, isPreload});
|
|
2662
2666
|
}
|
|
2663
2667
|
|
|
2664
2668
|
/**
|
package/lib/mss/mss_parser.js
CHANGED
|
@@ -82,17 +82,25 @@ shaka.mss.MssParser = class {
|
|
|
82
82
|
* @private {!Map.<number, !BufferSource>}
|
|
83
83
|
*/
|
|
84
84
|
this.initSegmentDataByStreamId_ = new Map();
|
|
85
|
+
|
|
86
|
+
/** @private {function():boolean} */
|
|
87
|
+
this.isPreloadFn_ = () => false;
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
/**
|
|
91
|
+
* @param {shaka.extern.ManifestConfiguration} config
|
|
92
|
+
* @param {(function():boolean)=} isPreloadFn
|
|
88
93
|
* @override
|
|
89
94
|
* @exportInterface
|
|
90
95
|
*/
|
|
91
|
-
configure(config) {
|
|
96
|
+
configure(config, isPreloadFn) {
|
|
92
97
|
goog.asserts.assert(config.mss != null,
|
|
93
98
|
'MssManifestConfiguration should not be null!');
|
|
94
99
|
|
|
95
100
|
this.config_ = config;
|
|
101
|
+
if (isPreloadFn) {
|
|
102
|
+
this.isPreloadFn_ = isPreloadFn;
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
/**
|
|
@@ -252,7 +260,10 @@ shaka.mss.MssParser = class {
|
|
|
252
260
|
const networkingEngine = this.playerInterface_.networkingEngine;
|
|
253
261
|
|
|
254
262
|
const startTime = Date.now();
|
|
255
|
-
const operation = networkingEngine.request(requestType, request, {
|
|
263
|
+
const operation = networkingEngine.request(requestType, request, {
|
|
264
|
+
type,
|
|
265
|
+
isPreload: this.isPreloadFn_(),
|
|
266
|
+
});
|
|
256
267
|
this.operationManager_.manage(operation);
|
|
257
268
|
|
|
258
269
|
const response = await operation.promise;
|
|
@@ -429,6 +440,7 @@ shaka.mss.MssParser = class {
|
|
|
429
440
|
periodCount: 1,
|
|
430
441
|
gapCount: 0,
|
|
431
442
|
isLowLatency: false,
|
|
443
|
+
startTime: null,
|
|
432
444
|
};
|
|
433
445
|
|
|
434
446
|
// This is the first point where we have a meaningful presentation start
|
|
@@ -29,10 +29,12 @@ shaka.net.HttpFetchPlugin = class {
|
|
|
29
29
|
* progress event happened.
|
|
30
30
|
* @param {shaka.extern.HeadersReceived} headersReceived Called when the
|
|
31
31
|
* headers for the download are received, but before the body is.
|
|
32
|
+
* @param {shaka.extern.SchemePluginConfig} config
|
|
32
33
|
* @return {!shaka.extern.IAbortableOperation.<shaka.extern.Response>}
|
|
33
34
|
* @export
|
|
34
35
|
*/
|
|
35
|
-
static parse(uri, request, requestType, progressUpdated, headersReceived
|
|
36
|
+
static parse(uri, request, requestType, progressUpdated, headersReceived,
|
|
37
|
+
config) {
|
|
36
38
|
const headers = new shaka.net.HttpFetchPlugin.Headers_();
|
|
37
39
|
shaka.util.MapUtils.asMap(request.headers).forEach((value, key) => {
|
|
38
40
|
headers.append(key, value);
|
|
@@ -56,9 +58,11 @@ shaka.net.HttpFetchPlugin = class {
|
|
|
56
58
|
timedOut: false,
|
|
57
59
|
};
|
|
58
60
|
|
|
61
|
+
const minBytes = config.minBytesForProgressEvents || 0;
|
|
62
|
+
|
|
59
63
|
const pendingRequest = shaka.net.HttpFetchPlugin.request_(
|
|
60
64
|
uri, requestType, init, abortStatus, progressUpdated, headersReceived,
|
|
61
|
-
request.streamDataCallback);
|
|
65
|
+
request.streamDataCallback, minBytes);
|
|
62
66
|
|
|
63
67
|
/** @type {!shaka.util.AbortableOperation} */
|
|
64
68
|
const op = new shaka.util.AbortableOperation(pendingRequest, () => {
|
|
@@ -96,11 +100,12 @@ shaka.net.HttpFetchPlugin = class {
|
|
|
96
100
|
* @param {shaka.extern.ProgressUpdated} progressUpdated
|
|
97
101
|
* @param {shaka.extern.HeadersReceived} headersReceived
|
|
98
102
|
* @param {?function(BufferSource):!Promise} streamDataCallback
|
|
103
|
+
* @param {number} minBytes
|
|
99
104
|
* @return {!Promise<!shaka.extern.Response>}
|
|
100
105
|
* @private
|
|
101
106
|
*/
|
|
102
107
|
static async request_(uri, requestType, init, abortStatus, progressUpdated,
|
|
103
|
-
headersReceived, streamDataCallback) {
|
|
108
|
+
headersReceived, streamDataCallback, minBytes) {
|
|
104
109
|
const fetch = shaka.net.HttpFetchPlugin.fetch_;
|
|
105
110
|
const ReadableStream = shaka.net.HttpFetchPlugin.ReadableStream_;
|
|
106
111
|
let response;
|
|
@@ -163,13 +168,15 @@ shaka.net.HttpFetchPlugin = class {
|
|
|
163
168
|
}
|
|
164
169
|
|
|
165
170
|
const currentTime = Date.now();
|
|
171
|
+
const chunkSize = loaded - lastLoaded;
|
|
166
172
|
// If the time between last time and this time we got progress event
|
|
167
173
|
// is long enough, or if a whole segment is downloaded, call
|
|
168
174
|
// progressUpdated().
|
|
169
|
-
if (currentTime - lastTime > 100
|
|
175
|
+
if ((currentTime - lastTime > 100 && chunkSize >= minBytes) ||
|
|
176
|
+
readObj.done) {
|
|
170
177
|
const numBytesRemaining =
|
|
171
178
|
readObj.done ? 0 : contentLength - loaded;
|
|
172
|
-
progressUpdated(currentTime - lastTime,
|
|
179
|
+
progressUpdated(currentTime - lastTime, chunkSize,
|
|
173
180
|
numBytesRemaining);
|
|
174
181
|
lastLoaded = loaded;
|
|
175
182
|
lastTime = currentTime;
|
|
@@ -26,10 +26,12 @@ shaka.net.HttpXHRPlugin = class {
|
|
|
26
26
|
* progress event happened.
|
|
27
27
|
* @param {shaka.extern.HeadersReceived} headersReceived Called when the
|
|
28
28
|
* headers for the download are received, but before the body is.
|
|
29
|
+
* @param {shaka.extern.SchemePluginConfig} config
|
|
29
30
|
* @return {!shaka.extern.IAbortableOperation.<shaka.extern.Response>}
|
|
30
31
|
* @export
|
|
31
32
|
*/
|
|
32
|
-
static parse(uri, request, requestType, progressUpdated, headersReceived
|
|
33
|
+
static parse(uri, request, requestType, progressUpdated, headersReceived,
|
|
34
|
+
config) {
|
|
33
35
|
const xhr = new shaka.net.HttpXHRPlugin.Xhr_();
|
|
34
36
|
|
|
35
37
|
// Last time stamp when we got a progress event.
|
|
@@ -98,11 +100,13 @@ shaka.net.HttpXHRPlugin = class {
|
|
|
98
100
|
// If the time between last time and this time we got progress event
|
|
99
101
|
// is long enough, or if a whole segment is downloaded, call
|
|
100
102
|
// progressUpdated().
|
|
101
|
-
|
|
103
|
+
const minBytes = config.minBytesForProgressEvents || 0;
|
|
104
|
+
const chunkSize = event.loaded - lastLoaded;
|
|
105
|
+
if ((currentTime - lastTime > 100 && chunkSize >= minBytes) ||
|
|
102
106
|
(event.lengthComputable && event.loaded == event.total)) {
|
|
103
107
|
const numBytesRemaining =
|
|
104
108
|
xhr.readyState == 4 ? 0 : event.total - event.loaded;
|
|
105
|
-
progressUpdated(currentTime - lastTime,
|
|
109
|
+
progressUpdated(currentTime - lastTime, chunkSize,
|
|
106
110
|
numBytesRemaining);
|
|
107
111
|
lastLoaded = event.loaded;
|
|
108
112
|
lastTime = currentTime;
|
|
@@ -101,6 +101,9 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget {
|
|
|
101
101
|
|
|
102
102
|
/** @private {boolean} */
|
|
103
103
|
this.forceHTTPS_ = false;
|
|
104
|
+
|
|
105
|
+
/** @private {number} */
|
|
106
|
+
this.minBytesForProgressEvents_ = 16e3;
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
/**
|
|
@@ -119,6 +122,14 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget {
|
|
|
119
122
|
this.forceHTTPS_ = forceHTTPS;
|
|
120
123
|
}
|
|
121
124
|
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @param {number} minBytes
|
|
128
|
+
*/
|
|
129
|
+
setMinBytesForProgressEvents(minBytes) {
|
|
130
|
+
this.minBytesForProgressEvents_ = minBytes;
|
|
131
|
+
}
|
|
132
|
+
|
|
122
133
|
/**
|
|
123
134
|
* Registers a scheme plugin. This plugin will handle all requests with the
|
|
124
135
|
* given scheme. If a plugin with the same scheme already exists, it is
|
|
@@ -575,7 +586,10 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget {
|
|
|
575
586
|
request.requestStartTime = Date.now();
|
|
576
587
|
|
|
577
588
|
const requestPlugin = plugin(
|
|
578
|
-
request.uris[index], request, type, progressUpdated, headersReceived
|
|
589
|
+
request.uris[index], request, type, progressUpdated, headersReceived,
|
|
590
|
+
{
|
|
591
|
+
minBytesForProgressEvents: this.minBytesForProgressEvents_,
|
|
592
|
+
});
|
|
579
593
|
|
|
580
594
|
if (!progressSupport) {
|
|
581
595
|
return requestPlugin;
|
|
@@ -872,6 +886,12 @@ shaka.net.NetworkingEngine.AdvancedRequestType = {
|
|
|
872
886
|
'MPD': 4,
|
|
873
887
|
'MSS': 5,
|
|
874
888
|
'MPD_PATCH': 6,
|
|
889
|
+
'MEDIATAILOR_SESSION_INFO': 7,
|
|
890
|
+
'MEDIATAILOR_TRACKING_INFO': 8,
|
|
891
|
+
'MEDIATAILOR_STATIC_RESOURCE': 9,
|
|
892
|
+
'MEDIATAILOR_TRACKING_EVENT': 10,
|
|
893
|
+
'INTERSTITIAL_ASSET_LIST': 11,
|
|
894
|
+
'INTERSTITIAL_AD_URL': 12,
|
|
875
895
|
};
|
|
876
896
|
|
|
877
897
|
|
package/lib/offline/storage.js
CHANGED
|
@@ -1180,6 +1180,7 @@ shaka.offline.Storage = class {
|
|
|
1180
1180
|
getBandwidthEstimate: () => config.abr.defaultBandwidthEstimate,
|
|
1181
1181
|
onMetadata: () => {},
|
|
1182
1182
|
disableStream: (stream) => {},
|
|
1183
|
+
addFont: (name, url) => {},
|
|
1183
1184
|
};
|
|
1184
1185
|
|
|
1185
1186
|
parser.configure(config.manifest);
|