@gcorevideo/player 0.0.5 → 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 +44501 -1
- package/lib/Player.d.ts +13 -18
- package/lib/Player.d.ts.map +1 -1
- package/lib/Player.js +114 -124
- 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 +3 -16
- 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 +129 -137
- 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 +3 -16
- package/src/plugins/hls-playback/HlsPlayback.ts +7 -3
- package/src/types.ts +18 -6
- package/src/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/lib/Player.d.ts
CHANGED
|
@@ -1,14 +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;
|
|
5
|
+
export type PlaybackModule = 'dash' | 'hls' | 'native';
|
|
12
6
|
/**
|
|
13
7
|
* @beta
|
|
14
8
|
*/
|
|
@@ -19,13 +13,18 @@ export declare class Player {
|
|
|
19
13
|
private clapprReady;
|
|
20
14
|
private timer;
|
|
21
15
|
private tuneInEntered;
|
|
22
|
-
private supportedMediaTransports;
|
|
23
16
|
private config;
|
|
17
|
+
private bitrateInfo;
|
|
18
|
+
get activePlayback(): PlaybackModule | null;
|
|
19
|
+
get bitrate(): BitrateInfo | null;
|
|
20
|
+
get hd(): any;
|
|
21
|
+
get playbackType(): PlaybackType | undefined;
|
|
24
22
|
get playing(): boolean;
|
|
25
23
|
get ready(): boolean;
|
|
26
24
|
constructor(config: PlayerConfig);
|
|
27
25
|
on<T extends PlayerEvent>(event: T, handler: PlayerEventHandler<T>): void;
|
|
28
26
|
off<T extends PlayerEvent>(event: T, handler: PlayerEventHandler<T>): void;
|
|
27
|
+
configure(config: Partial<PlayerConfig>): void;
|
|
29
28
|
init(playerElement: HTMLElement): Promise<void>;
|
|
30
29
|
destroy(): void;
|
|
31
30
|
pause(): void;
|
|
@@ -33,18 +32,14 @@ export declare class Player {
|
|
|
33
32
|
seekTo(time: number): void;
|
|
34
33
|
stop(): void;
|
|
35
34
|
static registerPlugin(plugin: PlayerPlugin): void;
|
|
36
|
-
|
|
35
|
+
static unregisterPlugin(plugin: PlayerPlugin): void;
|
|
37
36
|
private initPlayer;
|
|
38
37
|
private tuneIn;
|
|
39
|
-
private configurePlugins;
|
|
40
38
|
private events;
|
|
41
39
|
private buildCoreOptions;
|
|
42
|
-
private
|
|
43
|
-
private
|
|
44
|
-
private
|
|
45
|
-
private getAvailableTransportsPreference;
|
|
46
|
-
private checkMediaTransportsSupport;
|
|
47
|
-
private processMultisources;
|
|
40
|
+
private configurePlaybacks;
|
|
41
|
+
private bindBitrateChangeHandler;
|
|
42
|
+
private buildMediaSourcesList;
|
|
48
43
|
}
|
|
49
44
|
export {};
|
|
50
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,CAAmB;IAElC,OAAO,CAAC,MAAM,CAA6B;IAE3C,OAAO,CAAC,aAAa,CAAkC;IAEvD,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,KAAK,CAA8C;IAE3D,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO,CAAC,WAAW,CAA4B;IAE/C,IAAI,cAAc,IAAI,cAAc,GAAG,IAAI,CAY1C;IAED,IAAI,OAAO,IAAI,WAAW,GAAG,IAAI,CAEhC;IAED,IAAI,EAAE,QAEL;IAED,IAAI,YAAY,IAAI,YAAY,GAAG,SAAS,CAE3C;IAED,IAAI,OAAO,YAEV;IAED,IAAI,KAAK,YAER;gBAGC,MAAM,EAAE,YAAY;IAKtB,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAIlE,GAAG,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAInE,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC;IAIjC,IAAI,CAAC,aAAa,EAAE,WAAW;IA2BrC,OAAO;IAQP,KAAK;IAKL,IAAI;IAKJ,MAAM,CAAC,IAAI,EAAE,MAAM;IAKnB,IAAI;IAKJ,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY;IAI1C,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,YAAY;IAI5C,OAAO,CAAC,UAAU;YA0BJ,MAAM;IAuCpB,OAAO,CAAC,MAAM,CA0CZ;IAEF,OAAO,CAAC,gBAAgB;IAoCxB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,qBAAqB;CAuC9B"}
|
package/lib/Player.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import { Browser, 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";
|
|
4
|
+
import { reportError } from "./trace/index.js";
|
|
5
|
+
import { PlayerEvent, } from "./types.js";
|
|
6
|
+
import DashPlayback from './plugins/dash-playback/DashPlayback.js';
|
|
7
|
+
import HlsPlayback from './plugins/hls-playback/HlsPlayback.js';
|
|
5
8
|
import '../assets/style/main.scss'; // TODO check if needed
|
|
6
|
-
|
|
7
|
-
export var PlayerEvent;
|
|
8
|
-
(function (PlayerEvent) {
|
|
9
|
-
PlayerEvent["Ready"] = "ready";
|
|
10
|
-
PlayerEvent["Play"] = "play";
|
|
11
|
-
PlayerEvent["Pause"] = "pause";
|
|
12
|
-
PlayerEvent["Stop"] = "stop";
|
|
13
|
-
PlayerEvent["Ended"] = "ended";
|
|
14
|
-
})(PlayerEvent || (PlayerEvent = {}));
|
|
15
|
-
const T = "Player";
|
|
9
|
+
const T = "GPlayer";
|
|
16
10
|
const DEFAULT_OPTIONS = {
|
|
17
11
|
autoPlay: false,
|
|
18
12
|
mute: false,
|
|
@@ -28,8 +22,30 @@ export class Player {
|
|
|
28
22
|
clapprReady = false;
|
|
29
23
|
timer = null;
|
|
30
24
|
tuneInEntered = false;
|
|
31
|
-
supportedMediaTransports = [];
|
|
32
25
|
config;
|
|
26
|
+
bitrateInfo = null;
|
|
27
|
+
get activePlayback() {
|
|
28
|
+
if (!this.player?.core.activePlayback) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
switch (this.player.core.activePlayback.name) {
|
|
32
|
+
case 'dash':
|
|
33
|
+
return 'dash';
|
|
34
|
+
case 'hls':
|
|
35
|
+
return 'hls';
|
|
36
|
+
default:
|
|
37
|
+
return 'native';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
get bitrate() {
|
|
41
|
+
return this.bitrateInfo;
|
|
42
|
+
}
|
|
43
|
+
get hd() {
|
|
44
|
+
return this.player?.core.activePlayback?.isHighDefinitionInUse || false;
|
|
45
|
+
}
|
|
46
|
+
get playbackType() {
|
|
47
|
+
return this.player?.core.activePlayback?.getPlaybackType();
|
|
48
|
+
}
|
|
33
49
|
get playing() {
|
|
34
50
|
return this.player ? this.player.isPlaying() : false;
|
|
35
51
|
}
|
|
@@ -45,29 +61,30 @@ export class Player {
|
|
|
45
61
|
off(event, handler) {
|
|
46
62
|
this.emitter.off(event, handler);
|
|
47
63
|
}
|
|
64
|
+
configure(config) {
|
|
65
|
+
$.extend(true, this.config, config);
|
|
66
|
+
}
|
|
48
67
|
async init(playerElement) {
|
|
49
68
|
assert.ok(!this.player, 'Player already initialized');
|
|
50
|
-
assert.ok(playerElement, 'Player element is required');
|
|
69
|
+
assert.ok(playerElement, 'Player container element is required');
|
|
51
70
|
if (this.config.debug === 'all' ||
|
|
52
71
|
this.config.debug === 'clappr') {
|
|
53
72
|
Log.setLevel(0);
|
|
54
73
|
}
|
|
55
|
-
Log.debug('Config', this.config);
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return this.initPlayer(coreOpts);
|
|
67
|
-
});
|
|
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);
|
|
68
85
|
}
|
|
69
86
|
destroy() {
|
|
70
|
-
|
|
87
|
+
Log.debug(T, 'destroy', { player: !!this.player });
|
|
71
88
|
if (this.player) {
|
|
72
89
|
this.player.destroy();
|
|
73
90
|
this.player = null;
|
|
@@ -92,8 +109,8 @@ export class Player {
|
|
|
92
109
|
static registerPlugin(plugin) {
|
|
93
110
|
Loader.registerPlugin(plugin);
|
|
94
111
|
}
|
|
95
|
-
|
|
96
|
-
|
|
112
|
+
static unregisterPlugin(plugin) {
|
|
113
|
+
Loader.unregisterPlugin(plugin);
|
|
97
114
|
}
|
|
98
115
|
initPlayer(coreOptions) {
|
|
99
116
|
assert.ok(!this.player, 'Player already initialized');
|
|
@@ -117,7 +134,7 @@ export class Player {
|
|
|
117
134
|
// TODO sort this out
|
|
118
135
|
async tuneIn() {
|
|
119
136
|
assert.ok(this.player);
|
|
120
|
-
|
|
137
|
+
Log.debug(T, 'tuneIn enter', {
|
|
121
138
|
ready: this.clapprReady,
|
|
122
139
|
tuneInEntered: this.tuneInEntered,
|
|
123
140
|
});
|
|
@@ -126,6 +143,18 @@ export class Player {
|
|
|
126
143
|
}
|
|
127
144
|
this.tuneInEntered = true;
|
|
128
145
|
const player = this.player;
|
|
146
|
+
try {
|
|
147
|
+
this.emitter.emit(PlayerEvent.Ready);
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
reportError(e);
|
|
151
|
+
}
|
|
152
|
+
if (player.core.activeContainer) {
|
|
153
|
+
this.bindBitrateChangeHandler();
|
|
154
|
+
}
|
|
155
|
+
player.core.on(ClapprEvents.CORE_ACTIVE_CONTAINER_CHANGED, () => {
|
|
156
|
+
this.bindBitrateChangeHandler();
|
|
157
|
+
}, null);
|
|
129
158
|
if (Browser.isiOS &&
|
|
130
159
|
player.core.activePlayback) {
|
|
131
160
|
player.core.activePlayback.$el.on('webkitendfullscreen', () => {
|
|
@@ -138,40 +167,19 @@ export class Player {
|
|
|
138
167
|
});
|
|
139
168
|
}
|
|
140
169
|
}
|
|
141
|
-
configurePlugins() {
|
|
142
|
-
if (!Browser.isiOS && this.config.multisources.some((el) => el.sourceDash)) {
|
|
143
|
-
this.scheduleLoad(async () => {
|
|
144
|
-
const module = await import('./plugins/dash-playback/DashPlayback.js');
|
|
145
|
-
Loader.registerPlayback(module.default);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
// TODO remove !isiOS?
|
|
149
|
-
// if (!Browser.isiOS && this.config.multisources.some((el) => el.hls_mpegts_url)) {
|
|
150
|
-
if (this.config.multisources.some((el) => el.hlsMpegtsUrl || el.hlsCmafUrl || el.source.endsWith('.m3u8'))) {
|
|
151
|
-
this.scheduleLoad(async () => {
|
|
152
|
-
const module = await import('./plugins/hls-playback/HlsPlayback.js');
|
|
153
|
-
Loader.registerPlayback(module.default);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
170
|
events = {
|
|
158
171
|
onReady: () => {
|
|
172
|
+
Log.debug(T, 'onReady', { clapprReady: this.clapprReady, player: !!this.player, core: !!this.player?.core, activeContainer: !!this.player?.core.activeContainer });
|
|
159
173
|
if (this.clapprReady) {
|
|
160
174
|
return;
|
|
161
175
|
}
|
|
162
176
|
this.clapprReady = true;
|
|
177
|
+
// TODO figure out what's for
|
|
163
178
|
if (this.timer) {
|
|
164
179
|
clearTimeout(this.timer);
|
|
165
180
|
this.timer = null;
|
|
166
181
|
}
|
|
167
|
-
trace(`${T} onReady`);
|
|
168
182
|
setTimeout(() => this.tuneIn(), 0);
|
|
169
|
-
try {
|
|
170
|
-
this.emitter.emit(PlayerEvent.Ready);
|
|
171
|
-
}
|
|
172
|
-
catch (e) {
|
|
173
|
-
reportError(e);
|
|
174
|
-
}
|
|
175
183
|
},
|
|
176
184
|
onPlay: () => {
|
|
177
185
|
try {
|
|
@@ -207,19 +215,20 @@ export class Player {
|
|
|
207
215
|
},
|
|
208
216
|
};
|
|
209
217
|
buildCoreOptions(playerElement) {
|
|
210
|
-
this.
|
|
211
|
-
const
|
|
212
|
-
const mediaSources =
|
|
213
|
-
const
|
|
214
|
-
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];
|
|
215
222
|
const poster = mainSource?.poster ?? this.config.poster;
|
|
216
223
|
const coreOptions = {
|
|
224
|
+
...this.config.pluginSettings,
|
|
217
225
|
autoPlay: this.config.autoPlay,
|
|
218
226
|
debug: this.config.debug || 'none',
|
|
219
227
|
events: this.events,
|
|
228
|
+
height: playerElement.clientHeight,
|
|
229
|
+
loop: this.config.loop,
|
|
220
230
|
multisources,
|
|
221
231
|
mute: this.config.mute,
|
|
222
|
-
...this.config.pluginSettings,
|
|
223
232
|
playback: {
|
|
224
233
|
controls: false,
|
|
225
234
|
preload: Browser.isiOS ? 'metadata' : 'none',
|
|
@@ -233,78 +242,59 @@ export class Player {
|
|
|
233
242
|
playbackType: this.config.playbackType,
|
|
234
243
|
poster,
|
|
235
244
|
width: playerElement.clientWidth,
|
|
236
|
-
height: playerElement.clientHeight,
|
|
237
|
-
loop: this.config.loop,
|
|
238
|
-
strings: this.config.strings,
|
|
239
245
|
source: mainSourceUrl,
|
|
240
246
|
sources: mediaSources,
|
|
247
|
+
strings: this.config.strings,
|
|
241
248
|
};
|
|
242
|
-
trace(`${T} buildCoreOptions`, coreOptions);
|
|
243
249
|
return coreOptions;
|
|
244
250
|
}
|
|
245
|
-
|
|
246
|
-
|
|
251
|
+
configurePlaybacks() {
|
|
252
|
+
Loader.registerPlayback(DashPlayback);
|
|
253
|
+
Loader.registerPlayback(HlsPlayback);
|
|
254
|
+
Loader.registerPlayback(HTML5Video);
|
|
247
255
|
}
|
|
248
|
-
|
|
249
|
-
this.
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const cmafUrl = ms.hlsCmafUrl || ms.source; // source is default url for hls
|
|
253
|
-
const mpegtsUrl = ms.hlsMpegtsUrl; // no-low-latency HLS
|
|
254
|
-
const dashUrl = ms.sourceDash;
|
|
255
|
-
const masterSource = ms.source;
|
|
256
|
-
const mts = this.getAvailableTransportsPreference(priorityTransport);
|
|
257
|
-
for (const mt of mts) {
|
|
258
|
-
switch (mt) {
|
|
259
|
-
case 'dash':
|
|
260
|
-
if (dashUrl) {
|
|
261
|
-
return dashUrl;
|
|
262
|
-
}
|
|
263
|
-
break;
|
|
264
|
-
case 'hls':
|
|
265
|
-
if (cmafUrl) {
|
|
266
|
-
return cmafUrl;
|
|
267
|
-
}
|
|
268
|
-
break;
|
|
269
|
-
default:
|
|
270
|
-
return mpegtsUrl || masterSource;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
// no supported transport found
|
|
274
|
-
return '';
|
|
256
|
+
bindBitrateChangeHandler() {
|
|
257
|
+
this.player?.core.activeContainer.on(ClapprEvents.CONTAINER_BITRATE, (bitrate) => {
|
|
258
|
+
this.bitrateInfo = bitrate;
|
|
259
|
+
});
|
|
275
260
|
}
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
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;
|
|
280
292
|
}
|
|
281
|
-
|
|
282
|
-
if (
|
|
283
|
-
|
|
293
|
+
Object.values(sources).forEach(s => {
|
|
294
|
+
if (s) {
|
|
295
|
+
msl.push(s);
|
|
284
296
|
}
|
|
285
|
-
}
|
|
286
|
-
return
|
|
287
|
-
}
|
|
288
|
-
checkMediaTransportsSupport() {
|
|
289
|
-
const isDashSupported = typeof (globalThis.MediaSource || globalThis.WebKitMediaSource) === 'function';
|
|
290
|
-
if (isDashSupported) {
|
|
291
|
-
this.supportedMediaTransports.push('dash');
|
|
292
|
-
}
|
|
293
|
-
if (Hls.isSupported()) {
|
|
294
|
-
this.supportedMediaTransports.push('hls');
|
|
295
|
-
}
|
|
296
|
-
this.supportedMediaTransports.push('mpegts');
|
|
297
|
-
}
|
|
298
|
-
processMultisources(transport) {
|
|
299
|
-
return this.config.multisources.map((ms) => ({
|
|
300
|
-
...ms,
|
|
301
|
-
source: this.selectMediaTransport(ms, transport),
|
|
302
|
-
})).filter((el) => !!el.source);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function unwrapSource(s) {
|
|
306
|
-
if (!s) {
|
|
307
|
-
return;
|
|
297
|
+
});
|
|
298
|
+
return msl;
|
|
308
299
|
}
|
|
309
|
-
return typeof s === "string" ? s : s.source;
|
|
310
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,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3C,KAAK,kBAAkB,GAAG;I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AAa;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) => {
|
|
@@ -193,13 +190,10 @@ export default class DashPlayback extends HTML5Video {
|
|
|
193
190
|
});
|
|
194
191
|
});
|
|
195
192
|
this._dash.on(DASHJS.MediaPlayer.events.METRIC_ADDED, (e) => {
|
|
196
|
-
// console.log(`${T} onMetricAdded`, e);
|
|
197
|
-
// TODO
|
|
198
193
|
// Listen for the first manifest request in order to update player UI
|
|
199
194
|
if (e.metric === 'DVRInfo') { // TODO fix typings
|
|
200
195
|
assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to get metrics');
|
|
201
196
|
const dvrInfo = this._dash.getDashMetrics().getCurrentDVRInfo('video');
|
|
202
|
-
// trace(`${T} onMetricAdded DVRInfo`, {metric: e.metric, dvrInfo});
|
|
203
197
|
if (dvrInfo) {
|
|
204
198
|
// Extract time info
|
|
205
199
|
this.manifestInfo = dvrInfo.manifestInfo;
|
|
@@ -455,7 +449,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
455
449
|
this.trigger(Events.PLAYBACK_PROGRESS, progress, {});
|
|
456
450
|
}
|
|
457
451
|
play() {
|
|
458
|
-
trace(`${T} play`, { dash: !!this._dash });
|
|
459
452
|
if (!this._dash) {
|
|
460
453
|
this._setup();
|
|
461
454
|
}
|
|
@@ -493,12 +486,8 @@ export default class DashPlayback extends HTML5Video {
|
|
|
493
486
|
_updatePlaybackType() {
|
|
494
487
|
assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to update the playback type');
|
|
495
488
|
this._playbackType = this._dash.isDynamic() ? Playback.LIVE : Playback.VOD;
|
|
496
|
-
trace(`${T} _updatePlaybackType`, {
|
|
497
|
-
playbackType: this._playbackType,
|
|
498
|
-
});
|
|
499
489
|
}
|
|
500
490
|
_fillLevels(levels) {
|
|
501
|
-
// trace(`${T} _fillLevels`, {levels});
|
|
502
491
|
// TOOD check that levels[i].qualityIndex === i
|
|
503
492
|
this._levels = levels.map((level) => {
|
|
504
493
|
return { id: level.qualityIndex, level: level };
|
|
@@ -631,7 +620,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
631
620
|
// this.trigger(Events.PLAYBACK_FRAGMENT_LOADED, data);
|
|
632
621
|
// }
|
|
633
622
|
onLevelSwitch(currentLevel) {
|
|
634
|
-
trace(`${T} onLevelSwitch`, { currentLevel });
|
|
635
623
|
this.trigger(Events.PLAYBACK_BITRATE, {
|
|
636
624
|
height: currentLevel.height,
|
|
637
625
|
width: currentLevel.width,
|
|
@@ -647,12 +635,11 @@ export default class DashPlayback extends HTML5Video {
|
|
|
647
635
|
}
|
|
648
636
|
}
|
|
649
637
|
DashPlayback.canPlay = function (resource, mimeType) {
|
|
650
|
-
console.log(`${T} canPlay resource:%s mimeType:%s`, resource, mimeType);
|
|
651
638
|
const resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
|
|
652
639
|
const isDash = ((resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'mpd') ||
|
|
653
640
|
mimeType === 'application/dash+xml' || mimeType === 'video/mp4');
|
|
654
641
|
const ctor = window.MediaSource || ('WebKitMediaSource' in window ? window.WebKitMediaSource : undefined);
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
return !!(
|
|
642
|
+
const hasBrowserSupport = typeof ctor === 'function';
|
|
643
|
+
Log.debug(T, 'canPlay', { hasBrowserSupport, isDash });
|
|
644
|
+
return !!(hasBrowserSupport && isDash);
|
|
658
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,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IAQJ,KAAK;IAUL,IAAI;IAQJ,OAAO;IAMP,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,eAAe;IAgIvB,kBAAkB,CAAC,GAAG,EAAE,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,eAAe;IAMrE,iBAAiB,CAAC,GAAG,EAAE,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,cAAc;IAIlE,iBAAiB;IAYjB,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,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
|