@gcorevideo/player 2.29.0 → 2.30.1
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 +108 -0
- package/dist/core.js +81 -22
- package/dist/index.css +370 -370
- package/dist/index.embed.js +80 -23
- package/dist/index.js +459 -87
- package/docs/api/player.md +37 -0
- package/docs/api/player.player.getplugin.md +59 -0
- package/docs/api/player.player.md +14 -0
- package/docs/api/player.tokenrefreshoptions.gettoken.md +13 -0
- package/docs/api/player.tokenrefreshoptions.ipbound.md +13 -0
- package/docs/api/player.tokenrefreshoptions.md +115 -0
- package/docs/api/player.tokenrefreshoptions.ontokenrefreshed.md +13 -0
- package/docs/api/player.tokenrefreshoptions.refreshleadseconds.md +13 -0
- package/docs/api/player.tokenrefreshplugin.md +50 -0
- package/docs/api/player.tokenresponse.client_ip.md +13 -0
- package/docs/api/player.tokenresponse.expires.md +13 -0
- package/docs/api/player.tokenresponse.md +153 -0
- package/docs/api/player.tokenresponse.token.md +13 -0
- package/docs/api/player.tokenresponse.token_ip.md +13 -0
- package/docs/api/player.tokenresponse.url.md +13 -0
- package/docs/api/player.tokenresponse.url_ip.md +13 -0
- package/lib/Player.d.ts +9 -0
- package/lib/Player.d.ts.map +1 -1
- package/lib/Player.js +11 -0
- package/lib/index.plugins.d.ts +1 -0
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +1 -0
- package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
- package/lib/playback/dash-playback/DashPlayback.js +5 -1
- package/lib/playback/hls-playback/HlsPlayback.d.ts +1 -1
- package/lib/playback/hls-playback/HlsPlayback.d.ts.map +1 -1
- package/lib/playback/hls-playback/HlsPlayback.js +23 -20
- package/lib/playback/hls-playback/RangesList.d.ts +7 -0
- package/lib/playback/hls-playback/RangesList.d.ts.map +1 -0
- package/lib/playback/hls-playback/RangesList.js +41 -0
- package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -1
- package/lib/plugins/subtitles/ClosedCaptions.js +0 -2
- package/lib/plugins/token-refresh/TokenRefreshPlugin.d.ts +119 -0
- package/lib/plugins/token-refresh/TokenRefreshPlugin.d.ts.map +1 -0
- package/lib/plugins/token-refresh/TokenRefreshPlugin.js +318 -0
- package/lib/plugins/token-refresh/index.d.ts +2 -0
- package/lib/plugins/token-refresh/index.d.ts.map +1 -0
- package/lib/plugins/token-refresh/index.js +1 -0
- package/package.json +1 -1
- package/src/Player.ts +12 -0
- package/src/index.plugins.ts +1 -0
- package/src/playback/dash-playback/DashPlayback.ts +6 -1
- package/src/playback/hls-playback/HlsPlayback.ts +40 -37
- package/src/playback/hls-playback/RangesList.ts +45 -0
- package/src/playback/hls-playback/__tests__/RangesList.test.ts +60 -0
- package/src/plugins/subtitles/ClosedCaptions.ts +0 -5
- package/src/plugins/token-refresh/TokenRefreshPlugin.ts +425 -0
- package/src/plugins/token-refresh/index.ts +5 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.embed.js
CHANGED
|
@@ -12830,6 +12830,7 @@ class DashPlayback extends BasePlayback {
|
|
|
12830
12830
|
this._dash = dash;
|
|
12831
12831
|
this._dash.initialize();
|
|
12832
12832
|
if (this.options.dash) {
|
|
12833
|
+
const { requestInterceptor, ...dashSettings } = this.options.dash;
|
|
12833
12834
|
const settings = $.extend(true, {
|
|
12834
12835
|
streaming: {
|
|
12835
12836
|
text: {
|
|
@@ -12841,8 +12842,11 @@ class DashPlayback extends BasePlayback {
|
|
|
12841
12842
|
// dispatchForManualRendering: true, // TODO only when useNativeSubtitles is not true?
|
|
12842
12843
|
},
|
|
12843
12844
|
},
|
|
12844
|
-
},
|
|
12845
|
+
}, dashSettings);
|
|
12845
12846
|
this._dash.updateSettings(settings);
|
|
12847
|
+
if (typeof requestInterceptor === 'function') {
|
|
12848
|
+
this._dash.addRequestInterceptor(requestInterceptor);
|
|
12849
|
+
}
|
|
12846
12850
|
}
|
|
12847
12851
|
this._dash.attachView(this.el);
|
|
12848
12852
|
this._dash.setAutoPlay(false);
|
|
@@ -49863,6 +49867,48 @@ Hls.defaultConfig = void 0;
|
|
|
49863
49867
|
// export const CLAPPR_VERSION: string = process.env.CLAPPR_VERSION || '0.11.3';
|
|
49864
49868
|
const CLAPPR_VERSION$1 = '0.13.0';
|
|
49865
49869
|
|
|
49870
|
+
class RangesList {
|
|
49871
|
+
// TODO write an efficient implementation
|
|
49872
|
+
items = [];
|
|
49873
|
+
insert(start, end, value) {
|
|
49874
|
+
const index = this.findIndex((start + end) / 2);
|
|
49875
|
+
this.items.splice(index, 0, [start, end, value]);
|
|
49876
|
+
}
|
|
49877
|
+
find(position) {
|
|
49878
|
+
const index = this.findIndex(position);
|
|
49879
|
+
const item = this.items[index];
|
|
49880
|
+
if (!item || item[0] > position || item[1] < position) {
|
|
49881
|
+
return null;
|
|
49882
|
+
}
|
|
49883
|
+
return item[2];
|
|
49884
|
+
}
|
|
49885
|
+
findIndex(position) {
|
|
49886
|
+
let low = 0;
|
|
49887
|
+
let high = this.items.length;
|
|
49888
|
+
let index = 0;
|
|
49889
|
+
while (low < high) {
|
|
49890
|
+
index = low + Math.floor((high - low) / 2);
|
|
49891
|
+
const item = this.items[index];
|
|
49892
|
+
if (item[0] > position) {
|
|
49893
|
+
if (index === low) {
|
|
49894
|
+
return index;
|
|
49895
|
+
}
|
|
49896
|
+
high = index;
|
|
49897
|
+
continue;
|
|
49898
|
+
}
|
|
49899
|
+
if (item[1] <= position) {
|
|
49900
|
+
if (index === high - 1) {
|
|
49901
|
+
return index + 1;
|
|
49902
|
+
}
|
|
49903
|
+
low = index + 1;
|
|
49904
|
+
continue;
|
|
49905
|
+
}
|
|
49906
|
+
break;
|
|
49907
|
+
}
|
|
49908
|
+
return index;
|
|
49909
|
+
}
|
|
49910
|
+
}
|
|
49911
|
+
|
|
49866
49912
|
// Copyright 2014 Globo.com Player authors. All rights reserved.
|
|
49867
49913
|
// Use of this source code is governed by a BSD-style
|
|
49868
49914
|
// license that can be found on https://github.com/clappr/hlsjs-playback/blob/main/LICENSE
|
|
@@ -49872,7 +49918,6 @@ const DEFAULT_RECOVER_ATTEMPTS = 16;
|
|
|
49872
49918
|
Events$1.register('PLAYBACK_FRAGMENT_PARSING_METADATA');
|
|
49873
49919
|
const T$7 = 'playback.hls';
|
|
49874
49920
|
class HlsPlayback extends BasePlayback {
|
|
49875
|
-
_ccTracksUpdated = false;
|
|
49876
49921
|
_currentFragment = null;
|
|
49877
49922
|
_currentLevel = null;
|
|
49878
49923
|
_durationExcludesAfterLiveSyncPoint = false;
|
|
@@ -49897,7 +49942,8 @@ class HlsPlayback extends BasePlayback {
|
|
|
49897
49942
|
_timeUpdateTimer = null;
|
|
49898
49943
|
oncueenter = null;
|
|
49899
49944
|
oncueexit = null;
|
|
49900
|
-
cues =
|
|
49945
|
+
cues = null;
|
|
49946
|
+
cuesByTrack = {};
|
|
49901
49947
|
currentCueId = null;
|
|
49902
49948
|
/**
|
|
49903
49949
|
* @internal
|
|
@@ -50094,7 +50140,6 @@ class HlsPlayback extends BasePlayback {
|
|
|
50094
50140
|
}
|
|
50095
50141
|
this._manifestParsed = false;
|
|
50096
50142
|
// this._ccIsSetup = false
|
|
50097
|
-
this._ccTracksUpdated = false;
|
|
50098
50143
|
this._setInitialState();
|
|
50099
50144
|
this._hls.destroy();
|
|
50100
50145
|
this._hls = null;
|
|
@@ -50148,12 +50193,20 @@ class HlsPlayback extends BasePlayback {
|
|
|
50148
50193
|
this._hls.on(Events.AUDIO_TRACK_SWITCHED, (evt, data) => this._onAudioTrackSwitched(evt, data));
|
|
50149
50194
|
this._hls.on(Events.CUES_PARSED, (evt, data) => {
|
|
50150
50195
|
data.cues?.forEach((cue) => {
|
|
50151
|
-
this.cues
|
|
50196
|
+
if (!this.cues) {
|
|
50197
|
+
const trackId = this._hls.subtitleTrack;
|
|
50198
|
+
if (!this.cuesByTrack[trackId]) {
|
|
50199
|
+
this.cuesByTrack[trackId] = new RangesList();
|
|
50200
|
+
}
|
|
50201
|
+
this.cues = this.cuesByTrack[trackId];
|
|
50202
|
+
}
|
|
50203
|
+
const cueInfo = {
|
|
50152
50204
|
id: cue.id,
|
|
50153
50205
|
start: cue.startTime,
|
|
50154
50206
|
end: cue.endTime,
|
|
50155
50207
|
text: cue.text,
|
|
50156
|
-
}
|
|
50208
|
+
};
|
|
50209
|
+
this.cues.insert(cue.startTime, cue.endTime, cueInfo);
|
|
50157
50210
|
});
|
|
50158
50211
|
});
|
|
50159
50212
|
this.bindCustomListeners();
|
|
@@ -50380,7 +50433,7 @@ class HlsPlayback extends BasePlayback {
|
|
|
50380
50433
|
}
|
|
50381
50434
|
}
|
|
50382
50435
|
reload() {
|
|
50383
|
-
this.cues =
|
|
50436
|
+
this.cues = null;
|
|
50384
50437
|
this.currentCueId = null;
|
|
50385
50438
|
this._hls?.startLoad(-1);
|
|
50386
50439
|
}
|
|
@@ -50445,9 +50498,7 @@ class HlsPlayback extends BasePlayback {
|
|
|
50445
50498
|
}
|
|
50446
50499
|
triggerCues() {
|
|
50447
50500
|
const currentTime = this.getCurrentTime();
|
|
50448
|
-
|
|
50449
|
-
// TODO build a search tree
|
|
50450
|
-
const cue = this.cues.find((cue) => currentTime >= cue.start && currentTime <= cue.end);
|
|
50501
|
+
const cue = this.cues?.find(currentTime);
|
|
50451
50502
|
if (cue) {
|
|
50452
50503
|
this.currentCueId = cue.id;
|
|
50453
50504
|
this.oncueenter?.(cue);
|
|
@@ -50490,20 +50541,14 @@ class HlsPlayback extends BasePlayback {
|
|
|
50490
50541
|
destroy() {
|
|
50491
50542
|
this._stopTimeUpdateTimer();
|
|
50492
50543
|
this._destroyHLSInstance();
|
|
50544
|
+
this.cues = null;
|
|
50545
|
+
this.cuesByTrack = {};
|
|
50493
50546
|
return super.destroy();
|
|
50494
50547
|
}
|
|
50495
50548
|
_updatePlaybackType(evt, data) {
|
|
50496
50549
|
const prevPlaybackType = this._playbackType;
|
|
50497
50550
|
this._playbackType = (data.details.live ? Playback.LIVE : Playback.VOD);
|
|
50498
50551
|
this._onLevelUpdated(evt, data);
|
|
50499
|
-
// Live stream subtitle tracks detection hack (may not immediately available)
|
|
50500
|
-
// if (
|
|
50501
|
-
// this._ccTracksUpdated &&
|
|
50502
|
-
// this._playbackType === Playback.LIVE &&
|
|
50503
|
-
// this.hasClosedCaptionsTracks
|
|
50504
|
-
// ) {
|
|
50505
|
-
// this._onSubtitleLoaded()
|
|
50506
|
-
// }
|
|
50507
50552
|
if (prevPlaybackType !== this._playbackType) {
|
|
50508
50553
|
this._updateSettings();
|
|
50509
50554
|
}
|
|
@@ -50723,7 +50768,10 @@ class HlsPlayback extends BasePlayback {
|
|
|
50723
50768
|
return;
|
|
50724
50769
|
}
|
|
50725
50770
|
this._hls.subtitleTrack = id;
|
|
50726
|
-
this.
|
|
50771
|
+
if (!this.cuesByTrack[id]) {
|
|
50772
|
+
this.cuesByTrack[id] = new RangesList();
|
|
50773
|
+
}
|
|
50774
|
+
this.cues = this.cuesByTrack[id];
|
|
50727
50775
|
}
|
|
50728
50776
|
/**
|
|
50729
50777
|
* @override
|
|
@@ -50732,7 +50780,7 @@ class HlsPlayback extends BasePlayback {
|
|
|
50732
50780
|
return this.getTextTracks();
|
|
50733
50781
|
}
|
|
50734
50782
|
getTextTracks() {
|
|
50735
|
-
return this._hls?.subtitleTracks.map((t) => ({
|
|
50783
|
+
return (this._hls?.subtitleTracks.map((t) => ({
|
|
50736
50784
|
id: t.id,
|
|
50737
50785
|
name: t.name,
|
|
50738
50786
|
track: {
|
|
@@ -50740,7 +50788,7 @@ class HlsPlayback extends BasePlayback {
|
|
|
50740
50788
|
label: t.name,
|
|
50741
50789
|
language: t.lang,
|
|
50742
50790
|
},
|
|
50743
|
-
})) || [];
|
|
50791
|
+
})) || []);
|
|
50744
50792
|
}
|
|
50745
50793
|
}
|
|
50746
50794
|
HlsPlayback.canPlay = function (resource, mimeType) {
|
|
@@ -51067,6 +51115,17 @@ class Player {
|
|
|
51067
51115
|
}
|
|
51068
51116
|
this.player?.load(ms, ms[0].mimeType ?? '');
|
|
51069
51117
|
}
|
|
51118
|
+
/**
|
|
51119
|
+
* Returns a registered core plugin instance by name, or `null` if not found.
|
|
51120
|
+
*
|
|
51121
|
+
* @example
|
|
51122
|
+
* ```ts
|
|
51123
|
+
* const tokenRefresh = player.getPlugin('token_refresh') as TokenRefreshPlugin | null
|
|
51124
|
+
* ```
|
|
51125
|
+
*/
|
|
51126
|
+
getPlugin(name) {
|
|
51127
|
+
return this.player?.core.getPlugin(name) ?? null;
|
|
51128
|
+
}
|
|
51070
51129
|
/**
|
|
51071
51130
|
* Mutes the sound of the video.
|
|
51072
51131
|
*/
|
|
@@ -58834,8 +58893,6 @@ class ClosedCaptions extends UICorePlugin {
|
|
|
58834
58893
|
// event.target does not exist for some reason in tests
|
|
58835
58894
|
const id = Number((event.target ?? event.currentTarget).dataset?.item ??
|
|
58836
58895
|
'-1');
|
|
58837
|
-
// TODO review, make configurable, and emit event in addition
|
|
58838
|
-
// localStorage.setItem(LOCAL_STORAGE_CC_ID, id) // TODO store language instead?
|
|
58839
58896
|
this.userSelectedItemId = id;
|
|
58840
58897
|
this.selectItem(this.findById(id));
|
|
58841
58898
|
this.hideMenu();
|