@gcorevideo/player 2.9.0 → 2.12.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/LICENSE +13 -0
- package/README.md +39 -0
- package/api-extractor.json +454 -0
- package/coverage/clover.xml +6 -0
- package/coverage/coverage-final.json +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +101 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +0 -0
- package/dist/index.js +4344 -1602
- package/dist/player.d.ts +407 -0
- package/docs/api/index.md +31 -0
- package/docs/api/player.dashsettings.md +16 -0
- package/docs/api/player.langtag.md +15 -0
- package/docs/api/player.md +295 -0
- package/docs/api/player.mediatransport.md +15 -0
- package/docs/api/player.playbackmodule.md +15 -0
- package/docs/api/player.playbacktype.md +16 -0
- package/docs/api/player.player._constructor_.md +50 -0
- package/docs/api/player.player.attachto.md +56 -0
- package/docs/api/player.player.configure.md +58 -0
- package/docs/api/player.player.destroy.md +20 -0
- package/docs/api/player.player.getcurrenttime.md +22 -0
- package/docs/api/player.player.getduration.md +22 -0
- package/docs/api/player.player.md +304 -0
- package/docs/api/player.player.mute.md +20 -0
- package/docs/api/player.player.off.md +72 -0
- package/docs/api/player.player.on.md +72 -0
- package/docs/api/player.player.pause.md +20 -0
- package/docs/api/player.player.play.md +20 -0
- package/docs/api/player.player.registerplugin.md +56 -0
- package/docs/api/player.player.resize.md +59 -0
- package/docs/api/player.player.seek.md +56 -0
- package/docs/api/player.player.stop.md +20 -0
- package/docs/api/player.player.unmute.md +20 -0
- package/docs/api/player.player.unregisterplugin.md +56 -0
- package/docs/api/player.playerconfig.autoplay.md +16 -0
- package/docs/api/player.playerconfig.dash.md +16 -0
- package/docs/api/player.playerconfig.debug.md +16 -0
- package/docs/api/player.playerconfig.language.md +16 -0
- package/docs/api/player.playerconfig.loop.md +16 -0
- package/docs/api/player.playerconfig.md +266 -0
- package/docs/api/player.playerconfig.mute.md +16 -0
- package/docs/api/player.playerconfig.playbacktype.md +16 -0
- package/docs/api/player.playerconfig.prioritytransport.md +16 -0
- package/docs/api/player.playerconfig.sources.md +16 -0
- package/docs/api/player.playerconfig.strings.md +16 -0
- package/docs/api/player.playerdebugsettings.md +20 -0
- package/docs/api/player.playerdebugtag.md +15 -0
- package/docs/api/player.playerevent.md +116 -0
- package/docs/api/player.playereventhandler.md +17 -0
- package/docs/api/player.playermediasource.md +18 -0
- package/docs/api/player.playermediasourcedesc.md +83 -0
- package/docs/api/player.playermediasourcedesc.mimetype.md +16 -0
- package/docs/api/player.playermediasourcedesc.source.md +16 -0
- package/docs/api/player.playerplugin.md +17 -0
- package/docs/api/player.qualitylevel.md +20 -0
- package/docs/api/player.translationkey.md +15 -0
- package/docs/api/player.translationsettings.md +35 -0
- package/docs/api/player.transportpreference.md +17 -0
- package/docs/api/player.version.md +27 -0
- package/lib/Player.d.ts +86 -7
- package/lib/Player.d.ts.map +1 -1
- package/lib/Player.js +132 -45
- package/lib/constants.d.ts +0 -18
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +1 -18
- package/lib/gcore.types.d.ts +84 -0
- package/lib/gcore.types.d.ts.map +1 -0
- package/lib/gcore.types.js +9 -0
- package/lib/index.d.ts +15 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +14 -5
- package/lib/internal.types.d.ts +30 -11
- package/lib/internal.types.d.ts.map +1 -1
- package/lib/playback/index.d.ts +4 -0
- package/lib/playback/index.d.ts.map +1 -0
- package/lib/playback/index.js +13 -0
- package/lib/playback.types.d.ts +28 -5
- package/lib/playback.types.d.ts.map +1 -1
- package/lib/playback.types.js +9 -1
- package/lib/plugins/dash-playback/DashPlayback.d.ts +0 -1
- package/lib/plugins/dash-playback/DashPlayback.d.ts.map +1 -1
- package/lib/plugins/dash-playback/DashPlayback.js +32 -96
- package/lib/plugins/dash-playback/types.d.ts +6 -0
- package/lib/plugins/dash-playback/types.d.ts.map +1 -0
- package/lib/plugins/dash-playback/types.js +1 -0
- 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 +136 -63
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/types.d.ts +181 -64
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +19 -0
- package/lib/utils/mediaSources.d.ts +14 -8
- package/lib/utils/mediaSources.d.ts.map +1 -1
- package/lib/utils/mediaSources.js +56 -62
- package/lib/utils/testUtils.d.ts +3 -0
- package/lib/utils/testUtils.d.ts.map +1 -0
- package/lib/utils/testUtils.js +12 -0
- package/lib/version.d.ts +5 -0
- package/lib/version.d.ts.map +1 -1
- package/lib/version.js +5 -0
- package/package.json +10 -4
- package/src/Player.ts +155 -54
- package/src/__tests__/Player.test.ts +357 -0
- package/src/index.ts +16 -5
- package/src/internal.types.ts +30 -15
- package/src/playback/index.ts +17 -0
- package/src/playback.types.ts +31 -7
- package/src/plugins/dash-playback/DashPlayback.ts +38 -114
- package/src/plugins/hls-playback/HlsPlayback.ts +561 -386
- package/src/types.ts +199 -75
- package/src/typings/@clappr/core/error_mixin.d.ts +0 -2
- package/src/typings/@clappr/core/index.d.ts +5 -0
- package/src/typings/@clappr/index.d.ts +1 -0
- package/src/utils/__tests__/mediaSources.test.ts +230 -0
- package/src/utils/mediaSources.ts +65 -75
- package/src/utils/testUtils.ts +15 -0
- package/src/version.ts +5 -0
- package/temp/player.api.json +1950 -0
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.ts +8 -0
- package/licenses.json +0 -782
- package/src/constants.ts +0 -17
- package/src/plugins/dash-playback/_DashPlayback.js +0 -688
- package/src/typings/@clappr/plugins.d.ts +0 -23
- package/src/utils/queryParams.ts +0 -5
package/lib/constants.d.ts
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated
|
|
3
|
-
*/
|
|
4
|
-
export declare const SentryLogLevel: {
|
|
5
|
-
FATAL: string;
|
|
6
|
-
ERROR: string;
|
|
7
|
-
WARNING: string;
|
|
8
|
-
LOG: string;
|
|
9
|
-
INFO: string;
|
|
10
|
-
DEBUG: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// TODO
|
|
14
|
-
export declare enum QueryParams {
|
|
15
|
-
DEBUG = "debug",
|
|
16
|
-
NO_LOW_LATENCY = "no_low_latency",
|
|
17
|
-
SUBTITLES_LANGUAGE = "sub_lang"
|
|
18
|
-
}
|
|
19
1
|
//# sourceMappingURL=constants.d.ts.map
|
package/lib/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":""}
|
package/lib/constants.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @deprecated
|
|
3
|
-
*/
|
|
4
|
-
export const SentryLogLevel = {
|
|
5
|
-
FATAL: 'fatal',
|
|
6
|
-
ERROR: 'error',
|
|
7
|
-
WARNING: 'warning',
|
|
8
|
-
LOG: 'log',
|
|
9
|
-
INFO: 'info',
|
|
10
|
-
DEBUG: 'debug'
|
|
11
|
-
};
|
|
12
|
-
export var QueryParams;
|
|
13
|
-
(function (QueryParams) {
|
|
14
|
-
QueryParams["DEBUG"] = "debug";
|
|
15
|
-
QueryParams["NO_LOW_LATENCY"] = "no_low_latency";
|
|
16
|
-
QueryParams["SUBTITLES_LANGUAGE"] = "sub_lang";
|
|
17
|
-
})(QueryParams || (QueryParams = {}));
|
|
18
|
-
;
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { TransportPreference } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @alpha
|
|
4
|
+
*/
|
|
5
|
+
export type SrcProjectionType = 'regular' | '360' | 'vr180' | 'vr360tb';
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
export type ProjectionType = '360' | '180' | '360_TB';
|
|
10
|
+
/**
|
|
11
|
+
* Represents a media stream source with its associated metadata
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export type GcoreStreamMediaSource = {
|
|
15
|
+
/**
|
|
16
|
+
* Human-readable description of the media
|
|
17
|
+
*/
|
|
18
|
+
description: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the stream supports DVR (Digital Video Recording) functionality
|
|
21
|
+
*/
|
|
22
|
+
dvr: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* URL for HLS CMAF stream, if available
|
|
25
|
+
*/
|
|
26
|
+
hlsCmafUrl: string | null;
|
|
27
|
+
/**
|
|
28
|
+
* URL for HLS MPEG-TS stream, if available
|
|
29
|
+
*/
|
|
30
|
+
hlsMpegtsUrl: string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Unique identifier for the media source
|
|
33
|
+
*/
|
|
34
|
+
id: number;
|
|
35
|
+
/**
|
|
36
|
+
* Whether this is a live stream
|
|
37
|
+
*/
|
|
38
|
+
live: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Preferred transport protocol for this source
|
|
41
|
+
*/
|
|
42
|
+
priorityTransport: TransportPreference;
|
|
43
|
+
/**
|
|
44
|
+
* URL to the poster image
|
|
45
|
+
*/
|
|
46
|
+
poster: string | null;
|
|
47
|
+
/**
|
|
48
|
+
* The projection type for the video
|
|
49
|
+
*/
|
|
50
|
+
projection: ProjectionType | null;
|
|
51
|
+
/**
|
|
52
|
+
* URL to a preview screenshot
|
|
53
|
+
*/
|
|
54
|
+
screenshot: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Primary source URL
|
|
57
|
+
*/
|
|
58
|
+
source: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* DASH manifest URL
|
|
61
|
+
*/
|
|
62
|
+
sourceDash: string | null;
|
|
63
|
+
/**
|
|
64
|
+
* URL to the video preview sprite sheet
|
|
65
|
+
*/
|
|
66
|
+
sprite: string | null;
|
|
67
|
+
/**
|
|
68
|
+
* Title of the media
|
|
69
|
+
*/
|
|
70
|
+
title: string;
|
|
71
|
+
/**
|
|
72
|
+
* URL to the WebVTT subtitle file
|
|
73
|
+
*/
|
|
74
|
+
vtt: string | null;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* @internal Gcore internal query params
|
|
78
|
+
*/
|
|
79
|
+
export declare enum _QueryParams {
|
|
80
|
+
DEBUG = "debug",
|
|
81
|
+
NO_LOW_LATENCY = "no_low_latency",
|
|
82
|
+
SUBTITLES_LANGUAGE = "sub_lang"
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=gcore.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcore.types.d.ts","sourceRoot":"","sources":["../src/gcore.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAA;AACvE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAA;AAErD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,GAAG,EAAE,OAAO,CAAA;IAEZ;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAEzB;;OAEG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IAEb;;OAEG;IACH,iBAAiB,EAAE,mBAAmB,CAAA;IAEtC;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAErB;;OAEG;IACH,UAAU,EAAE,cAAc,GAAG,IAAI,CAAA;IAEjC;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAEzB;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAErB;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAEzB;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAErB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACnB,CAAA;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB,KAAK,UAAU;IACf,cAAc,mBAAmB;IACjC,kBAAkB,aAAa;CAChC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal Gcore internal query params
|
|
3
|
+
*/
|
|
4
|
+
export var _QueryParams;
|
|
5
|
+
(function (_QueryParams) {
|
|
6
|
+
_QueryParams["DEBUG"] = "debug";
|
|
7
|
+
_QueryParams["NO_LOW_LATENCY"] = "no_low_latency";
|
|
8
|
+
_QueryParams["SUBTITLES_LANGUAGE"] = "sub_lang";
|
|
9
|
+
})(_QueryParams || (_QueryParams = {}));
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Video player for the GCore streaming platform
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This package provides a video player for the GCore streaming platform.
|
|
6
|
+
* It is built on top of the Clappr library and provides a framework for building custom integrations.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { setTracer } from '@gcorevideo/utils';
|
|
11
|
+
export * from './Player.js';
|
|
12
|
+
export { PlaybackError } from './internal.types.js';
|
|
13
|
+
export * from './playback.types.js';
|
|
14
|
+
export * from './types.js';
|
|
15
|
+
export * from './version.js';
|
|
6
16
|
//# 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,cAAc,aAAa,CAAA;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Video player for the GCore streaming platform
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This package provides a video player for the GCore streaming platform.
|
|
6
|
+
* It is built on top of the Clappr library and provides a framework for building custom integrations.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { setTracer } from '@gcorevideo/utils';
|
|
11
|
+
export * from './Player.js';
|
|
12
|
+
export * from './playback.types.js';
|
|
13
|
+
export * from './types.js';
|
|
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 } from "./types";
|
|
2
|
+
import { PlaybackType, PlayerDebugTag, PlayerMediaSource } from "./types";
|
|
3
3
|
type ExternalTrack = {
|
|
4
4
|
kind?: "subtitles" | "captions";
|
|
5
5
|
src: string;
|
|
@@ -10,17 +10,20 @@ type MediacontrolStyles = {
|
|
|
10
10
|
seekbar?: string;
|
|
11
11
|
buttons?: string;
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export type PlayerMediaSource = string | PlayerMediaSourceDesc;
|
|
13
|
+
/**
|
|
14
|
+
* HLS.js configuration options to use with the HlsPlayback plugin.
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
18
17
|
type HlsjsConfig = {
|
|
19
18
|
debug?: boolean;
|
|
20
19
|
startLevel?: number;
|
|
21
20
|
} & Record<string, unknown>;
|
|
22
21
|
type ShakaConfig = Record<string, unknown>;
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @see {@link https://github.com/clappr/clappr-core?tab=readme-ov-file#playback-configuration | the Clappr playback settings}
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
export interface CorePlaybackConfig {
|
|
24
27
|
disableContextMenu?: boolean;
|
|
25
28
|
controls?: boolean;
|
|
26
29
|
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
@@ -31,14 +34,22 @@ type CorePlaybackConfig = {
|
|
|
31
34
|
playInline: boolean;
|
|
32
35
|
preload?: 'metadata' | 'auto' | 'none';
|
|
33
36
|
shakaConfiguration?: ShakaConfig;
|
|
34
|
-
}
|
|
37
|
+
}
|
|
35
38
|
type ErrorLevel = "FATAL" | "WARN" | "INFO";
|
|
39
|
+
/**
|
|
40
|
+
* @beta
|
|
41
|
+
*/
|
|
36
42
|
export type PlaybackError = {
|
|
37
43
|
code?: number | string;
|
|
38
44
|
description: string;
|
|
39
45
|
raw?: MediaError;
|
|
40
46
|
level?: ErrorLevel;
|
|
47
|
+
message: string;
|
|
48
|
+
scope?: string;
|
|
41
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
42
53
|
export type CorePlayerEvents = {
|
|
43
54
|
onReady?: () => void;
|
|
44
55
|
onResize?: (data: {
|
|
@@ -58,10 +69,14 @@ export type CorePlayerEvents = {
|
|
|
58
69
|
onVolumeUpdate?: (value: number) => void;
|
|
59
70
|
onSubtitleAvailable?: () => void;
|
|
60
71
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
64
75
|
export type PlaybackPluginFactory = typeof ClapprPlayback;
|
|
76
|
+
/**
|
|
77
|
+
* For the plugin development
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
65
80
|
export type CorePluginOptions = {
|
|
66
81
|
core?: CorePlugin[];
|
|
67
82
|
container?: ContainerPlugin[];
|
|
@@ -69,6 +84,10 @@ export type CorePluginOptions = {
|
|
|
69
84
|
loadExternalPluginsFirst?: boolean;
|
|
70
85
|
loadExternalPlaybacksFirst?: boolean;
|
|
71
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* For the plugin development
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
72
91
|
export type CoreOptions = {
|
|
73
92
|
actualLiveTime?: boolean;
|
|
74
93
|
actualLiveServerTime?: string;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"internal.types.d.ts","sourceRoot":"","sources":["../src/internal.types.ts"],"names":[],"mappings":"AAAA,OAAO,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AAE,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playback/index.ts"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,SAGhC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,WAE5D;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,WAE3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Loader } from '@clappr/core';
|
|
2
|
+
import DashPlayback from '../plugins/dash-playback/DashPlayback.js';
|
|
3
|
+
import HlsPlayback from '../plugins/hls-playback/HlsPlayback.js';
|
|
4
|
+
export function registerPlaybacks() {
|
|
5
|
+
Loader.registerPlayback(DashPlayback);
|
|
6
|
+
Loader.registerPlayback(HlsPlayback);
|
|
7
|
+
}
|
|
8
|
+
export function canPlayDash(source, mimeType) {
|
|
9
|
+
return DashPlayback.canPlay(source, mimeType);
|
|
10
|
+
}
|
|
11
|
+
export function canPlayHls(source, mimeType) {
|
|
12
|
+
return HlsPlayback.canPlay(source, mimeType);
|
|
13
|
+
}
|
package/lib/playback.types.d.ts
CHANGED
|
@@ -1,23 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playback time in seconds since the beginning of the stream (or a segment for the live streams)
|
|
3
|
+
* For the plugin development
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
1
6
|
export type TimeValue = number;
|
|
7
|
+
/**
|
|
8
|
+
* For the plugin development
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
2
11
|
export type TimePosition = {
|
|
3
12
|
current: TimeValue;
|
|
4
13
|
total: TimeValue;
|
|
5
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* For the plugin development
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
6
19
|
export type TimeProgress = TimePosition & {
|
|
7
20
|
start: number;
|
|
8
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* For the plugin development
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
9
26
|
export type TimeUpdate = TimePosition & {
|
|
10
27
|
firstFragDateTime: number;
|
|
11
28
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
height: number;
|
|
16
|
-
};
|
|
29
|
+
/**
|
|
30
|
+
* @beta
|
|
31
|
+
*/
|
|
17
32
|
export type QualityLevel = {
|
|
18
33
|
level: number;
|
|
19
34
|
width: number;
|
|
20
35
|
height: number;
|
|
21
36
|
bitrate: number;
|
|
22
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare enum PlaybackErrorCode {
|
|
42
|
+
Generic = 0,
|
|
43
|
+
MediaSourceUnavailable = 1,
|
|
44
|
+
QualityLevelUnavailable = 2
|
|
45
|
+
}
|
|
23
46
|
//# sourceMappingURL=playback.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playback.types.d.ts","sourceRoot":"","sources":["../src/playback.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playback.types.d.ts","sourceRoot":"","sources":["../src/playback.types.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;CAAE,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG;IACtC,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,OAAO,IAAI;IACX,sBAAsB,IAAI;IAC1B,uBAAuB,IAAI;CAC5B"}
|
package/lib/playback.types.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @beta
|
|
3
|
+
*/
|
|
4
|
+
export var PlaybackErrorCode;
|
|
5
|
+
(function (PlaybackErrorCode) {
|
|
6
|
+
PlaybackErrorCode[PlaybackErrorCode["Generic"] = 0] = "Generic";
|
|
7
|
+
PlaybackErrorCode[PlaybackErrorCode["MediaSourceUnavailable"] = 1] = "MediaSourceUnavailable";
|
|
8
|
+
PlaybackErrorCode[PlaybackErrorCode["QualityLevelUnavailable"] = 2] = "QualityLevelUnavailable";
|
|
9
|
+
})(PlaybackErrorCode || (PlaybackErrorCode = {}));
|
|
@@ -25,7 +25,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
25
25
|
_localEndTimeCorrelation: LocalTimeCorrelation | null;
|
|
26
26
|
startChangeQuality: boolean;
|
|
27
27
|
manifestInfo: IManifestInfo | null;
|
|
28
|
-
_segmentTargetDuration: TimeValue | null;
|
|
29
28
|
_timeUpdateTimer: ReturnType<typeof setInterval> | null;
|
|
30
29
|
get name(): string;
|
|
31
30
|
get levels(): QualityLevel[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashPlayback.d.ts","sourceRoot":"","sources":["../../../src/plugins/dash-playback/DashPlayback.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,UAAU,EAAO,QAAQ,EAAS,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"DashPlayback.d.ts","sourceRoot":"","sources":["../../../src/plugins/dash-playback/DashPlayback.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,UAAU,EAAO,QAAQ,EAAS,MAAM,cAAc,CAAA;AAGvE,OAAO,MAAM,EAAE,EAIb,KAAK,WAAW,IAAI,eAAe,EAEnC,aAAa,EACd,MAAM,QAAQ,CAAA;AAEf,OAAO,EAAqB,YAAY,EAAE,YAAY,EAAc,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAM9G,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,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jB,IAAI,UAAU,YASb;IAED,WAAW;IAmBX,IAAI;IAUJ,KAAK;IAWL,IAAI;IASJ,OAAO;IAkBP,mBAAmB;IAYnB,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE;IAarC,OAAO,CAAC,aAAa;IASrB,eAAe;IAIf,aAAa;CAGd"}
|
|
@@ -2,9 +2,10 @@
|
|
|
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
4
|
import { Events, HTML5Video, Log, Playback, Utils } from '@clappr/core';
|
|
5
|
+
import { trace } from '@gcorevideo/utils';
|
|
5
6
|
import assert from 'assert';
|
|
6
7
|
import DASHJS from 'dashjs';
|
|
7
|
-
import {
|
|
8
|
+
import { PlaybackErrorCode } from '../../playback.types.js';
|
|
8
9
|
const AUTO = -1;
|
|
9
10
|
const { now } = Utils;
|
|
10
11
|
const T = 'DashPlayback';
|
|
@@ -45,8 +46,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
45
46
|
_localEndTimeCorrelation = null;
|
|
46
47
|
startChangeQuality = false;
|
|
47
48
|
manifestInfo = null;
|
|
48
|
-
// #EXT-X-TARGETDURATION
|
|
49
|
-
_segmentTargetDuration = null;
|
|
50
49
|
_timeUpdateTimer = null;
|
|
51
50
|
get name() {
|
|
52
51
|
return 'dash';
|
|
@@ -67,6 +66,8 @@ export default class DashPlayback extends HTML5Video {
|
|
|
67
66
|
set currentLevel(id) {
|
|
68
67
|
this._currentLevel = id;
|
|
69
68
|
this.trigger(Events.PLAYBACK_LEVEL_SWITCH_START);
|
|
69
|
+
assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to switch levels');
|
|
70
|
+
const dash = this._dash;
|
|
70
71
|
// TODO use $.extend
|
|
71
72
|
const settings = this.options.dash ? structuredClone(this.options.dash) : {};
|
|
72
73
|
settings.streaming = settings.streaming || {};
|
|
@@ -74,8 +75,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
74
75
|
settings.streaming.abr.autoSwitchBitrate =
|
|
75
76
|
settings.streaming.abr.autoSwitchBitrate || {};
|
|
76
77
|
settings.streaming.abr.autoSwitchBitrate.video = id === -1;
|
|
77
|
-
assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to switch levels');
|
|
78
|
-
const dash = this._dash;
|
|
79
78
|
dash.updateSettings(settings);
|
|
80
79
|
if (id !== -1) {
|
|
81
80
|
this._dash.setQualityFor('video', id);
|
|
@@ -222,9 +221,6 @@ export default class DashPlayback extends HTML5Video {
|
|
|
222
221
|
return this._duration;
|
|
223
222
|
}
|
|
224
223
|
getCurrentTime() {
|
|
225
|
-
// e.g. can be < 0 if user pauses near the start
|
|
226
|
-
// eventually they will then be kicked to the end by hlsjs if they run out of buffer
|
|
227
|
-
// before the official start time
|
|
228
224
|
return this._dash ? this._dash.time() : 0;
|
|
229
225
|
}
|
|
230
226
|
// the time that "0" now represents relative to when playback started
|
|
@@ -282,85 +278,28 @@ export default class DashPlayback extends HTML5Video {
|
|
|
282
278
|
};
|
|
283
279
|
_onDASHJSSError = (event) => {
|
|
284
280
|
trace(`${T} _onDASHJSSError`, { event });
|
|
285
|
-
// TODO
|
|
286
|
-
// only report/handle errors if they are fatal
|
|
281
|
+
// TODO figure out what's for
|
|
287
282
|
this._stopTimeUpdateTimer();
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
// These errors have useful error messages, so we forward it on
|
|
309
|
-
const formattedError = this.createError(event.error);
|
|
310
|
-
this.trigger(Events.PLAYBACK_ERROR, formattedError);
|
|
311
|
-
if (event.error) {
|
|
312
|
-
Log.error(event.event.message);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
else if (event.error === 'mediasource') {
|
|
316
|
-
// This error happens when dash.js fails to allocate a SourceBuffer
|
|
317
|
-
// OR the underlying video element throws a `MediaError`.
|
|
318
|
-
// If it's a buffer allocation fail, the message states which buffer
|
|
319
|
-
// (audio/video/text) failed allocation.
|
|
320
|
-
// If it's a `MediaError`, dash.js inspects the error object for
|
|
321
|
-
// additional information to append to the error type.
|
|
322
|
-
const formattedError = this.createError(event.error);
|
|
323
|
-
this.trigger(Events.PLAYBACK_ERROR, formattedError);
|
|
324
|
-
Log.error(event.event);
|
|
325
|
-
}
|
|
326
|
-
else if (event.error === 'capability' &&
|
|
327
|
-
event.event === 'encryptedmedia') {
|
|
328
|
-
// Browser doesn't support EME
|
|
329
|
-
const formattedError = this.createError(event.error);
|
|
330
|
-
this.trigger(Events.PLAYBACK_ERROR, formattedError);
|
|
331
|
-
Log.error('The media cannot be played because it requires encryption ' +
|
|
332
|
-
'that your browser does not support.');
|
|
333
|
-
}
|
|
334
|
-
else if (event.error === 'key_session') {
|
|
335
|
-
// This block handles pretty much all errors thrown by the
|
|
336
|
-
// encryption subsystem
|
|
337
|
-
const formattedError = this.createError(event.error);
|
|
338
|
-
this.trigger(Events.PLAYBACK_ERROR, formattedError);
|
|
339
|
-
Log.error(event.event);
|
|
340
|
-
}
|
|
341
|
-
else if (event.error === 'download') {
|
|
342
|
-
const formattedError = this.createError(event.error);
|
|
343
|
-
this.trigger(Events.PLAYBACK_ERROR, formattedError);
|
|
344
|
-
Log.error('The media playback was aborted because too many consecutive ' +
|
|
345
|
-
'download errors occurred.');
|
|
346
|
-
// } else if (event.error === 'mssError') {
|
|
347
|
-
// const formattedError = this.createError(event.error);
|
|
348
|
-
// this.trigger(Events.PLAYBACK_ERROR, formattedError);
|
|
349
|
-
// if (event.error) {
|
|
350
|
-
// Log.error(event.error.message);
|
|
351
|
-
// }
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
// ignore the error
|
|
355
|
-
if (typeof event.error === 'object') {
|
|
356
|
-
const formattedError = this.createError(event.error);
|
|
357
|
-
this.trigger(Events.PLAYBACK_ERROR, formattedError);
|
|
358
|
-
Log.error(event.error.message);
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
Log.error(event.error);
|
|
362
|
-
}
|
|
363
|
-
return;
|
|
283
|
+
const e = event.error;
|
|
284
|
+
switch (e.code) {
|
|
285
|
+
case DASHJS.MediaPlayer.errors.MANIFEST_LOADER_PARSING_FAILURE_ERROR_CODE:
|
|
286
|
+
case DASHJS.MediaPlayer.errors.MANIFEST_LOADER_LOADING_FAILURE_ERROR_CODE:
|
|
287
|
+
case DASHJS.MediaPlayer.errors.DOWNLOAD_ERROR_ID_MANIFEST_CODE:
|
|
288
|
+
this.trigger(Events.PLAYBACK_ERROR, this.createError({
|
|
289
|
+
code: PlaybackErrorCode.MediaSourceUnavailable,
|
|
290
|
+
message: e.message,
|
|
291
|
+
}, {
|
|
292
|
+
useCodePrefix: false,
|
|
293
|
+
}));
|
|
294
|
+
break;
|
|
295
|
+
// TODO more cases
|
|
296
|
+
default:
|
|
297
|
+
this.trigger(Events.PLAYBACK_ERROR, this.createError({
|
|
298
|
+
code: PlaybackErrorCode.Generic,
|
|
299
|
+
message: e.message,
|
|
300
|
+
}, {
|
|
301
|
+
useCodePrefix: false,
|
|
302
|
+
}));
|
|
364
303
|
}
|
|
365
304
|
// only reset the dash player in 10ms async, so that the rest of the
|
|
366
305
|
// calling function finishes
|
|
@@ -475,6 +414,9 @@ export default class DashPlayback extends HTML5Video {
|
|
|
475
414
|
this.trigger(Events.PLAYBACK_LEVELS_AVAILABLE, this._levels);
|
|
476
415
|
}
|
|
477
416
|
onLevelSwitch(currentLevel) {
|
|
417
|
+
// TODO check the two below
|
|
418
|
+
this.trigger(Events.PLAYBACK_LEVEL_SWITCH, currentLevel);
|
|
419
|
+
this.trigger(Events.PLAYBACK_LEVEL_SWITCH_END);
|
|
478
420
|
const isHD = (currentLevel.height >= 720 || (currentLevel.bitrate / 1000) >= 2000);
|
|
479
421
|
this.trigger(Events.PLAYBACK_HIGHDEFINITIONUPDATE, isHD);
|
|
480
422
|
this.trigger(Events.PLAYBACK_BITRATE, currentLevel);
|
|
@@ -491,18 +433,12 @@ DashPlayback.canPlay = function (resource, mimeType) {
|
|
|
491
433
|
const isDash = (resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'mpd') ||
|
|
492
434
|
mimeType === 'application/dash+xml' ||
|
|
493
435
|
mimeType === 'video/mp4';
|
|
436
|
+
if (!isDash) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
494
439
|
const ms = window.MediaSource;
|
|
495
440
|
const mms = 'ManagedMediaSource' in window ? window.ManagedMediaSource : undefined;
|
|
496
441
|
const wms = 'WebKitMediaSource' in window ? window.WebKitMediaSource : undefined;
|
|
497
442
|
const ctor = ms || mms || wms;
|
|
498
|
-
|
|
499
|
-
trace(`${T} canPlay`, {
|
|
500
|
-
hasSupport,
|
|
501
|
-
isDash,
|
|
502
|
-
resource,
|
|
503
|
-
ms: typeof ms === 'function',
|
|
504
|
-
mms: typeof mms === 'function',
|
|
505
|
-
wms: typeof wms === 'function',
|
|
506
|
-
});
|
|
507
|
-
return !!(hasSupport && isDash);
|
|
443
|
+
return typeof ctor === 'function';
|
|
508
444
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/dash-playback/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,OAAO,CAAA;CACd,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTML5Video } from '@clappr/core';
|
|
2
|
-
import HLSJS, { HlsEvents, type HlsErrorData, type FragChangedData, type FragLoadedData, type FragParsingMetadataData, type LevelSwitchingData } from 'hls.js';
|
|
2
|
+
import HLSJS, { Events as HlsEvents, type ErrorData as HlsErrorData, type FragChangedData, type FragLoadedData, type FragParsingMetadataData, type LevelSwitchingData } from 'hls.js';
|
|
3
3
|
import { QualityLevel } from '../../playback.types.js';
|
|
4
4
|
import { PlaybackType } from '../../types';
|
|
5
5
|
type ErrorInfo = Record<string, unknown>;
|
|
@@ -66,10 +66,10 @@ export default class HlsPlayback extends HTML5Video {
|
|
|
66
66
|
render(): this;
|
|
67
67
|
_ready(): void;
|
|
68
68
|
_recover(evt: HlsEvents.ERROR, data: HlsErrorData, error: ErrorInfo): void;
|
|
69
|
-
|
|
69
|
+
protected _setupSrc(srcUrl: string): void;
|
|
70
70
|
_startTimeUpdateTimer(): void;
|
|
71
71
|
_stopTimeUpdateTimer(): void;
|
|
72
|
-
getProgramDateTime():
|
|
72
|
+
getProgramDateTime(): number;
|
|
73
73
|
getDuration(): number;
|
|
74
74
|
getCurrentTime(): number;
|
|
75
75
|
getStartTimeOffset(): number;
|