@gcorevideo/player 0.0.2 → 0.0.4
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/DashPlayback-BRJzl8D8.js +901 -0
- package/dist/{HlsPlayback-Avwy8-0O.js → HlsPlayback-D9EmONbV.js} +25 -27
- package/dist/index-C02TmVOf.js +41012 -0
- package/dist/index.js +1 -4
- package/package.json +1 -2
- package/rollup.config.js +1 -3
- package/dist/DashPlayback-6wKK0_pL.js +0 -666
- package/dist/DashPlayback-8U6_s4Jc.js +0 -666
- package/dist/DashPlayback-BeZz7mN9.js +0 -663
- package/dist/DashPlayback-CRdja67F.js +0 -667
- package/dist/DashPlayback-D0df6zGg.js +0 -663
- package/dist/DashPlayback-D7egS-CZ.js +0 -664
- package/dist/DashPlayback-DH5lZMRR.js +0 -663
- package/dist/DashPlayback-DZfIc9sK.js +0 -665
- package/dist/DashPlayback-VhCxbQhn.js +0 -666
- package/dist/DashPlayback-oVlZkeUP.js +0 -662
- package/dist/HlsPlayback-CYDGVQC4.js +0 -750
- package/dist/index-DTOY9tbl.js +0 -3332
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { HTML5Video, Playback, Events, Log, PlayerError, Utils } from '
|
|
2
|
-
import assert from 'assert';
|
|
3
|
-
import HLSJS from 'hls.js';
|
|
1
|
+
import { H as HTML5Video, P as Playback, E as Events, a as assert, b as Hls, L as Log, c as PlayerError, U as Utils } from './index-C02TmVOf.js';
|
|
4
2
|
|
|
5
3
|
// Copyright 2014 Globo.com Player authors. All rights reserved.
|
|
6
4
|
// Use of this source code is governed by a BSD-style
|
|
@@ -156,7 +154,7 @@ class HlsPlayback extends HTML5Video {
|
|
|
156
154
|
return currentTimestampInMs / 1000;
|
|
157
155
|
}
|
|
158
156
|
static get HLSJS() {
|
|
159
|
-
return
|
|
157
|
+
return Hls;
|
|
160
158
|
}
|
|
161
159
|
constructor(...args) {
|
|
162
160
|
// @ts-ignore
|
|
@@ -228,7 +226,7 @@ class HlsPlayback extends HTML5Video {
|
|
|
228
226
|
maxBufferLength: 2,
|
|
229
227
|
maxMaxBufferLength: 4,
|
|
230
228
|
};
|
|
231
|
-
this._hls = new
|
|
229
|
+
this._hls = new Hls(config);
|
|
232
230
|
}
|
|
233
231
|
_attachHLSMedia() {
|
|
234
232
|
if (!this._hls) {
|
|
@@ -240,7 +238,7 @@ class HlsPlayback extends HTML5Video {
|
|
|
240
238
|
if (!this._hls) {
|
|
241
239
|
return;
|
|
242
240
|
}
|
|
243
|
-
this._hls.once(
|
|
241
|
+
this._hls.once(Hls.Events.MEDIA_ATTACHED, () => {
|
|
244
242
|
assert.ok(this._hls, 'Hls.js instance is not available');
|
|
245
243
|
this.options.hlsPlayback.preload && this._hls.loadSource(this.options.src);
|
|
246
244
|
});
|
|
@@ -252,17 +250,17 @@ class HlsPlayback extends HTML5Video {
|
|
|
252
250
|
this.el.removeEventListener('playing', onPlaying);
|
|
253
251
|
};
|
|
254
252
|
this.el.addEventListener('playing', onPlaying);
|
|
255
|
-
this._hls.on(
|
|
256
|
-
this._hls.on(
|
|
257
|
-
this._hls.on(
|
|
258
|
-
this._hls.on(
|
|
259
|
-
this._hls.on(
|
|
260
|
-
this._hls.on(
|
|
261
|
-
this._hls.on(
|
|
262
|
-
this._hls.on(
|
|
253
|
+
this._hls.on(Hls.Events.MANIFEST_PARSED, () => this._manifestParsed = true);
|
|
254
|
+
this._hls.on(Hls.Events.LEVEL_LOADED, (evt, data) => this._updatePlaybackType(evt, data));
|
|
255
|
+
this._hls.on(Hls.Events.LEVEL_UPDATED, (evt, data) => this._onLevelUpdated(evt, data));
|
|
256
|
+
this._hls.on(Hls.Events.LEVEL_SWITCHING, (evt, data) => this._onLevelSwitch(evt, data));
|
|
257
|
+
this._hls.on(Hls.Events.FRAG_CHANGED, (evt, data) => this._onFragmentChanged(evt, data));
|
|
258
|
+
this._hls.on(Hls.Events.FRAG_LOADED, (evt, data) => this._onFragmentLoaded(evt, data));
|
|
259
|
+
this._hls.on(Hls.Events.FRAG_PARSING_METADATA, (evt, data) => this._onFragmentParsingMetadata(evt, data));
|
|
260
|
+
this._hls.on(Hls.Events.ERROR, (evt, data) => this._onHLSJSError(evt, data));
|
|
263
261
|
// this._hls.on(HLSJS.Events.SUBTITLE_TRACK_LOADED, (evt, data) => this._onSubtitleLoaded(evt, data));
|
|
264
|
-
this._hls.on(
|
|
265
|
-
this._hls.on(
|
|
262
|
+
this._hls.on(Hls.Events.SUBTITLE_TRACK_LOADED, () => this._onSubtitleLoaded());
|
|
263
|
+
this._hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED, () => this._ccTracksUpdated = true);
|
|
266
264
|
this.bindCustomListeners();
|
|
267
265
|
}
|
|
268
266
|
bindCustomListeners() {
|
|
@@ -408,16 +406,16 @@ class HlsPlayback extends HTML5Video {
|
|
|
408
406
|
if (this._recoverAttemptsRemaining > 0) {
|
|
409
407
|
this._recoverAttemptsRemaining -= 1;
|
|
410
408
|
switch (data.type) {
|
|
411
|
-
case
|
|
409
|
+
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
412
410
|
switch (data.details) {
|
|
413
411
|
// The following network errors cannot be recovered with HLS.startLoad()
|
|
414
412
|
// For more details, see https://github.com/video-dev/hls.js/blob/master/doc/design.md#error-detection-and-handling
|
|
415
413
|
// For "level load" fatal errors, see https://github.com/video-dev/hls.js/issues/1138
|
|
416
|
-
case
|
|
417
|
-
case
|
|
418
|
-
case
|
|
419
|
-
case
|
|
420
|
-
case
|
|
414
|
+
case Hls.ErrorDetails.MANIFEST_LOAD_ERROR:
|
|
415
|
+
case Hls.ErrorDetails.MANIFEST_LOAD_TIMEOUT:
|
|
416
|
+
case Hls.ErrorDetails.MANIFEST_PARSING_ERROR:
|
|
417
|
+
case Hls.ErrorDetails.LEVEL_LOAD_ERROR:
|
|
418
|
+
case Hls.ErrorDetails.LEVEL_LOAD_TIMEOUT:
|
|
421
419
|
Log.error('hlsjs: unrecoverable network fatal error.', { evt, data });
|
|
422
420
|
formattedError = this.createError(error);
|
|
423
421
|
this.trigger(Events.PLAYBACK_ERROR, formattedError);
|
|
@@ -431,7 +429,7 @@ class HlsPlayback extends HTML5Video {
|
|
|
431
429
|
break;
|
|
432
430
|
}
|
|
433
431
|
break;
|
|
434
|
-
case
|
|
432
|
+
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
435
433
|
Log.warn('hlsjs: trying to recover from media error.', { evt, data });
|
|
436
434
|
error.level = PlayerError.Levels.WARN;
|
|
437
435
|
this._recover(evt, data, error);
|
|
@@ -468,8 +466,8 @@ class HlsPlayback extends HTML5Video {
|
|
|
468
466
|
}
|
|
469
467
|
}
|
|
470
468
|
_keyIsDenied(data) {
|
|
471
|
-
return data.type ===
|
|
472
|
-
&& data.details ===
|
|
469
|
+
return data.type === Hls.ErrorTypes.NETWORK_ERROR
|
|
470
|
+
&& data.details === Hls.ErrorDetails.KEY_LOAD_ERROR
|
|
473
471
|
&& data.response
|
|
474
472
|
&& data.response.code
|
|
475
473
|
&& data.response.code >= 400;
|
|
@@ -624,7 +622,7 @@ class HlsPlayback extends HTML5Video {
|
|
|
624
622
|
if (this._playbackType === Playback.LIVE) {
|
|
625
623
|
const fragmentTargetDuration = data.details.targetduration;
|
|
626
624
|
const hlsjsConfig = this.options.playback.hlsjsConfig || {};
|
|
627
|
-
const liveSyncDurationCount = hlsjsConfig.liveSyncDurationCount ||
|
|
625
|
+
const liveSyncDurationCount = hlsjsConfig.liveSyncDurationCount || Hls.DefaultConfig.liveSyncDurationCount;
|
|
628
626
|
const hiddenAreaDuration = fragmentTargetDuration * liveSyncDurationCount;
|
|
629
627
|
if (hiddenAreaDuration <= newDuration) {
|
|
630
628
|
newDuration -= hiddenAreaDuration;
|
|
@@ -743,7 +741,7 @@ class HlsPlayback extends HTML5Video {
|
|
|
743
741
|
HlsPlayback.canPlay = function (resource, mimeType) {
|
|
744
742
|
const resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
|
|
745
743
|
const isHls = ((resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'm3u8') || listContainsIgnoreCase(mimeType, ['application/vnd.apple.mpegurl', 'application/x-mpegURL']));
|
|
746
|
-
return !!(
|
|
744
|
+
return !!(Hls.isSupported() && isHls);
|
|
747
745
|
};
|
|
748
746
|
|
|
749
747
|
export { HlsPlayback as default };
|