@gcorevideo/player 0.1.0 → 0.2.3
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/index.js +29198 -27398
- package/lib/Player.d.ts +8 -25
- package/lib/Player.d.ts.map +1 -1
- package/lib/Player.js +79 -131
- package/lib/backend.js +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/internal.types.d.ts +9 -2
- package/lib/internal.types.d.ts.map +1 -1
- package/lib/plugins/dash-playback/DashPlayback.d.ts.map +1 -1
- package/lib/plugins/dash-playback/DashPlayback.js +1 -11
- package/lib/plugins/hls-playback/HlsPlayback.d.ts.map +1 -1
- package/lib/plugins/hls-playback/HlsPlayback.js +5 -1
- package/lib/types.d.ts +16 -3
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +8 -1
- package/lib/utils/utils.d.ts +0 -4
- package/lib/utils/utils.d.ts.map +1 -1
- package/lib/utils/utils.js +0 -26
- package/lib/version.d.ts +5 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +8 -0
- package/package.json +2 -1
- package/rollup.config.js +3 -1
- package/src/Player.ts +89 -166
- package/src/backend.ts +2 -2
- package/src/index.ts +1 -0
- package/src/internal.types.ts +11 -3
- package/src/plugins/dash-playback/DashPlayback.ts +1 -11
- package/src/plugins/hls-playback/HlsPlayback.ts +7 -3
- package/src/types.ts +18 -6
- package/src/{xtypings → typings}/@clappr/core/player.d.ts +0 -7
- package/src/typings/@clappr/plugins.d.ts +23 -0
- package/src/utils/utils.ts +0 -26
- package/src/version.ts +9 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/utils/scripts-load.ts +0 -26
- /package/src/{xtypings → typings}/@clappr/core/error_mixin.d.ts +0 -0
- /package/src/{xtypings → typings}/@clappr/core/events.d.ts +0 -0
- /package/src/{xtypings → typings}/@clappr/core/html5_video.d.ts +0 -0
- /package/src/{xtypings → typings}/@clappr/core/playback.d.ts +0 -0
- /package/src/{xtypings → typings}/globals.d.ts +0 -0
package/lib/Player.d.ts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
+
import type { BitrateInfo, PlaybackType, PlayerPlugin } from "./types.js";
|
|
2
|
+
import { PlayerConfig, PlayerEvent } from "./types.js";
|
|
1
3
|
import '../assets/style/main.scss';
|
|
2
|
-
import type { PlayerPlugin } from "./types";
|
|
3
|
-
import { PlayerConfig } from "./types.js";
|
|
4
|
-
export declare enum PlayerEvent {
|
|
5
|
-
Ready = "ready",
|
|
6
|
-
Play = "play",
|
|
7
|
-
Pause = "pause",
|
|
8
|
-
Stop = "stop",
|
|
9
|
-
Ended = "ended"
|
|
10
|
-
}
|
|
11
4
|
type PlayerEventHandler<T extends PlayerEvent> = () => void;
|
|
12
5
|
export type PlaybackModule = 'dash' | 'hls' | 'native';
|
|
13
|
-
type BitrateInfo = {
|
|
14
|
-
height: number;
|
|
15
|
-
width: number;
|
|
16
|
-
bitrate: number;
|
|
17
|
-
level: number;
|
|
18
|
-
};
|
|
19
6
|
/**
|
|
20
7
|
* @beta
|
|
21
8
|
*/
|
|
@@ -26,17 +13,18 @@ export declare class Player {
|
|
|
26
13
|
private clapprReady;
|
|
27
14
|
private timer;
|
|
28
15
|
private tuneInEntered;
|
|
29
|
-
private supportedMediaTransports;
|
|
30
16
|
private config;
|
|
31
17
|
private bitrateInfo;
|
|
32
|
-
get
|
|
18
|
+
get activePlayback(): PlaybackModule | null;
|
|
33
19
|
get bitrate(): BitrateInfo | null;
|
|
34
20
|
get hd(): any;
|
|
21
|
+
get playbackType(): PlaybackType | undefined;
|
|
35
22
|
get playing(): boolean;
|
|
36
23
|
get ready(): boolean;
|
|
37
24
|
constructor(config: PlayerConfig);
|
|
38
25
|
on<T extends PlayerEvent>(event: T, handler: PlayerEventHandler<T>): void;
|
|
39
26
|
off<T extends PlayerEvent>(event: T, handler: PlayerEventHandler<T>): void;
|
|
27
|
+
configure(config: Partial<PlayerConfig>): void;
|
|
40
28
|
init(playerElement: HTMLElement): Promise<void>;
|
|
41
29
|
destroy(): void;
|
|
42
30
|
pause(): void;
|
|
@@ -44,19 +32,14 @@ export declare class Player {
|
|
|
44
32
|
seekTo(time: number): void;
|
|
45
33
|
stop(): void;
|
|
46
34
|
static registerPlugin(plugin: PlayerPlugin): void;
|
|
47
|
-
|
|
35
|
+
static unregisterPlugin(plugin: PlayerPlugin): void;
|
|
48
36
|
private initPlayer;
|
|
49
37
|
private tuneIn;
|
|
50
|
-
private configurePlugins;
|
|
51
38
|
private events;
|
|
52
39
|
private buildCoreOptions;
|
|
53
|
-
private
|
|
54
|
-
private scheduleLoad;
|
|
55
|
-
private selectMediaTransport;
|
|
56
|
-
private getAvailableTransportsPreference;
|
|
57
|
-
private checkMediaTransportsSupport;
|
|
58
|
-
private processMultisources;
|
|
40
|
+
private configurePlaybacks;
|
|
59
41
|
private bindBitrateChangeHandler;
|
|
42
|
+
private buildMediaSourcesList;
|
|
60
43
|
}
|
|
61
44
|
export {};
|
|
62
45
|
//# sourceMappingURL=Player.d.ts.map
|
package/lib/Player.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../src/Player.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../src/Player.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EAEb,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,YAAY,EACZ,WAAW,EACZ,MAAM,YAAY,CAAC;AAIpB,OAAO,2BAA2B,CAAC;AAInC,KAAK,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI,MAAM,IAAI,CAAC;AAU5D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AAIvD;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAA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, Log, Player as PlayerClappr, $, Loader, } from '@clappr/core';
|
|
1
|
+
import { Browser, Events as ClapprEvents, HTML5Video, Log, Player as PlayerClappr, $, Loader, } from '@clappr/core';
|
|
2
2
|
import assert from 'assert';
|
|
3
|
-
import Hls from 'hls.js';
|
|
4
3
|
import EventLite from "event-lite";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
4
|
+
import { reportError } from "./trace/index.js";
|
|
5
|
+
import { PlayerEvent, } from "./types.js";
|
|
7
6
|
import DashPlayback from './plugins/dash-playback/DashPlayback.js';
|
|
8
7
|
import HlsPlayback from './plugins/hls-playback/HlsPlayback.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
PlayerEvent["Ready"] = "ready";
|
|
12
|
-
PlayerEvent["Play"] = "play";
|
|
13
|
-
PlayerEvent["Pause"] = "pause";
|
|
14
|
-
PlayerEvent["Stop"] = "stop";
|
|
15
|
-
PlayerEvent["Ended"] = "ended";
|
|
16
|
-
})(PlayerEvent || (PlayerEvent = {}));
|
|
17
|
-
const T = "Player";
|
|
8
|
+
import '../assets/style/main.scss'; // TODO check if needed
|
|
9
|
+
const T = "GPlayer";
|
|
18
10
|
const DEFAULT_OPTIONS = {
|
|
19
11
|
autoPlay: false,
|
|
20
12
|
mute: false,
|
|
@@ -30,10 +22,9 @@ export class Player {
|
|
|
30
22
|
clapprReady = false;
|
|
31
23
|
timer = null;
|
|
32
24
|
tuneInEntered = false;
|
|
33
|
-
supportedMediaTransports = [];
|
|
34
25
|
config;
|
|
35
26
|
bitrateInfo = null;
|
|
36
|
-
get
|
|
27
|
+
get activePlayback() {
|
|
37
28
|
if (!this.player?.core.activePlayback) {
|
|
38
29
|
return null;
|
|
39
30
|
}
|
|
@@ -52,6 +43,9 @@ export class Player {
|
|
|
52
43
|
get hd() {
|
|
53
44
|
return this.player?.core.activePlayback?.isHighDefinitionInUse || false;
|
|
54
45
|
}
|
|
46
|
+
get playbackType() {
|
|
47
|
+
return this.player?.core.activePlayback?.getPlaybackType();
|
|
48
|
+
}
|
|
55
49
|
get playing() {
|
|
56
50
|
return this.player ? this.player.isPlaying() : false;
|
|
57
51
|
}
|
|
@@ -67,28 +61,30 @@ export class Player {
|
|
|
67
61
|
off(event, handler) {
|
|
68
62
|
this.emitter.off(event, handler);
|
|
69
63
|
}
|
|
64
|
+
configure(config) {
|
|
65
|
+
$.extend(true, this.config, config);
|
|
66
|
+
}
|
|
70
67
|
async init(playerElement) {
|
|
71
68
|
assert.ok(!this.player, 'Player already initialized');
|
|
72
|
-
assert.ok(playerElement, 'Player element is required');
|
|
69
|
+
assert.ok(playerElement, 'Player container element is required');
|
|
73
70
|
if (this.config.debug === 'all' ||
|
|
74
71
|
this.config.debug === 'clappr') {
|
|
75
72
|
Log.setLevel(0);
|
|
76
73
|
}
|
|
77
|
-
Log.debug('Config', this.config);
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
74
|
+
Log.debug(T, 'Config', this.config);
|
|
75
|
+
this.configurePlaybacks();
|
|
76
|
+
const coreOpts = this.buildCoreOptions(playerElement);
|
|
77
|
+
const { core, container, } = Loader.registeredPlugins;
|
|
78
|
+
coreOpts.plugins = {
|
|
79
|
+
core: Object.values(core),
|
|
80
|
+
container: Object.values(container),
|
|
81
|
+
playback: Loader.registeredPlaybacks,
|
|
82
|
+
};
|
|
83
|
+
Log.debug(T, 'coreOpts', coreOpts);
|
|
84
|
+
return this.initPlayer(coreOpts);
|
|
89
85
|
}
|
|
90
86
|
destroy() {
|
|
91
|
-
|
|
87
|
+
Log.debug(T, 'destroy', { player: !!this.player });
|
|
92
88
|
if (this.player) {
|
|
93
89
|
this.player.destroy();
|
|
94
90
|
this.player = null;
|
|
@@ -113,8 +109,8 @@ export class Player {
|
|
|
113
109
|
static registerPlugin(plugin) {
|
|
114
110
|
Loader.registerPlugin(plugin);
|
|
115
111
|
}
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
static unregisterPlugin(plugin) {
|
|
113
|
+
Loader.unregisterPlugin(plugin);
|
|
118
114
|
}
|
|
119
115
|
initPlayer(coreOptions) {
|
|
120
116
|
assert.ok(!this.player, 'Player already initialized');
|
|
@@ -138,7 +134,7 @@ export class Player {
|
|
|
138
134
|
// TODO sort this out
|
|
139
135
|
async tuneIn() {
|
|
140
136
|
assert.ok(this.player);
|
|
141
|
-
|
|
137
|
+
Log.debug(T, 'tuneIn enter', {
|
|
142
138
|
ready: this.clapprReady,
|
|
143
139
|
tuneInEntered: this.tuneInEntered,
|
|
144
140
|
});
|
|
@@ -157,7 +153,6 @@ export class Player {
|
|
|
157
153
|
this.bindBitrateChangeHandler();
|
|
158
154
|
}
|
|
159
155
|
player.core.on(ClapprEvents.CORE_ACTIVE_CONTAINER_CHANGED, () => {
|
|
160
|
-
trace(`${T} onActiveContainerChanged`);
|
|
161
156
|
this.bindBitrateChangeHandler();
|
|
162
157
|
}, null);
|
|
163
158
|
if (Browser.isiOS &&
|
|
@@ -172,28 +167,9 @@ export class Player {
|
|
|
172
167
|
});
|
|
173
168
|
}
|
|
174
169
|
}
|
|
175
|
-
configurePlugins() {
|
|
176
|
-
// TODO remove !isiOS?
|
|
177
|
-
const useDash = !Browser.isiOS && this.config.multisources.some((el) => el.sourceDash && DashPlayback.canPlay(el.sourceDash));
|
|
178
|
-
if (useDash) {
|
|
179
|
-
this.scheduleLoad(async () => {
|
|
180
|
-
const module = await import('./plugins/dash-playback/DashPlayback.js');
|
|
181
|
-
Loader.registerPlayback(module.default);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
// TODO remove !isiOS?
|
|
185
|
-
// if (!Browser.isiOS && this.config.multisources.some((el) => el.hls_mpegts_url)) {
|
|
186
|
-
const useHls = this.config.multisources.some((el) => HlsPlayback.canPlay(el.hlsCmafUrl || el.hlsMpegtsUrl || el.source));
|
|
187
|
-
if (useHls) {
|
|
188
|
-
this.scheduleLoad(async () => {
|
|
189
|
-
const module = await import('./plugins/hls-playback/HlsPlayback.js');
|
|
190
|
-
Loader.registerPlayback(module.default);
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
170
|
events = {
|
|
195
171
|
onReady: () => {
|
|
196
|
-
|
|
172
|
+
Log.debug(T, 'onReady', { clapprReady: this.clapprReady, player: !!this.player, core: !!this.player?.core, activeContainer: !!this.player?.core.activeContainer });
|
|
197
173
|
if (this.clapprReady) {
|
|
198
174
|
return;
|
|
199
175
|
}
|
|
@@ -203,9 +179,6 @@ export class Player {
|
|
|
203
179
|
clearTimeout(this.timer);
|
|
204
180
|
this.timer = null;
|
|
205
181
|
}
|
|
206
|
-
// trace(`${T} onReady`, {
|
|
207
|
-
// activeContainer: !!this.player?.core.activeContainer,
|
|
208
|
-
// });
|
|
209
182
|
setTimeout(() => this.tuneIn(), 0);
|
|
210
183
|
},
|
|
211
184
|
onPlay: () => {
|
|
@@ -242,19 +215,20 @@ export class Player {
|
|
|
242
215
|
},
|
|
243
216
|
};
|
|
244
217
|
buildCoreOptions(playerElement) {
|
|
245
|
-
this.
|
|
246
|
-
const
|
|
247
|
-
const mediaSources =
|
|
248
|
-
const
|
|
249
|
-
const mainSourceUrl = unwrapSource(mainSource ? this.selectMediaTransport(mainSource, this.config.priorityTransport) : undefined);
|
|
218
|
+
const multisources = this.config.multisources;
|
|
219
|
+
const mainSource = this.config.playbackType === 'live' ? multisources.find(ms => ms.live !== false) : multisources[0];
|
|
220
|
+
const mediaSources = mainSource ? this.buildMediaSourcesList(mainSource) : [];
|
|
221
|
+
const mainSourceUrl = mediaSources[0];
|
|
250
222
|
const poster = mainSource?.poster ?? this.config.poster;
|
|
251
223
|
const coreOptions = {
|
|
224
|
+
...this.config.pluginSettings,
|
|
252
225
|
autoPlay: this.config.autoPlay,
|
|
253
226
|
debug: this.config.debug || 'none',
|
|
254
227
|
events: this.events,
|
|
228
|
+
height: playerElement.clientHeight,
|
|
229
|
+
loop: this.config.loop,
|
|
255
230
|
multisources,
|
|
256
231
|
mute: this.config.mute,
|
|
257
|
-
...this.config.pluginSettings,
|
|
258
232
|
playback: {
|
|
259
233
|
controls: false,
|
|
260
234
|
preload: Browser.isiOS ? 'metadata' : 'none',
|
|
@@ -268,85 +242,59 @@ export class Player {
|
|
|
268
242
|
playbackType: this.config.playbackType,
|
|
269
243
|
poster,
|
|
270
244
|
width: playerElement.clientWidth,
|
|
271
|
-
height: playerElement.clientHeight,
|
|
272
|
-
loop: this.config.loop,
|
|
273
|
-
strings: this.config.strings,
|
|
274
245
|
source: mainSourceUrl,
|
|
275
246
|
sources: mediaSources,
|
|
247
|
+
strings: this.config.strings,
|
|
276
248
|
};
|
|
277
|
-
trace(`${T} buildCoreOptions`, coreOptions);
|
|
278
249
|
return coreOptions;
|
|
279
250
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
this.pluginLoaders.push(cb);
|
|
285
|
-
}
|
|
286
|
-
selectMediaTransport(ms, priorityTransport = ms.priorityTransport) {
|
|
287
|
-
const cmafUrl = ms.hlsCmafUrl || ms.source; // source is default url for hls
|
|
288
|
-
const mpegtsUrl = ms.hlsMpegtsUrl; // no-low-latency HLS
|
|
289
|
-
const dashUrl = ms.sourceDash;
|
|
290
|
-
const masterSource = ms.source;
|
|
291
|
-
const mts = this.getAvailableTransportsPreference(priorityTransport);
|
|
292
|
-
for (const mt of mts) {
|
|
293
|
-
switch (mt) {
|
|
294
|
-
case 'dash':
|
|
295
|
-
if (dashUrl) {
|
|
296
|
-
return dashUrl;
|
|
297
|
-
}
|
|
298
|
-
break;
|
|
299
|
-
case 'hls':
|
|
300
|
-
if (cmafUrl) {
|
|
301
|
-
return cmafUrl;
|
|
302
|
-
}
|
|
303
|
-
break;
|
|
304
|
-
default:
|
|
305
|
-
return mpegtsUrl || masterSource;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
// no supported transport found
|
|
309
|
-
return '';
|
|
310
|
-
}
|
|
311
|
-
getAvailableTransportsPreference(priorityTransport) {
|
|
312
|
-
const mtp = [];
|
|
313
|
-
if (priorityTransport !== 'auto' && this.supportedMediaTransports.includes(priorityTransport)) {
|
|
314
|
-
mtp.push(priorityTransport);
|
|
315
|
-
}
|
|
316
|
-
for (const mt of this.supportedMediaTransports) {
|
|
317
|
-
if (mt !== priorityTransport) {
|
|
318
|
-
mtp.push(mt);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return mtp;
|
|
322
|
-
}
|
|
323
|
-
checkMediaTransportsSupport() {
|
|
324
|
-
const isDashSupported = typeof (globalThis.MediaSource || globalThis.WebKitMediaSource) === 'function';
|
|
325
|
-
if (isDashSupported) {
|
|
326
|
-
this.supportedMediaTransports.push('dash');
|
|
327
|
-
}
|
|
328
|
-
if (Hls.isSupported()) {
|
|
329
|
-
this.supportedMediaTransports.push('hls');
|
|
330
|
-
}
|
|
331
|
-
this.supportedMediaTransports.push('mpegts');
|
|
332
|
-
}
|
|
333
|
-
processMultisources(transport) {
|
|
334
|
-
return this.config.multisources.map((ms) => ({
|
|
335
|
-
...ms,
|
|
336
|
-
source: this.selectMediaTransport(ms, transport),
|
|
337
|
-
})).filter((el) => !!el.source);
|
|
251
|
+
configurePlaybacks() {
|
|
252
|
+
Loader.registerPlayback(DashPlayback);
|
|
253
|
+
Loader.registerPlayback(HlsPlayback);
|
|
254
|
+
Loader.registerPlayback(HTML5Video);
|
|
338
255
|
}
|
|
339
256
|
bindBitrateChangeHandler() {
|
|
340
|
-
trace(`${T} bindBitrateChangeHandler`, { activePlayback: !!this.player?.core.activePlayback });
|
|
341
257
|
this.player?.core.activeContainer.on(ClapprEvents.CONTAINER_BITRATE, (bitrate) => {
|
|
342
|
-
trace(`${T} onPlaybackBitrate`, { bitrate });
|
|
343
258
|
this.bitrateInfo = bitrate;
|
|
344
259
|
});
|
|
345
260
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
261
|
+
buildMediaSourcesList(ms) {
|
|
262
|
+
const msl = [];
|
|
263
|
+
const sources = {
|
|
264
|
+
dash: ms.sourceDash,
|
|
265
|
+
master: ms.source,
|
|
266
|
+
hls: ms.hlsCmafUrl,
|
|
267
|
+
mpegts: ms.hlsMpegtsUrl,
|
|
268
|
+
};
|
|
269
|
+
switch (this.config.priorityTransport) {
|
|
270
|
+
case 'dash':
|
|
271
|
+
if (sources.dash) {
|
|
272
|
+
msl.push(sources.dash);
|
|
273
|
+
sources.dash = null;
|
|
274
|
+
}
|
|
275
|
+
break;
|
|
276
|
+
case 'hls':
|
|
277
|
+
if (sources.hls) {
|
|
278
|
+
msl.push(sources.hls);
|
|
279
|
+
sources.hls = null;
|
|
280
|
+
}
|
|
281
|
+
if (sources.master?.endsWith('.m3u8')) {
|
|
282
|
+
msl.push(sources.master);
|
|
283
|
+
sources.master = null;
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
case 'mpegts':
|
|
287
|
+
if (sources.mpegts) {
|
|
288
|
+
msl.push(sources.mpegts);
|
|
289
|
+
sources.mpegts = null;
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
Object.values(sources).forEach(s => {
|
|
294
|
+
if (s) {
|
|
295
|
+
msl.push(s);
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
return msl;
|
|
350
299
|
}
|
|
351
|
-
return typeof s === "string" ? s : s.source;
|
|
352
300
|
}
|
package/lib/backend.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export function fromStreamMediaSourceDto(s) {
|
|
2
2
|
return ({
|
|
3
3
|
...s,
|
|
4
|
-
hlsCmafUrl: s.hls_cmaf_url,
|
|
5
|
-
hlsMpegtsUrl: s.hls_mpegts_url,
|
|
4
|
+
hlsCmafUrl: s.hls_cmaf_url ?? null,
|
|
5
|
+
hlsMpegtsUrl: s.hls_mpegts_url ?? null,
|
|
6
6
|
priorityTransport: s.priority_transport,
|
|
7
7
|
sourceDash: s.source_dash,
|
|
8
8
|
vtt: s.vtt,
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/internal.types.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { CorePlugin, ContainerPlugin, Playback as
|
|
1
|
+
import type { CorePlugin, ContainerPlugin, Playback as ClapprPlayback } from "@clappr/core";
|
|
2
2
|
import { PlaybackType, PlayerDebugTag, StreamMediaSource } from "./types";
|
|
3
|
+
type ExternalTrack = {
|
|
4
|
+
kind?: "subtitles" | "captions";
|
|
5
|
+
src: string;
|
|
6
|
+
label: string;
|
|
7
|
+
lang: string;
|
|
8
|
+
};
|
|
3
9
|
type MediacontrolStyles = {
|
|
4
10
|
seekbar?: string;
|
|
5
11
|
buttons?: string;
|
|
@@ -54,10 +60,11 @@ export type CorePlayerEvents = {
|
|
|
54
60
|
export type ClapprVersionSpec = {
|
|
55
61
|
min: string;
|
|
56
62
|
};
|
|
63
|
+
export type PlaybackPluginFactory = typeof ClapprPlayback;
|
|
57
64
|
export type CorePluginOptions = {
|
|
58
65
|
core?: CorePlugin[];
|
|
59
66
|
container?: ContainerPlugin[];
|
|
60
|
-
playback?:
|
|
67
|
+
playback?: PlaybackPluginFactory[];
|
|
61
68
|
loadExternalPluginsFirst?: boolean;
|
|
62
69
|
loadExternalPlaybacksFirst?: boolean;
|
|
63
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.types.d.ts","sourceRoot":"","sources":["../src/internal.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,QAAQ,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"internal.types.d.ts","sourceRoot":"","sources":["../src/internal.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,QAAQ,IAAI,cAAc,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE1E,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAA;AAED,KAAK,kBAAkB,GAAG;IAExB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,qBAAqB,CAAC;AAE/D,KAAK,WAAW,GAAG;IACjB,K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AAS;IAI/B,cAAc,CAAC,UAAU,EAAE,MAAM;IAYjC,IAAI,CAAC,IAAI,EAAE,SAAS;IAWpB,eAAe;IAIf,UAAU,CAAC,MAAM,EAAE,OAAO;IAK1B,eAAe;IAcf,gBAAgB,UAAW,sBAAsB,UAEhD;IAED,eAAe,UAAW,cAAc,UA2FvC;IAED,aAAa;IAoBb,iBAAiB;IAWjB,IAAI,UAAU,YAGb;IAED,WAAW;IAmBX,IAAI;IASJ,KAAK;IAWL,IAAI;IASJ,OAAO;IAYP,mBAAmB;IAKnB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE;IAqJjC,OAAO,CAAC,aAAa;IASrB,eAAe;IAIf,aAAa;CAGd"}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { Events, HTML5Video, Log, Playback, /* PlayerError, */ Utils } from '@clappr/core';
|
|
5
5
|
import assert from 'assert'; // uses Node.js's assert types
|
|
6
6
|
import DASHJS from 'dashjs';
|
|
7
|
-
import { trace } from '../../trace/index.js';
|
|
8
7
|
const AUTO = -1;
|
|
9
8
|
const { now } = Utils;
|
|
10
9
|
const T = "DashPlayback";
|
|
@@ -166,7 +165,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
167
|
_setup() {
|
|
169
|
-
trace(`${T} _setup`, { el: this.el });
|
|
170
168
|
const dash = DASHJS.MediaPlayer().create();
|
|
171
169
|
this._dash = dash;
|
|
172
170
|
this._dash.initialize();
|
|
@@ -181,7 +179,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
181
179
|
this._dash.on(DASHJS.MediaPlayer.events.PLAYBACK_ERROR, this._onPlaybackError);
|
|
182
180
|
this._dash.on(DASHJS.MediaPlayer.events.STREAM_INITIALIZED, () => {
|
|
183
181
|
const bitrates = dash.getBitrateInfoListFor('video');
|
|
184
|
-
trace(`${T} STREAM_INITIALIZED`, { bitrates });
|
|
185
182
|
this._updatePlaybackType();
|
|
186
183
|
this._fillLevels(bitrates);
|
|
187
184
|
dash.on(DASHJS.MediaPlayer.events.QUALITY_CHANGE_REQUESTED, (evt) => {
|
|
@@ -452,7 +449,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
452
449
|
this.trigger(Events.PLAYBACK_PROGRESS, progress, {});
|
|
453
450
|
}
|
|
454
451
|
play() {
|
|
455
|
-
trace(`${T} play`, { dash: !!this._dash });
|
|
456
452
|
if (!this._dash) {
|
|
457
453
|
this._setup();
|
|
458
454
|
}
|
|
@@ -490,12 +486,8 @@ export default class DashPlayback extends HTML5Video {
|
|
|
490
486
|
_updatePlaybackType() {
|
|
491
487
|
assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to update the playback type');
|
|
492
488
|
this._playbackType = this._dash.isDynamic() ? Playback.LIVE : Playback.VOD;
|
|
493
|
-
trace(`${T} _updatePlaybackType`, {
|
|
494
|
-
playbackType: this._playbackType,
|
|
495
|
-
});
|
|
496
489
|
}
|
|
497
490
|
_fillLevels(levels) {
|
|
498
|
-
// trace(`${T} _fillLevels`, {levels});
|
|
499
491
|
// TOOD check that levels[i].qualityIndex === i
|
|
500
492
|
this._levels = levels.map((level) => {
|
|
501
493
|
return { id: level.qualityIndex, level: level };
|
|
@@ -628,7 +620,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
628
620
|
// this.trigger(Events.PLAYBACK_FRAGMENT_LOADED, data);
|
|
629
621
|
// }
|
|
630
622
|
onLevelSwitch(currentLevel) {
|
|
631
|
-
trace(`${T} onLevelSwitch`, { currentLevel });
|
|
632
623
|
this.trigger(Events.PLAYBACK_BITRATE, {
|
|
633
624
|
height: currentLevel.height,
|
|
634
625
|
width: currentLevel.width,
|
|
@@ -644,12 +635,11 @@ export default class DashPlayback extends HTML5Video {
|
|
|
644
635
|
}
|
|
645
636
|
}
|
|
646
637
|
DashPlayback.canPlay = function (resource, mimeType) {
|
|
647
|
-
trace(`${T} canPlay resource:%s mimeType:%s`, { resource, mimeType });
|
|
648
638
|
const resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
|
|
649
639
|
const isDash = ((resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'mpd') ||
|
|
650
640
|
mimeType === 'application/dash+xml' || mimeType === 'video/mp4');
|
|
651
641
|
const ctor = window.MediaSource || ('WebKitMediaSource' in window ? window.WebKitMediaSource : undefined);
|
|
652
642
|
const hasBrowserSupport = typeof ctor === 'function';
|
|
653
|
-
|
|
643
|
+
Log.debug(T, 'canPlay', { hasBrowserSupport, isDash });
|
|
654
644
|
return !!(hasBrowserSupport && isDash);
|
|
655
645
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HlsPlayback.d.ts","sourceRoot":"","sources":["../../../src/plugins/hls-playback/HlsPlayback.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,UAAU,EAAqC,MAAM,cAAc,CAAC;AAErF,OAAO,KAAK,EAAE,EACZ,SAAS,EAET,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAG5B,KAAK,kBAAkB,EACxB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"HlsPlayback.d.ts","sourceRoot":"","sources":["../../../src/plugins/hls-playback/HlsPlayback.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,UAAU,EAAqC,MAAM,cAAc,CAAC;AAErF,OAAO,KAAK,EAAE,EACZ,SAAS,EAET,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAG5B,KAAK,kBAAkB,EACxB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAyC3C,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,gBAAgB,CAA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AAE,kBAAkB;IAuBvE,IAAI,UAAU,YAMb;IAED,eAAe;IAIf,aAAa;CAGd"}
|
|
@@ -743,5 +743,9 @@ export default class HlsPlayback extends HTML5Video {
|
|
|
743
743
|
HlsPlayback.canPlay = function (resource, mimeType) {
|
|
744
744
|
const resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
|
|
745
745
|
const isHls = ((resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'm3u8') || listContainsIgnoreCase(mimeType, ['application/vnd.apple.mpegurl', 'application/x-mpegURL']));
|
|
746
|
-
|
|
746
|
+
const isSupported = HLSJS.isSupported();
|
|
747
|
+
Log.debug(T, 'canPlay', {
|
|
748
|
+
isSupported, isHls,
|
|
749
|
+
});
|
|
750
|
+
return !!(isSupported && isHls);
|
|
747
751
|
};
|
package/lib/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type MediaTransport = 'dash' | 'hls' | 'mpegts';
|
|
|
5
5
|
export type TransportPreference = MediaTransport | 'auto';
|
|
6
6
|
export type PlayerPlugin = {
|
|
7
7
|
new (...args: any[]): unknown;
|
|
8
|
-
type:
|
|
8
|
+
type: string;
|
|
9
9
|
};
|
|
10
10
|
export type PlayerConfig = {
|
|
11
11
|
autoPlay?: boolean;
|
|
@@ -61,8 +61,8 @@ export type StreamMediaSourceDto = {
|
|
|
61
61
|
export type StreamMediaSource = {
|
|
62
62
|
description: string;
|
|
63
63
|
dvr: boolean;
|
|
64
|
-
hlsCmafUrl
|
|
65
|
-
hlsMpegtsUrl
|
|
64
|
+
hlsCmafUrl: string | null;
|
|
65
|
+
hlsMpegtsUrl: string | null;
|
|
66
66
|
id: number;
|
|
67
67
|
live: boolean;
|
|
68
68
|
priorityTransport: TransportPreference;
|
|
@@ -78,5 +78,18 @@ export type StreamMediaSource = {
|
|
|
78
78
|
export type SrcProjectionType = 'regular' | '360' | 'vr180' | 'vr360tb';
|
|
79
79
|
export type ProjectionType = '360' | '180' | '360_TB';
|
|
80
80
|
export type TranslationSettings = Partial<Record<LangTag, Record<TranslationKey, string>>>;
|
|
81
|
+
export type BitrateInfo = {
|
|
82
|
+
height: number;
|
|
83
|
+
width: number;
|
|
84
|
+
bitrate: number;
|
|
85
|
+
level: number;
|
|
86
|
+
};
|
|
87
|
+
export declare enum PlayerEvent {
|
|
88
|
+
Ready = "ready",
|
|
89
|
+
Play = "play",
|
|
90
|
+
Pause = "pause",
|
|
91
|
+
Stop = "stop",
|
|
92
|
+
Ended = "ended"
|
|
93
|
+
}
|
|
81
94
|
export {};
|
|
82
95
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,OAAO,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;AAC1C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AACvD,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,MAAM,CAAC;AAE1D,MAAM,MAAM,YAAY,GAAG;IACzB,KAAI,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAC7B,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,OAAO,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;AAC1C,MAAM,MAAM,cAAc,GA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UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AACxE,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAE3F,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,KAAK,UAAU;IACf,IAAI,SAAS;IACb,KAAK,UAAU;CAChB"}
|
package/lib/types.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var PlayerEvent;
|
|
2
|
+
(function (PlayerEvent) {
|
|
3
|
+
PlayerEvent["Ready"] = "ready";
|
|
4
|
+
PlayerEvent["Play"] = "play";
|
|
5
|
+
PlayerEvent["Pause"] = "pause";
|
|
6
|
+
PlayerEvent["Stop"] = "stop";
|
|
7
|
+
PlayerEvent["Ended"] = "ended";
|
|
8
|
+
})(PlayerEvent || (PlayerEvent = {}));
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
export declare function getLocation(href: string): HTMLAnchorElement;
|
|
2
2
|
export declare function strtimeToMiliseconds(str: string): number;
|
|
3
|
-
export declare function isFullscreen(el: HTMLElement): boolean;
|
|
4
|
-
export declare const FullscreenIOS: {
|
|
5
|
-
isFullscreen: (el: HTMLVideoElement) => boolean;
|
|
6
|
-
};
|
|
7
3
|
//# sourceMappingURL=utils.d.ts.map
|