@gcorevideo/player 2.7.5 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +22 -75
- package/lib/Player.d.ts +1 -7
- package/lib/Player.d.ts.map +1 -1
- package/lib/Player.js +1 -68
- package/lib/plugins/dash-playback/DashPlayback.d.ts +6 -6
- package/lib/plugins/dash-playback/DashPlayback.d.ts.map +1 -1
- package/lib/plugins/dash-playback/DashPlayback.js +11 -2
- package/lib/plugins/hls-playback/HlsPlayback.d.ts +3 -3
- package/lib/plugins/hls-playback/HlsPlayback.d.ts.map +1 -1
- package/lib/plugins/hls-playback/HlsPlayback.js +5 -0
- package/lib/utils/mediaSources.js +3 -3
- package/licenses.json +782 -0
- package/package.json +1 -1
- package/src/Player.ts +1 -86
- package/src/plugins/dash-playback/DashPlayback.ts +16 -11
- package/src/plugins/hls-playback/HlsPlayback.ts +6 -1
- package/src/typings/@clappr/core/html5_video.d.ts +20 -21
- package/src/utils/mediaSources.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/src/typings/@clappr/core/events.d.ts +0 -7
- package/src/typings/@clappr/core/player.d.ts +0 -8
package/package.json
CHANGED
package/src/Player.ts
CHANGED
|
@@ -16,7 +16,6 @@ import type {
|
|
|
16
16
|
PlayerMediaSource,
|
|
17
17
|
} from './internal.types.js'
|
|
18
18
|
import type {
|
|
19
|
-
PlaybackType,
|
|
20
19
|
PlayerPlugin,
|
|
21
20
|
} from './types.js'
|
|
22
21
|
import { reportError, trace } from './trace/index.js'
|
|
@@ -28,7 +27,6 @@ import {
|
|
|
28
27
|
buildSourcesSet,
|
|
29
28
|
unwrapSource,
|
|
30
29
|
} from './utils/mediaSources.js'
|
|
31
|
-
import { QualityLevel } from './playback.types.js'
|
|
32
30
|
|
|
33
31
|
// TODO implement transport retry/failover and fallback logic
|
|
34
32
|
|
|
@@ -57,8 +55,6 @@ type PluginOptions = Record<string, unknown>
|
|
|
57
55
|
* @beta
|
|
58
56
|
*/
|
|
59
57
|
export class Player {
|
|
60
|
-
private qLevel: QualityLevel | null = null
|
|
61
|
-
|
|
62
58
|
private config: PlayerConfig = DEFAULT_OPTIONS
|
|
63
59
|
|
|
64
60
|
private emitter = new EventLite()
|
|
@@ -73,39 +69,6 @@ export class Player {
|
|
|
73
69
|
|
|
74
70
|
private tunedIn = false
|
|
75
71
|
|
|
76
|
-
// get activePlayback(): PlaybackModule | null {
|
|
77
|
-
// if (!this.player?.core.activePlayback) {
|
|
78
|
-
// return null
|
|
79
|
-
// }
|
|
80
|
-
// switch (this.player.core.activePlayback.name) {
|
|
81
|
-
// case 'dash':
|
|
82
|
-
// return 'dash'
|
|
83
|
-
// case 'hls':
|
|
84
|
-
// return 'hls'
|
|
85
|
-
// default:
|
|
86
|
-
// return 'native'
|
|
87
|
-
// }
|
|
88
|
-
// }
|
|
89
|
-
|
|
90
|
-
// get activeSource(): string | null {
|
|
91
|
-
// if (!this.player?.core.activePlayback) {
|
|
92
|
-
// return null
|
|
93
|
-
// }
|
|
94
|
-
// return this.player.core.activePlayback.options.src
|
|
95
|
-
// }
|
|
96
|
-
|
|
97
|
-
get bitrate(): QualityLevel | null {
|
|
98
|
-
return this.qLevel
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
get hd() {
|
|
102
|
-
return this.player?.core.activePlayback?.isHighDefinitionInUse || false
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
get playbackType(): PlaybackType | undefined {
|
|
106
|
-
return this.player?.core.activePlayback?.getPlaybackType()
|
|
107
|
-
}
|
|
108
|
-
|
|
109
72
|
constructor(config: PlayerConfig) {
|
|
110
73
|
this.setConfig(config)
|
|
111
74
|
}
|
|
@@ -165,7 +128,6 @@ export class Player {
|
|
|
165
128
|
clearTimeout(this.tuneInTimerId)
|
|
166
129
|
this.tuneInTimerId = null
|
|
167
130
|
}
|
|
168
|
-
this.qLevel = null
|
|
169
131
|
}
|
|
170
132
|
|
|
171
133
|
pause() {
|
|
@@ -209,7 +171,6 @@ export class Player {
|
|
|
209
171
|
|
|
210
172
|
private initPlayer(coreOptions: CoreOptions) {
|
|
211
173
|
trace(`${T} initPlayer`, {
|
|
212
|
-
// coreOptions,
|
|
213
174
|
// TODO selected options
|
|
214
175
|
})
|
|
215
176
|
|
|
@@ -218,18 +179,6 @@ export class Player {
|
|
|
218
179
|
const player = new PlayerClappr(coreOptions)
|
|
219
180
|
this.player = player
|
|
220
181
|
|
|
221
|
-
if (player.core.activeContainer) {
|
|
222
|
-
trace(`${T} tuneIn bindBitrateChangeHandler`)
|
|
223
|
-
this.bindBitrateChangeHandler()
|
|
224
|
-
}
|
|
225
|
-
player.core.on(
|
|
226
|
-
ClapprEvents.CORE_ACTIVE_CONTAINER_CHANGED,
|
|
227
|
-
() => {
|
|
228
|
-
this.bindBitrateChangeHandler()
|
|
229
|
-
},
|
|
230
|
-
null,
|
|
231
|
-
)
|
|
232
|
-
|
|
233
182
|
// TODO checks if the whole thing is necessary
|
|
234
183
|
this.tuneInTimerId = globalThis.setTimeout(() => {
|
|
235
184
|
trace(`${T} tuneInTimer`, {
|
|
@@ -367,20 +316,7 @@ export class Player {
|
|
|
367
316
|
}
|
|
368
317
|
|
|
369
318
|
private buildCoreOptions(rootNode: HTMLElement): CoreOptions {
|
|
370
|
-
|
|
371
|
-
// const multisources = this.config.multisources
|
|
372
|
-
// const mainSource =
|
|
373
|
-
// this.config.playbackType === 'live'
|
|
374
|
-
// ? multisources.find((ms) => ms.live !== false)
|
|
375
|
-
// : multisources[0]
|
|
376
|
-
// const mediaSources = mainSource
|
|
377
|
-
// ? this.buildMediaSourcesList(mainSource)
|
|
378
|
-
// : []
|
|
379
|
-
// const mainSourceUrl = mediaSources[0];
|
|
380
|
-
// const poster = mainSource?.poster ?? this.config.poster
|
|
381
|
-
// const poster = this.config.poster
|
|
382
|
-
|
|
383
|
-
const source = this.selectMediaSource() // TODO
|
|
319
|
+
const source = this.selectMediaSource()
|
|
384
320
|
|
|
385
321
|
this.rootNode = rootNode
|
|
386
322
|
|
|
@@ -406,10 +342,8 @@ export class Player {
|
|
|
406
342
|
},
|
|
407
343
|
parent: rootNode,
|
|
408
344
|
playbackType: this.config.playbackType,
|
|
409
|
-
// poster,
|
|
410
345
|
width: rootNode.clientWidth,
|
|
411
346
|
source: source ? unwrapSource(source) : undefined,
|
|
412
|
-
// sources: mediaSources,
|
|
413
347
|
strings: this.config.strings,
|
|
414
348
|
}
|
|
415
349
|
return coreOptions
|
|
@@ -421,25 +355,6 @@ export class Player {
|
|
|
421
355
|
Loader.registerPlayback(HlsPlayback)
|
|
422
356
|
}
|
|
423
357
|
|
|
424
|
-
private bindBitrateChangeHandler() {
|
|
425
|
-
// TODO implement a plugin for the whole thing
|
|
426
|
-
trace(`${T} bindBitrateChangeHandler`, { activeContainer: this.player?.core?.activeContainer?.name })
|
|
427
|
-
const currentPlayback = this.player?.core.activePlayback;
|
|
428
|
-
currentPlayback.on(ClapprEvents.PLAYBACK_LEVELS_AVAILABLE, (levels: QualityLevel[]) => {
|
|
429
|
-
// TODO test
|
|
430
|
-
if (!this.qLevel) {
|
|
431
|
-
this.qLevel = levels[0]
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
this.player?.core.activeContainer.on(
|
|
435
|
-
ClapprEvents.CONTAINER_BITRATE,
|
|
436
|
-
(bitrate: QualityLevel) => {
|
|
437
|
-
trace(`${T} bitrate has changed`, { bitrate })
|
|
438
|
-
this.qLevel = bitrate
|
|
439
|
-
},
|
|
440
|
-
)
|
|
441
|
-
}
|
|
442
|
-
|
|
443
358
|
// Select a single source to play according to the priority transport and the modules support
|
|
444
359
|
private selectMediaSource(): PlayerMediaSource | undefined {
|
|
445
360
|
return buildSourcesPriorityList(
|
|
@@ -13,7 +13,7 @@ import DASHJS, {
|
|
|
13
13
|
} from 'dashjs'
|
|
14
14
|
import { trace } from '../../trace/index.js'
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { QualityLevel, TimePosition, TimeValue } from '../../playback.types.js'
|
|
17
17
|
|
|
18
18
|
const AUTO = -1
|
|
19
19
|
|
|
@@ -34,6 +34,7 @@ type LocalTimeCorrelation = {
|
|
|
34
34
|
|
|
35
35
|
const T = 'DashPlayback'
|
|
36
36
|
|
|
37
|
+
// @ts-expect-error
|
|
37
38
|
export default class DashPlayback extends HTML5Video {
|
|
38
39
|
_levels: QualityLevel[] | null = null
|
|
39
40
|
|
|
@@ -299,7 +300,7 @@ export default class DashPlayback extends HTML5Video {
|
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
// override
|
|
302
|
-
_setupSrc() {
|
|
303
|
+
private override _setupSrc() {
|
|
303
304
|
// this playback manages the src on the video element itself
|
|
304
305
|
}
|
|
305
306
|
|
|
@@ -386,27 +387,31 @@ export default class DashPlayback extends HTML5Video {
|
|
|
386
387
|
this.trigger(Events.PLAYBACK_STATS_ADD, { dvr: status })
|
|
387
388
|
}
|
|
388
389
|
|
|
389
|
-
_updateSettings() {
|
|
390
|
+
override _updateSettings() {
|
|
390
391
|
if (this._playbackType === Playback.VOD) {
|
|
392
|
+
// @ts-expect-error
|
|
391
393
|
this.settings.left = ['playpause', 'position', 'duration']
|
|
392
394
|
} else if (this.dvrEnabled) {
|
|
395
|
+
// @ts-expect-error
|
|
393
396
|
this.settings.left = ['playpause']
|
|
394
397
|
} else {
|
|
398
|
+
// @ts-expect-error
|
|
395
399
|
this.settings.left = ['playstop']
|
|
396
400
|
}
|
|
397
|
-
|
|
401
|
+
// @ts-expect-error
|
|
398
402
|
this.settings.seekEnabled = this.isSeekEnabled()
|
|
399
403
|
this.trigger(Events.PLAYBACK_SETTINGSUPDATE)
|
|
400
404
|
}
|
|
401
405
|
|
|
402
|
-
_onPlaybackError = (event: DashPlaybackErrorEvent) => {
|
|
406
|
+
private _onPlaybackError = (event: DashPlaybackErrorEvent) => {
|
|
403
407
|
// TODO
|
|
408
|
+
trace(`${T} _onPlaybackError`, { event })
|
|
404
409
|
}
|
|
405
410
|
|
|
406
|
-
_onDASHJSSError = (event: DashErrorEvent) => {
|
|
411
|
+
private _onDASHJSSError = (event: DashErrorEvent) => {
|
|
412
|
+
trace(`${T} _onDASHJSSError`, { event })
|
|
407
413
|
// TODO
|
|
408
414
|
// only report/handle errors if they are fatal
|
|
409
|
-
// hlsjs should automatically handle non fatal errors
|
|
410
415
|
this._stopTimeUpdateTimer()
|
|
411
416
|
if (event.error === 'capability' && event.event === 'mediasource') {
|
|
412
417
|
// No support for MSE
|
|
@@ -542,10 +547,10 @@ export default class DashPlayback extends HTML5Video {
|
|
|
542
547
|
}
|
|
543
548
|
|
|
544
549
|
get dvrEnabled() {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
550
|
+
if (!this._dash) {
|
|
551
|
+
trace(`${T} dvrEnable no dash player instance`)
|
|
552
|
+
return false
|
|
553
|
+
}
|
|
549
554
|
return (
|
|
550
555
|
this._dash?.getDVRWindowSize() >= this._minDvrSize &&
|
|
551
556
|
this.getPlaybackType() === Playback.LIVE
|
|
@@ -61,6 +61,7 @@ type CustomListener = {
|
|
|
61
61
|
// TODO level, code, description, etc
|
|
62
62
|
type ErrorInfo = Record<string, unknown>;
|
|
63
63
|
|
|
64
|
+
// @ts-expect-error
|
|
64
65
|
export default class HlsPlayback extends HTML5Video {
|
|
65
66
|
private _ccIsSetup = false;
|
|
66
67
|
|
|
@@ -436,7 +437,7 @@ export default class HlsPlayback extends HTML5Video {
|
|
|
436
437
|
|
|
437
438
|
// override
|
|
438
439
|
// this playback manages the src on the video element itself
|
|
439
|
-
_setupSrc(srcUrl: string) { } // eslint-disable-line no-unused-vars
|
|
440
|
+
private override _setupSrc(srcUrl: string) { } // eslint-disable-line no-unused-vars
|
|
440
441
|
|
|
441
442
|
_startTimeUpdateTimer() {
|
|
442
443
|
if (this._timeUpdateTimer) {
|
|
@@ -511,13 +512,17 @@ export default class HlsPlayback extends HTML5Video {
|
|
|
511
512
|
|
|
512
513
|
_updateSettings() {
|
|
513
514
|
if (this._playbackType === Playback.VOD) {
|
|
515
|
+
// @ts-expect-error
|
|
514
516
|
this.settings.left = ['playpause', 'position', 'duration'];
|
|
515
517
|
} else if (this.dvrEnabled) {
|
|
518
|
+
// @ts-expect-error
|
|
516
519
|
this.settings.left = ['playpause'];
|
|
517
520
|
} else {
|
|
521
|
+
// @ts-expect-error
|
|
518
522
|
this.settings.left = ['playstop'];
|
|
519
523
|
}
|
|
520
524
|
|
|
525
|
+
// @ts-expect-error
|
|
521
526
|
this.settings.seekEnabled = this.isSeekEnabled();
|
|
522
527
|
this.trigger(Events.PLAYBACK_SETTINGSUPDATE);
|
|
523
528
|
}
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import '@clappr/core';
|
|
2
2
|
|
|
3
3
|
declare module "@clappr/core" {
|
|
4
|
-
declare type HTML5VideoSettingsItem =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
| "playstop";
|
|
4
|
+
// declare type HTML5VideoSettingsItem =
|
|
5
|
+
// | "seekbar"
|
|
6
|
+
// | "playpause"
|
|
7
|
+
// | "position"
|
|
8
|
+
// | "duration"
|
|
9
|
+
// | "fullscreen"
|
|
10
|
+
// | "volume"
|
|
11
|
+
// | "hd-indicator"
|
|
12
|
+
// | "playstop";
|
|
14
13
|
|
|
15
|
-
declare type HTML5VideoSettings = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
14
|
+
// declare type HTML5VideoSettings = {
|
|
15
|
+
// default: HTML5VideoSettingsItem[];
|
|
16
|
+
// left?: HTML5VideoSettingsItem[];
|
|
17
|
+
// right?: HTML5VideoSettingsItem[];
|
|
18
|
+
// seekEnabled?: boolean;
|
|
19
|
+
// }
|
|
21
20
|
|
|
22
|
-
declare class HTML5Video extends Playback {
|
|
23
|
-
|
|
21
|
+
// declare class HTML5Video extends Playback {
|
|
22
|
+
// settings: HTML5VideoSettings;
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
// readonly _minDvrSize: number;
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
}
|
|
26
|
+
// _onDurationChange(): void;
|
|
27
|
+
// }
|
|
29
28
|
}
|
|
@@ -65,13 +65,13 @@ export function buildSourcesPriorityList(
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function addHls() {
|
|
68
|
-
if (sources.hls && HlsPlayback.canPlay(sources.hls)) {
|
|
68
|
+
if (sources.hls && HlsPlayback.canPlay(sources.hls, undefined)) {
|
|
69
69
|
msl.push(sources.hls)
|
|
70
70
|
sources.hls = null
|
|
71
71
|
}
|
|
72
72
|
if (
|
|
73
73
|
sources.master?.endsWith('.m3u8') &&
|
|
74
|
-
HlsPlayback.canPlay(sources.master)
|
|
74
|
+
HlsPlayback.canPlay(sources.master, undefined)
|
|
75
75
|
) {
|
|
76
76
|
msl.push(sources.master)
|
|
77
77
|
sources.master = null
|
|
@@ -79,7 +79,7 @@ export function buildSourcesPriorityList(
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function addDash() {
|
|
82
|
-
if (sources.dash && DashPlayback.canPlay(sources.dash)) {
|
|
82
|
+
if (sources.dash && DashPlayback.canPlay(sources.dash, undefined)) {
|
|
83
83
|
msl.push(sources.dash)
|
|
84
84
|
sources.dash = null
|
|
85
85
|
}
|