@gcorevideo/player 2.16.17 → 2.18.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 +68 -19
- package/dist/index.js +272 -125
- package/dist/player.d.ts +230 -73
- package/docs/api/index.md +1 -1
- package/docs/api/player.containersize.md +19 -0
- package/docs/api/player.dashsettings.md +2 -0
- package/docs/api/player.errorlevel.md +1 -0
- package/docs/api/player.langtag.md +6 -0
- package/docs/api/player.md +59 -24
- package/docs/api/player.mediatransport.md +1 -0
- package/docs/api/player.playbackerror.code.md +2 -0
- package/docs/api/player.playbackerror.description.md +2 -0
- package/docs/api/player.playbackerror.level.md +2 -0
- package/docs/api/player.playbackerror.md +43 -4
- package/docs/api/player.playbackerror.message.md +2 -0
- package/docs/api/player.playbackerror.origin.md +21 -0
- package/docs/api/player.playbackerror.scope.md +16 -0
- package/docs/api/player.playbackerrorcode.md +8 -7
- package/docs/api/player.playbackmodule.md +1 -0
- package/docs/api/player.player.attachto.md +26 -0
- package/docs/api/player.player.configure.md +6 -2
- package/docs/api/player.player.destroy.md +1 -1
- package/docs/api/player.player.getcurrenttime.md +6 -2
- package/docs/api/player.player.getduration.md +4 -0
- package/docs/api/player.player.getvolume.md +22 -0
- package/docs/api/player.player.isdvrenabled.md +20 -0
- package/docs/api/player.player.isdvrinuse.md +24 -0
- package/docs/api/player.player.isplaying.md +20 -0
- package/docs/api/player.player.md +76 -8
- package/docs/api/player.player.mute.md +1 -1
- package/docs/api/player.player.off.md +5 -5
- package/docs/api/player.player.on.md +5 -5
- package/docs/api/player.player.registerplugin.md +14 -1
- package/docs/api/player.player.resize.md +6 -5
- package/docs/api/player.player.seek.md +1 -1
- package/docs/api/player.player.setvolume.md +56 -0
- package/docs/api/player.player.unmute.md +1 -1
- package/docs/api/player.player.unregisterplugin.md +2 -2
- package/docs/api/player.playercomponenttype.md +16 -0
- package/docs/api/player.playerdebugsettings.md +1 -1
- package/docs/api/player.playerdebugtag.md +1 -0
- package/docs/api/player.playerevent.md +96 -0
- package/docs/api/player.playereventhandler.md +3 -2
- package/docs/api/player.playereventparams.md +20 -0
- package/docs/api/player.playermediasourcedesc.md +1 -1
- package/docs/api/player.playermediasourcedesc.mimetype.md +1 -1
- package/docs/api/player.qualitylevel.bitrate.md +16 -0
- package/docs/api/player.qualitylevel.height.md +16 -0
- package/docs/api/player.qualitylevel.level.md +16 -0
- package/docs/api/player.qualitylevel.md +104 -7
- package/docs/api/player.qualitylevel.width.md +16 -0
- package/docs/api/player.timeposition.current.md +16 -0
- package/docs/api/player.timeposition.md +65 -7
- package/docs/api/player.timeposition.total.md +16 -0
- package/docs/api/player.timevalue.md +1 -1
- package/docs/api/player.translationsettings.md +7 -1
- package/docs/api/player.transportpreference.md +1 -0
- package/lib/Player.d.ts +107 -26
- package/lib/Player.d.ts.map +1 -1
- package/lib/Player.js +161 -77
- package/lib/index.d.ts +2 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -3
- package/lib/internal.types.d.ts +3 -5
- package/lib/internal.types.d.ts.map +1 -1
- package/lib/playback/dash-playback/DashPlayback.d.ts +2 -0
- package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
- package/lib/playback/dash-playback/DashPlayback.js +37 -25
- package/lib/playback/hls-playback/HlsPlayback.d.ts +3 -0
- package/lib/playback/hls-playback/HlsPlayback.d.ts.map +1 -1
- package/lib/playback/hls-playback/HlsPlayback.js +33 -18
- package/lib/playback.types.d.ts +65 -6
- package/lib/playback.types.d.ts.map +1 -1
- package/lib/playback.types.js +10 -0
- package/lib/types.d.ts +54 -5
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +31 -2
- package/package.json +1 -1
- package/rollup.config.js +1 -1
- package/src/Player.ts +202 -91
- package/src/__tests__/Player.test.ts +9 -3
- package/src/index.ts +2 -3
- package/src/internal.types.ts +3 -2
- package/src/playback/dash-playback/DashPlayback.ts +64 -35
- package/src/playback/hls-playback/HlsPlayback.ts +46 -22
- package/src/playback.types.ts +65 -5
- package/src/types.ts +56 -6
- package/src/utils/__tests__/mediaSources.test.ts +8 -2
- package/temp/player.api.json +771 -106
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/DashPlayback-BRJzl8D8.js +0 -901
package/lib/Player.js
CHANGED
|
@@ -18,11 +18,11 @@ const DEFAULT_OPTIONS = {
|
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* The main component to use in the application code.
|
|
21
|
+
* @beta
|
|
21
22
|
* @remarks
|
|
22
23
|
* The Player object provides very basic API to control playback.
|
|
23
24
|
* To build a sophisticated UI, use the plugins framework to tap into the Clappr core.
|
|
24
25
|
* {@link https://github.com/clappr/clappr/wiki/Architecture}
|
|
25
|
-
* @beta
|
|
26
26
|
*/
|
|
27
27
|
export class Player {
|
|
28
28
|
config = DEFAULT_OPTIONS;
|
|
@@ -40,16 +40,16 @@ export class Player {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Adds a listener to a player event
|
|
43
|
-
* @param event -
|
|
44
|
-
* @param handler -
|
|
43
|
+
* @param event - event type, see {@link PlayerEvent}
|
|
44
|
+
* @param handler - a callback function to handle the event
|
|
45
45
|
*/
|
|
46
46
|
on(event, handler) {
|
|
47
47
|
this.emitter.on(event, handler);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Removes a
|
|
50
|
+
* Removes a previously added event listener
|
|
51
51
|
* @param event - See {@link PlayerEvent}
|
|
52
|
-
* @param handler -
|
|
52
|
+
* @param handler - a callback attached earlier to that event type
|
|
53
53
|
*/
|
|
54
54
|
off(event, handler) {
|
|
55
55
|
this.emitter.off(event, handler);
|
|
@@ -57,10 +57,12 @@ export class Player {
|
|
|
57
57
|
/**
|
|
58
58
|
* Configures the player.
|
|
59
59
|
*
|
|
60
|
-
* Can be called multiple times. Each consequent call extends the previous configuration.
|
|
61
|
-
* After a reconfiguration, if something significant has changed, the must be reinitialized (i.e, a `.destroy()` followed by an `.init()` call).
|
|
62
|
-
*
|
|
63
60
|
* @param config - complete or partial configuration
|
|
61
|
+
* @remarks
|
|
62
|
+
* Can be called multiple times.
|
|
63
|
+
* Each consequent call extends the previous configuration with only the new keys overridden.
|
|
64
|
+
*
|
|
65
|
+
* After a reconfiguration, if something significant has changed, it might make sense reinitialize the player (i.e, a `.destroy()` followed by an `.init()` call).
|
|
64
66
|
*/
|
|
65
67
|
configure(config) {
|
|
66
68
|
this.setConfig(config);
|
|
@@ -68,6 +70,29 @@ export class Player {
|
|
|
68
70
|
/**
|
|
69
71
|
* Initializes the player at the given container element.
|
|
70
72
|
* @param playerElement - DOM element to host the player
|
|
73
|
+
* @remarks
|
|
74
|
+
* The player will be initialized and attached to the given element.
|
|
75
|
+
*
|
|
76
|
+
* All the core plugins will be initialized at this point.
|
|
77
|
+
*
|
|
78
|
+
* If no sources were configured, it will trigger an error.
|
|
79
|
+
*
|
|
80
|
+
* The player container will be initialized and then all the registered UI plugins.
|
|
81
|
+
*
|
|
82
|
+
* If the `autoPlay` option is set, then it will trigger playback immediately.
|
|
83
|
+
*
|
|
84
|
+
* It is an error to call this method twice. If you need to attache player to another DOM element,
|
|
85
|
+
* first call {@link Player.destroy} and then {@link Player.attachTo}.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const player = new Player({
|
|
90
|
+
* sources: [{ source: 'https://example.com/a.mpd', mimeType: 'application/dash+xml' }],
|
|
91
|
+
* })
|
|
92
|
+
* document.addEventListener('DOMContentLoaded', () => {
|
|
93
|
+
* player.attachTo(document.getElementById('video-container'))
|
|
94
|
+
* })
|
|
95
|
+
* ```
|
|
71
96
|
*/
|
|
72
97
|
attachTo(playerElement) {
|
|
73
98
|
assert.ok(!this.player, 'Player already initialized');
|
|
@@ -88,7 +113,7 @@ export class Player {
|
|
|
88
113
|
return this.initPlayer(coreOpts);
|
|
89
114
|
}
|
|
90
115
|
/**
|
|
91
|
-
* Destroys the player, releasing all resources and
|
|
116
|
+
* Destroys the player, releasing all resources and unmounting its UI from the DOM.
|
|
92
117
|
*/
|
|
93
118
|
destroy() {
|
|
94
119
|
trace(`${T} destroy`, {
|
|
@@ -106,8 +131,11 @@ export class Player {
|
|
|
106
131
|
}
|
|
107
132
|
}
|
|
108
133
|
/**
|
|
109
|
-
* Current playback time
|
|
110
|
-
*
|
|
134
|
+
* Current playback (time since the beginning of the stream), if appropriate.
|
|
135
|
+
*
|
|
136
|
+
* @returns Time in seconds
|
|
137
|
+
* @remarks
|
|
138
|
+
* For live streams, it returns the current time within the current segment.
|
|
111
139
|
*/
|
|
112
140
|
getCurrentTime() {
|
|
113
141
|
if (!this.player) {
|
|
@@ -117,7 +145,10 @@ export class Player {
|
|
|
117
145
|
}
|
|
118
146
|
/**
|
|
119
147
|
* Duration of the current media in seconds, if appropriate.
|
|
120
|
-
*
|
|
148
|
+
*
|
|
149
|
+
* @returns Time in seconds
|
|
150
|
+
* @remarks
|
|
151
|
+
* For live streams, it returns the duration of the current segment.
|
|
121
152
|
*/
|
|
122
153
|
getDuration() {
|
|
123
154
|
if (!this.player) {
|
|
@@ -126,13 +157,33 @@ export class Player {
|
|
|
126
157
|
return this.player.getDuration();
|
|
127
158
|
}
|
|
128
159
|
/**
|
|
129
|
-
*
|
|
160
|
+
* Indicates whether DVR is enabled.
|
|
161
|
+
*/
|
|
162
|
+
isDvrEnabled() {
|
|
163
|
+
return this.player?.isDvrEnabled() ?? false;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Indicates whether DVR is in use.
|
|
167
|
+
* @remarks
|
|
168
|
+
* DVR mode, if it is enabled, is triggered we a user seeks behind the live edge.
|
|
169
|
+
*/
|
|
170
|
+
isDvrInUse() {
|
|
171
|
+
return this.player?.isDvrInUse() ?? false;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Indicates the playing state.
|
|
175
|
+
*/
|
|
176
|
+
isPlaying() {
|
|
177
|
+
return this.player?.isPlaying() ?? false;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Mutes the sound of the video.
|
|
130
181
|
*/
|
|
131
182
|
mute() {
|
|
132
183
|
this.player?.mute();
|
|
133
184
|
}
|
|
134
185
|
/**
|
|
135
|
-
* Unmutes the
|
|
186
|
+
* Unmutes the video sound.
|
|
136
187
|
*/
|
|
137
188
|
unmute() {
|
|
138
189
|
this.player?.unmute();
|
|
@@ -152,17 +203,38 @@ export class Player {
|
|
|
152
203
|
/**
|
|
153
204
|
* Resizes the player container element and everything within it.
|
|
154
205
|
* @param newSize - new size of the player
|
|
206
|
+
* @remarks
|
|
207
|
+
* Use this method when the player itself does not detect properly the change in size of its container element.
|
|
208
|
+
* It can be a case for orientation change on some mobile devices.
|
|
155
209
|
*/
|
|
156
210
|
resize(newSize) {
|
|
157
211
|
this.player?.resize(newSize);
|
|
158
212
|
}
|
|
159
213
|
/**
|
|
160
214
|
* Seeks to the given time.
|
|
161
|
-
* @param time - time to seek to in seconds
|
|
215
|
+
* @param time - time to seek to in seconds (since the beginning of the stream)
|
|
162
216
|
*/
|
|
163
217
|
seek(time) {
|
|
164
218
|
this.player?.seek(time);
|
|
165
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Gets the current volume of the media content being played.
|
|
222
|
+
* @returns a number between 0 and 1
|
|
223
|
+
*/
|
|
224
|
+
getVolume() {
|
|
225
|
+
// This method is provided by the MediaControl plugin
|
|
226
|
+
// @ts-ignore
|
|
227
|
+
return this.player?.getVolume?.() || 0;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Sets the current volume of the media content being played.
|
|
231
|
+
* @param volume - a number between 0 and 1
|
|
232
|
+
*/
|
|
233
|
+
setVolume(volume) {
|
|
234
|
+
// This method is provided by the MediaControl plugin
|
|
235
|
+
// @ts-ignore
|
|
236
|
+
this.player?.setVolume?.(volume);
|
|
237
|
+
}
|
|
166
238
|
/**
|
|
167
239
|
* Stops playback.
|
|
168
240
|
*/
|
|
@@ -171,14 +243,27 @@ export class Player {
|
|
|
171
243
|
}
|
|
172
244
|
/**
|
|
173
245
|
* Registers a plugin.
|
|
174
|
-
* @param plugin - plugin
|
|
246
|
+
* @param plugin - a plugin class
|
|
247
|
+
* @remarks
|
|
248
|
+
* Use this method to extend the player with custom behavior.
|
|
249
|
+
* The plugin class must inherit from one of the Clappr UIPlugin, UIContainerPlugin or CorePlugin classes.
|
|
250
|
+
* A core plugin will be initialized and attached to the player when the player is initialized.
|
|
251
|
+
* A UI plugin will be initialized and attached to the player container is initialized.
|
|
252
|
+
*
|
|
253
|
+
* @see {@link https://github.com/clappr/clappr/wiki/Architecture}
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* import MyPlugin from './MyPlugin.js'
|
|
257
|
+
*
|
|
258
|
+
* Player.registerPlugin(MyPlugin)
|
|
259
|
+
* ```
|
|
175
260
|
*/
|
|
176
261
|
static registerPlugin(plugin) {
|
|
177
262
|
Loader.registerPlugin(plugin);
|
|
178
263
|
}
|
|
179
264
|
/**
|
|
180
|
-
* Unregisters a plugin.
|
|
181
|
-
* @param plugin - plugin
|
|
265
|
+
* Unregisters a plugin registered earlier with {@link Player.registerPlugin}.
|
|
266
|
+
* @param plugin - a plugin class
|
|
182
267
|
*/
|
|
183
268
|
static unregisterPlugin(plugin) {
|
|
184
269
|
Loader.unregisterPlugin(plugin);
|
|
@@ -216,32 +301,7 @@ export class Player {
|
|
|
216
301
|
const player = this.player;
|
|
217
302
|
this.bindContainerEventListeners(player);
|
|
218
303
|
player.core.on(ClapprEvents.CORE_ACTIVE_CONTAINER_CHANGED, () => this.bindContainerEventListeners(player), null);
|
|
219
|
-
|
|
220
|
-
trace(`${T} CORE_SCREEN_ORIENTATION_CHANGED`, {
|
|
221
|
-
orientation,
|
|
222
|
-
rootNode: {
|
|
223
|
-
width: this.rootNode?.clientWidth,
|
|
224
|
-
height: this.rootNode?.clientHeight,
|
|
225
|
-
},
|
|
226
|
-
});
|
|
227
|
-
if (Browser.isiOS && this.rootNode) {
|
|
228
|
-
player.core.resize({
|
|
229
|
-
width: this.rootNode.clientWidth,
|
|
230
|
-
height: this.rootNode.clientHeight,
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
}, null);
|
|
234
|
-
player.core.on(ClapprEvents.CORE_RESIZE, ({ width, height }) => {
|
|
235
|
-
trace(`${T} CORE_RESIZE`, {
|
|
236
|
-
width,
|
|
237
|
-
height,
|
|
238
|
-
});
|
|
239
|
-
}, null);
|
|
240
|
-
player.core.on(ClapprEvents.CORE_FULLSCREEN, (isFullscreen) => {
|
|
241
|
-
trace(`${T} CORE_FULLSCREEN`, {
|
|
242
|
-
isFullscreen,
|
|
243
|
-
});
|
|
244
|
-
}, null);
|
|
304
|
+
this.bindSizeManagementListeners(player);
|
|
245
305
|
if (this.config.autoPlay) {
|
|
246
306
|
setTimeout(() => {
|
|
247
307
|
trace(`${T} autoPlay`, {
|
|
@@ -259,6 +319,15 @@ export class Player {
|
|
|
259
319
|
reportError(e);
|
|
260
320
|
}
|
|
261
321
|
}
|
|
322
|
+
safeTriggerEvent(event, ...args) {
|
|
323
|
+
try {
|
|
324
|
+
this.emitter.emit(event, ...args);
|
|
325
|
+
}
|
|
326
|
+
catch (e) {
|
|
327
|
+
reportError(e);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// TODO test
|
|
262
331
|
events = {
|
|
263
332
|
onReady: () => {
|
|
264
333
|
trace(`${T} onReady`, {
|
|
@@ -275,42 +344,29 @@ export class Player {
|
|
|
275
344
|
// TODO ensure that CORE_ACTIVE_CONTAINER_CHANGED does not get caught before onReady
|
|
276
345
|
setTimeout(() => this.tuneIn(), 0);
|
|
277
346
|
},
|
|
278
|
-
onResize: (newSize) => {
|
|
279
|
-
trace(`${T} onResize`, {
|
|
280
|
-
newSize,
|
|
281
|
-
});
|
|
282
|
-
},
|
|
283
347
|
onPlay: () => {
|
|
284
|
-
|
|
285
|
-
this.emitter.emit(PlayerEvent.Play);
|
|
286
|
-
}
|
|
287
|
-
catch (e) {
|
|
288
|
-
reportError(e);
|
|
289
|
-
}
|
|
348
|
+
this.safeTriggerEvent(PlayerEvent.Play);
|
|
290
349
|
},
|
|
291
350
|
onPause: () => {
|
|
292
|
-
|
|
293
|
-
this.emitter.emit(PlayerEvent.Pause);
|
|
294
|
-
}
|
|
295
|
-
catch (e) {
|
|
296
|
-
reportError(e);
|
|
297
|
-
}
|
|
351
|
+
this.safeTriggerEvent(PlayerEvent.Pause);
|
|
298
352
|
},
|
|
299
353
|
onEnded: () => {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
reportError(e);
|
|
305
|
-
}
|
|
354
|
+
this.safeTriggerEvent(PlayerEvent.Ended);
|
|
355
|
+
},
|
|
356
|
+
onSeek: (time) => {
|
|
357
|
+
this.safeTriggerEvent(PlayerEvent.Seek, time);
|
|
306
358
|
},
|
|
307
359
|
onStop: () => {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
360
|
+
this.safeTriggerEvent(PlayerEvent.Stop);
|
|
361
|
+
},
|
|
362
|
+
onVolumeUpdate: (volume) => {
|
|
363
|
+
this.safeTriggerEvent(PlayerEvent.VolumeUpdate, volume);
|
|
364
|
+
},
|
|
365
|
+
onTimeUpdate: (time) => {
|
|
366
|
+
this.safeTriggerEvent(PlayerEvent.TimeUpdate, time);
|
|
367
|
+
},
|
|
368
|
+
onError: (error) => {
|
|
369
|
+
this.safeTriggerEvent(PlayerEvent.Error, error);
|
|
314
370
|
},
|
|
315
371
|
};
|
|
316
372
|
buildCoreOptions(rootNode) {
|
|
@@ -338,6 +394,7 @@ export class Player {
|
|
|
338
394
|
mute: this.config.mute,
|
|
339
395
|
crossOrigin: 'anonymous', // TODO
|
|
340
396
|
hlsjsConfig: {
|
|
397
|
+
// TODO
|
|
341
398
|
debug: this.config.debug === 'all' || this.config.debug === 'hls',
|
|
342
399
|
},
|
|
343
400
|
},
|
|
@@ -346,7 +403,7 @@ export class Player {
|
|
|
346
403
|
width: rootNode.clientWidth,
|
|
347
404
|
source: source ? source.source : undefined,
|
|
348
405
|
mimeType: source ? source.mimeType : undefined,
|
|
349
|
-
sources,
|
|
406
|
+
sources,
|
|
350
407
|
strings: this.config.strings,
|
|
351
408
|
};
|
|
352
409
|
return coreOptions;
|
|
@@ -360,9 +417,6 @@ export class Player {
|
|
|
360
417
|
this.config.sources.map((s) => wrapSource(s)), this.config.priorityTransport);
|
|
361
418
|
}
|
|
362
419
|
bindContainerEventListeners(player) {
|
|
363
|
-
trace(`${T} bindContainerEventListeners`, {
|
|
364
|
-
activePlayback: player.core.activePlayback?.name,
|
|
365
|
-
});
|
|
366
420
|
if (Browser.isiOS && player.core.activePlayback) {
|
|
367
421
|
player.core.activePlayback.$el.on('webkitendfullscreen', () => {
|
|
368
422
|
try {
|
|
@@ -374,4 +428,34 @@ export class Player {
|
|
|
374
428
|
});
|
|
375
429
|
}
|
|
376
430
|
}
|
|
431
|
+
bindSizeManagementListeners(player) {
|
|
432
|
+
player.core.on(ClapprEvents.CORE_SCREEN_ORIENTATION_CHANGED, ({ orientation }) => {
|
|
433
|
+
trace(`${T} on CORE_SCREEN_ORIENTATION_CHANGED`, {
|
|
434
|
+
orientation,
|
|
435
|
+
rootNode: {
|
|
436
|
+
width: this.rootNode?.clientWidth,
|
|
437
|
+
height: this.rootNode?.clientHeight,
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
if (Browser.isiOS && this.rootNode) {
|
|
441
|
+
player.core.resize({
|
|
442
|
+
width: this.rootNode.clientWidth,
|
|
443
|
+
height: this.rootNode.clientHeight,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}, null);
|
|
447
|
+
player.core.on(ClapprEvents.CORE_RESIZE, ({ width, height }) => {
|
|
448
|
+
trace(`${T} on CORE_RESIZE`, {
|
|
449
|
+
width,
|
|
450
|
+
height,
|
|
451
|
+
});
|
|
452
|
+
this.safeTriggerEvent(PlayerEvent.Resize, { width, height });
|
|
453
|
+
}, null);
|
|
454
|
+
player.core.on(ClapprEvents.CORE_FULLSCREEN, (isFullscreen) => {
|
|
455
|
+
trace(`${T} CORE_FULLSCREEN`, {
|
|
456
|
+
isFullscreen,
|
|
457
|
+
});
|
|
458
|
+
this.safeTriggerEvent(PlayerEvent.Fullscreen, isFullscreen);
|
|
459
|
+
}, null);
|
|
460
|
+
}
|
|
377
461
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Video player for the
|
|
2
|
+
* Video player for the Gcore streaming platform
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
|
-
* This package provides a video player for the
|
|
5
|
+
* This package provides a video player for the Gcore streaming platform.
|
|
6
6
|
* It is built on top of the Clappr library and provides a framework for building custom integrations.
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
@@ -11,6 +11,5 @@ export { LogTracer, Logger, SentryTracer, reportError, setTracer, trace } from '
|
|
|
11
11
|
export * from './Player.js';
|
|
12
12
|
export * from './playback.types.js';
|
|
13
13
|
export * from './types.js';
|
|
14
|
-
export * from './utils/mediaSources.js';
|
|
15
14
|
export * from './version.js';
|
|
16
15
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClG,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClG,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Video player for the
|
|
2
|
+
* Video player for the Gcore streaming platform
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
|
-
* This package provides a video player for the
|
|
5
|
+
* This package provides a video player for the Gcore streaming platform.
|
|
6
6
|
* It is built on top of the Clappr library and provides a framework for building custom integrations.
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
@@ -11,5 +11,4 @@ export { LogTracer, Logger, SentryTracer, reportError, setTracer, trace } from '
|
|
|
11
11
|
export * from './Player.js';
|
|
12
12
|
export * from './playback.types.js';
|
|
13
13
|
export * from './types.js';
|
|
14
|
-
export * from './utils/mediaSources.js';
|
|
15
14
|
export * from './version.js';
|
package/lib/internal.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CorePlugin, ContainerPlugin, Playback as ClapprPlayback } from "@clappr/core";
|
|
2
|
-
import { PlaybackType, PlayerDebugTag, PlayerMediaSource } from "./types";
|
|
2
|
+
import { ContainerSize, PlaybackType, PlayerDebugTag, PlayerMediaSource } from "./types";
|
|
3
3
|
import { PlaybackError } from "./playback.types";
|
|
4
4
|
type ExternalTrack = {
|
|
5
5
|
kind?: "subtitles" | "captions";
|
|
@@ -34,6 +34,7 @@ export interface CorePlaybackConfig {
|
|
|
34
34
|
mute?: boolean;
|
|
35
35
|
playInline: boolean;
|
|
36
36
|
preload?: 'metadata' | 'auto' | 'none';
|
|
37
|
+
recycleVideo?: boolean;
|
|
37
38
|
shakaConfiguration?: ShakaConfig;
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
@@ -41,10 +42,7 @@ export interface CorePlaybackConfig {
|
|
|
41
42
|
*/
|
|
42
43
|
export type CorePlayerEvents = {
|
|
43
44
|
onReady?: () => void;
|
|
44
|
-
onResize?: (data:
|
|
45
|
-
width: number;
|
|
46
|
-
height: number;
|
|
47
|
-
}) => void;
|
|
45
|
+
onResize?: (data: ContainerSize) => void;
|
|
48
46
|
onPlay?: (metadata: unknown) => void;
|
|
49
47
|
onPause?: (metadata: unknown) => void;
|
|
50
48
|
onStop?: (metadata: unknown) => void;
|
|
@@ -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,EAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,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;AAEtB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,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;;;GAGG;AACH,KAAK,WA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AC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,CAAC,EAAE,iBAAiB,GAAG,UAAU,EAAE,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA"}
|
|
@@ -66,8 +66,10 @@ export default class DashPlayback extends HTML5Video {
|
|
|
66
66
|
_updatePlaybackType(): void;
|
|
67
67
|
_fillLevels(levels: DashBitrateInfo[]): void;
|
|
68
68
|
private onLevelSwitch;
|
|
69
|
+
private onLevelSwitchEnd;
|
|
69
70
|
getPlaybackType(): string;
|
|
70
71
|
isSeekEnabled(): boolean;
|
|
72
|
+
private getLevel;
|
|
71
73
|
}
|
|
72
74
|
export {};
|
|
73
75
|
//# sourceMappingURL=DashPlayback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashPlayback.d.ts","sourceRoot":"","sources":["../../../src/playback/dash-playback/DashPlayback.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"DashPlayback.d.ts","sourceRoot":"","sources":["../../../src/playback/dash-playback/DashPlayback.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,UAAU,EAEV,QAAQ,EAIT,MAAM,cAAc,CAAA;AAGrB,OAAO,MAAM,EAAE,EAIb,KAAK,WAAW,IAAI,eAAe,EAEnC,aAAa,EACd,MAAM,QAAQ,CAAA;AAEf,OAAO,EAIL,YAAY,EACZ,YAAY,EAEZ,SAAS,EACV,MAAM,yBAAyB,CAAA;AAOhC,KAAK,YAAY,GACb,OAAO,QAAQ,CAAC,GAAG,GACnB,OAAO,QAAQ,CAAC,IAAI,GACpB,OAAO,QAAQ,CAAC,GAAG,GACnB,OAAO,QAAQ,CAAC,KAAK,CAAA;AAEzB,KAAK,YAAY,GAAG,MAAM,CAAA;AAE1B,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAKD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,UAAU;IAClD,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAAO;IAErC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAO;IAKnC,mCAAmC,EAAE,OAAO,CAAQ;IAEpD,aAAa,EAAE,OAAO,CAAQ;IAI9B,uBAAuB,EAAE,MAAM,CAAI;IASnC,wBAAwB,EAAE,MAAM,CAAI;IAEpC,aAAa,EAAE,YAAY,CAAe;IAG1C,aAAa,EAAE,YAAY,GAAG,IAAI,CAAO;IAGzC,gBAAgB,EAAE,SAAS,CAAI;IAE/B,KAAK,EAAE,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAO;IAE5C,2BAA2B,EAAE,MAAM,CAAI;IAEvC,aAAa,EAAE,SAAS,GAAG,IAAI,CAAO;IAEtC,eAAe,EAAE,YAAY,CAA2B;IA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gB;IAQxB,eAAe;IAIf,aAAa;IAIb,OAAO,CAAC,QAAQ;CAKjB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Copyright 2014 Globo.com Player authors. All rights reserved.
|
|
2
2
|
// Use of this source code is governed by a BSD-style
|
|
3
3
|
// license that can be found in the LICENSE file.
|
|
4
|
-
import { Events, HTML5Video, Log, Playback, PlayerError, Utils } from '@clappr/core';
|
|
4
|
+
import { Events, HTML5Video, Log, Playback, PlayerError, Utils, $, } from '@clappr/core';
|
|
5
5
|
import { trace } from '@gcorevideo/utils';
|
|
6
6
|
import assert from 'assert';
|
|
7
7
|
import DASHJS from 'dashjs';
|
|
8
|
-
import { PlaybackErrorCode } from '../../playback.types.js';
|
|
8
|
+
import { PlaybackErrorCode, } from '../../playback.types.js';
|
|
9
9
|
import { isDashSource } from '../../utils/mediaSources.js';
|
|
10
10
|
const AUTO = -1;
|
|
11
11
|
const { now } = Utils;
|
|
@@ -69,13 +69,15 @@ export default class DashPlayback extends HTML5Video {
|
|
|
69
69
|
this.trigger(Events.PLAYBACK_LEVEL_SWITCH_START);
|
|
70
70
|
assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to switch levels');
|
|
71
71
|
const dash = this._dash;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
const settings = $.extend(true, {}, this.options.dash, {
|
|
73
|
+
streaming: {
|
|
74
|
+
abr: {
|
|
75
|
+
autoSwitchBitrate: {
|
|
76
|
+
video: id === -1,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
79
81
|
dash.updateSettings(settings);
|
|
80
82
|
if (id !== -1) {
|
|
81
83
|
this._dash.setQualityFor('video', id);
|
|
@@ -143,16 +145,14 @@ export default class DashPlayback extends HTML5Video {
|
|
|
143
145
|
this._dash.initialize();
|
|
144
146
|
if (this.options.dash) {
|
|
145
147
|
// TODO use $.extend
|
|
146
|
-
const settings =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
this._dash.updateSettings(this.options.dash);
|
|
148
|
+
const settings = $.extend({}, this.options.dash, {
|
|
149
|
+
streaming: {
|
|
150
|
+
text: {
|
|
151
|
+
defaultEnabled: false,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
this._dash.updateSettings(settings);
|
|
156
156
|
}
|
|
157
157
|
this._dash.attachView(this.el);
|
|
158
158
|
this._dash.setAutoPlay(false);
|
|
@@ -164,13 +164,14 @@ export default class DashPlayback extends HTML5Video {
|
|
|
164
164
|
this._updatePlaybackType();
|
|
165
165
|
this._fillLevels(bitrates);
|
|
166
166
|
dash.on(DASHJS.MediaPlayer.events.QUALITY_CHANGE_REQUESTED, (evt) => {
|
|
167
|
-
|
|
168
|
-
assert.ok(this._levels, 'An array of levels is required to change quality');
|
|
169
|
-
const newLevel = this._levels.find((level) => level.level === evt.newQuality); // TODO or simply this._levels[evt.newQuality]?
|
|
170
|
-
assert.ok(newLevel, 'A valid level is required to change quality');
|
|
167
|
+
const newLevel = this.getLevel(evt.newQuality);
|
|
171
168
|
this.onLevelSwitch(newLevel);
|
|
172
169
|
});
|
|
173
170
|
});
|
|
171
|
+
this._dash.on(DASHJS.MediaPlayer.events.QUALITY_CHANGE_RENDERED, (evt) => {
|
|
172
|
+
const currentLevel = this.getLevel(evt.newQuality);
|
|
173
|
+
this.onLevelSwitchEnd(currentLevel);
|
|
174
|
+
});
|
|
174
175
|
this._dash.on(DASHJS.MediaPlayer.events.METRIC_ADDED, (e) => {
|
|
175
176
|
// Listen for the first manifest request in order to update player UI
|
|
176
177
|
if (e.metric === 'DVRInfo') {
|
|
@@ -314,7 +315,11 @@ export default class DashPlayback extends HTML5Video {
|
|
|
314
315
|
};
|
|
315
316
|
triggerError(error) {
|
|
316
317
|
trace(`${T} triggerError`, { error });
|
|
317
|
-
this.trigger(Events.PLAYBACK_ERROR,
|
|
318
|
+
this.trigger(Events.PLAYBACK_ERROR, {
|
|
319
|
+
...error,
|
|
320
|
+
origin: this.name,
|
|
321
|
+
scope: DashPlayback.type,
|
|
322
|
+
});
|
|
318
323
|
// only reset the dash player in 10ms async, so that the rest of the
|
|
319
324
|
// calling function finishes
|
|
320
325
|
setTimeout(() => {
|
|
@@ -429,8 +434,10 @@ export default class DashPlayback extends HTML5Video {
|
|
|
429
434
|
onLevelSwitch(currentLevel) {
|
|
430
435
|
// TODO check the two below
|
|
431
436
|
this.trigger(Events.PLAYBACK_LEVEL_SWITCH, currentLevel);
|
|
437
|
+
}
|
|
438
|
+
onLevelSwitchEnd(currentLevel) {
|
|
432
439
|
this.trigger(Events.PLAYBACK_LEVEL_SWITCH_END);
|
|
433
|
-
const isHD =
|
|
440
|
+
const isHD = currentLevel.height >= 720 || currentLevel.bitrate / 1000 >= 2000;
|
|
434
441
|
this.trigger(Events.PLAYBACK_HIGHDEFINITIONUPDATE, isHD);
|
|
435
442
|
this.trigger(Events.PLAYBACK_BITRATE, currentLevel);
|
|
436
443
|
}
|
|
@@ -440,6 +447,11 @@ export default class DashPlayback extends HTML5Video {
|
|
|
440
447
|
isSeekEnabled() {
|
|
441
448
|
return this._playbackType === Playback.VOD || this.dvrEnabled;
|
|
442
449
|
}
|
|
450
|
+
getLevel(quality) {
|
|
451
|
+
const ret = this.levels.find((level) => level.level === quality);
|
|
452
|
+
assert.ok(ret, 'Invalid quality level');
|
|
453
|
+
return ret;
|
|
454
|
+
}
|
|
443
455
|
}
|
|
444
456
|
DashPlayback.canPlay = function (resource, mimeType) {
|
|
445
457
|
if (!isDashSource(resource, mimeType)) {
|
|
@@ -94,6 +94,9 @@ export default class HlsPlayback extends HTML5Video {
|
|
|
94
94
|
_onFragmentLoaded(evt: HlsEvents.FRAG_LOADED, data: FragLoadedData): void;
|
|
95
95
|
_onSubtitleLoaded(): void;
|
|
96
96
|
_onLevelSwitch(evt: HlsEvents.LEVEL_SWITCHING, data: LevelSwitchingData): void;
|
|
97
|
+
_onLevelSwitched(evt: HlsEvents.LEVEL_SWITCHED, data: {
|
|
98
|
+
level: number;
|
|
99
|
+
}): void;
|
|
97
100
|
get dvrEnabled(): boolean;
|
|
98
101
|
getPlaybackType(): PlaybackType;
|
|
99
102
|
isSeekEnabled(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HlsPlayback.d.ts","sourceRoot":"","sources":["../../../src/playback/hls-playback/HlsPlayback.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,UAAU,EAKX,MAAM,cAAc,CAAA;AAGrB,OAAO,KAAK,EAAE,EACZ,MAAM,IAAI,SAAS,EAEnB,KAAK,SAAS,IAAI,YAAY,EAE9B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAG5B,KAAK,kBAAkB,EACxB,MAAM,QAAQ,CAAA;AAEf,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"HlsPlayback.d.ts","sourceRoot":"","sources":["../../../src/playback/hls-playback/HlsPlayback.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,UAAU,EAKX,MAAM,cAAc,CAAA;AAGrB,OAAO,KAAK,EAAE,EACZ,MAAM,IAAI,SAAS,EAEnB,KAAK,SAAS,IAAI,YAAY,EAE9B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAG5B,KAAK,kBAAkB,EACxB,MAAM,QAAQ,CAAA;AAEf,OAAO,EACL,aAAa,EAGb,YAAY,EAGb,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AA4C7C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,OAAO,CAAC,UAAU,CAAQ;IAE1B,OAAO,CAAC,gBAAgB,CAAQ;IAEhC,OAAO,CAAC,gBAAgB,CAA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