@gcorevideo/player 2.16.17 → 2.17.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 +93 -19
- package/dist/player.d.ts +82 -51
- package/docs/api/index.md +1 -1
- package/docs/api/player.md +2 -2
- package/docs/api/player.playbackerrorcode.md +4 -4
- 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.isplaying.md +20 -0
- package/docs/api/player.player.md +62 -8
- package/docs/api/player.player.mute.md +1 -1
- package/docs/api/player.player.off.md +1 -1
- package/docs/api/player.player.registerplugin.md +14 -1
- package/docs/api/player.player.resize.md +4 -0
- 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/lib/Player.d.ts +79 -14
- package/lib/Player.d.ts.map +1 -1
- package/lib/Player.js +91 -14
- package/lib/index.d.ts +2 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -3
- package/package.json +1 -1
- package/rollup.config.js +1 -1
- package/src/Player.ts +95 -15
- package/src/__tests__/Player.test.ts +9 -3
- package/src/index.ts +2 -3
- package/src/utils/__tests__/mediaSources.test.ts +8 -2
- package/temp/player.api.json +162 -21
- package/tsconfig.tsbuildinfo +1 -1
package/lib/Player.js
CHANGED
|
@@ -47,7 +47,7 @@ export class Player {
|
|
|
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
52
|
* @param handler - See {@link PlayerEventHandler}
|
|
53
53
|
*/
|
|
@@ -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,25 @@ 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 the playing state of the player.
|
|
167
|
+
*/
|
|
168
|
+
isPlaying() {
|
|
169
|
+
return this.player?.isPlaying() ?? false;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Mutes the sound of the video.
|
|
130
173
|
*/
|
|
131
174
|
mute() {
|
|
132
175
|
this.player?.mute();
|
|
133
176
|
}
|
|
134
177
|
/**
|
|
135
|
-
* Unmutes the
|
|
178
|
+
* Unmutes the video sound.
|
|
136
179
|
*/
|
|
137
180
|
unmute() {
|
|
138
181
|
this.player?.unmute();
|
|
@@ -152,17 +195,38 @@ export class Player {
|
|
|
152
195
|
/**
|
|
153
196
|
* Resizes the player container element and everything within it.
|
|
154
197
|
* @param newSize - new size of the player
|
|
198
|
+
* @remarks
|
|
199
|
+
* Use this method when the player itself does not detect the change in size of its container element.
|
|
200
|
+
* It can be a case for orientation change on some mobile devices.
|
|
155
201
|
*/
|
|
156
202
|
resize(newSize) {
|
|
157
203
|
this.player?.resize(newSize);
|
|
158
204
|
}
|
|
159
205
|
/**
|
|
160
206
|
* Seeks to the given time.
|
|
161
|
-
* @param time - time to seek to in seconds
|
|
207
|
+
* @param time - time to seek to in seconds (since the beginning of the stream)
|
|
162
208
|
*/
|
|
163
209
|
seek(time) {
|
|
164
210
|
this.player?.seek(time);
|
|
165
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Gets the current volume of the media content being played.
|
|
214
|
+
* @returns a number between 0 and 1
|
|
215
|
+
*/
|
|
216
|
+
getVolume() {
|
|
217
|
+
// This method is provided by the MediaControl plugin
|
|
218
|
+
// @ts-ignore
|
|
219
|
+
return this.player?.getVolume?.() || 0;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Sets the current volume of the media content being played.
|
|
223
|
+
* @param volume - a number between 0 and 1
|
|
224
|
+
*/
|
|
225
|
+
setVolume(volume) {
|
|
226
|
+
// This method is provided by the MediaControl plugin
|
|
227
|
+
// @ts-ignore
|
|
228
|
+
this.player?.setVolume?.(volume);
|
|
229
|
+
}
|
|
166
230
|
/**
|
|
167
231
|
* Stops playback.
|
|
168
232
|
*/
|
|
@@ -171,14 +235,27 @@ export class Player {
|
|
|
171
235
|
}
|
|
172
236
|
/**
|
|
173
237
|
* Registers a plugin.
|
|
174
|
-
* @param plugin - plugin
|
|
238
|
+
* @param plugin - a plugin class
|
|
239
|
+
* @remarks
|
|
240
|
+
* Use this method to extend the player with custom behavior.
|
|
241
|
+
* The plugin class must inherit from one of the Clappr UIPlugin, UIContainerPlugin or CorePlugin classes.
|
|
242
|
+
* A core plugin will be initialized and attached to the player when the player is initialized.
|
|
243
|
+
* A UI plugin will be initialized and attached to the player container is initialized.
|
|
244
|
+
*
|
|
245
|
+
* @see {@link https://github.com/clappr/clappr/wiki/Architecture}
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* import MyPlugin from './MyPlugin.js'
|
|
249
|
+
*
|
|
250
|
+
* Player.registerPlugin(MyPlugin)
|
|
251
|
+
* ```
|
|
175
252
|
*/
|
|
176
253
|
static registerPlugin(plugin) {
|
|
177
254
|
Loader.registerPlugin(plugin);
|
|
178
255
|
}
|
|
179
256
|
/**
|
|
180
|
-
* Unregisters a plugin.
|
|
181
|
-
* @param plugin - plugin
|
|
257
|
+
* Unregisters a plugin registered earlier with {@link Player.registerPlugin}.
|
|
258
|
+
* @param plugin - a plugin class
|
|
182
259
|
*/
|
|
183
260
|
static unregisterPlugin(plugin) {
|
|
184
261
|
Loader.unregisterPlugin(plugin);
|
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/package.json
CHANGED
package/rollup.config.js
CHANGED
package/src/Player.ts
CHANGED
|
@@ -19,7 +19,6 @@ import type { PlayerMediaSourceDesc, PlayerPlugin } from './types.js'
|
|
|
19
19
|
import { PlayerConfig, PlayerEvent } from './types.js'
|
|
20
20
|
import {
|
|
21
21
|
buildMediaSourcesList,
|
|
22
|
-
unwrapSource,
|
|
23
22
|
wrapSource,
|
|
24
23
|
} from './utils/mediaSources.js'
|
|
25
24
|
import { registerPlaybacks } from './playback/index.js'
|
|
@@ -89,7 +88,7 @@ export class Player {
|
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
/**
|
|
92
|
-
* Removes a
|
|
91
|
+
* Removes a previously added event listener
|
|
93
92
|
* @param event - See {@link PlayerEvent}
|
|
94
93
|
* @param handler - See {@link PlayerEventHandler}
|
|
95
94
|
*/
|
|
@@ -100,10 +99,12 @@ export class Player {
|
|
|
100
99
|
/**
|
|
101
100
|
* Configures the player.
|
|
102
101
|
*
|
|
103
|
-
* Can be called multiple times. Each consequent call extends the previous configuration.
|
|
104
|
-
* After a reconfiguration, if something significant has changed, the must be reinitialized (i.e, a `.destroy()` followed by an `.init()` call).
|
|
105
|
-
*
|
|
106
102
|
* @param config - complete or partial configuration
|
|
103
|
+
* @remarks
|
|
104
|
+
* Can be called multiple times.
|
|
105
|
+
* Each consequent call extends the previous configuration with only the new keys overridden.
|
|
106
|
+
*
|
|
107
|
+
* After a reconfiguration, if something significant has changed, it might make sense reinitialize the player (i.e, a `.destroy()` followed by an `.init()` call).
|
|
107
108
|
*/
|
|
108
109
|
configure(config: Partial<PlayerConfig>) {
|
|
109
110
|
this.setConfig(config)
|
|
@@ -112,6 +113,29 @@ export class Player {
|
|
|
112
113
|
/**
|
|
113
114
|
* Initializes the player at the given container element.
|
|
114
115
|
* @param playerElement - DOM element to host the player
|
|
116
|
+
* @remarks
|
|
117
|
+
* The player will be initialized and attached to the given element.
|
|
118
|
+
*
|
|
119
|
+
* All the core plugins will be initialized at this point.
|
|
120
|
+
*
|
|
121
|
+
* If no sources were configured, it will trigger an error.
|
|
122
|
+
*
|
|
123
|
+
* The player container will be initialized and then all the registered UI plugins.
|
|
124
|
+
*
|
|
125
|
+
* If the `autoPlay` option is set, then it will trigger playback immediately.
|
|
126
|
+
*
|
|
127
|
+
* It is an error to call this method twice. If you need to attache player to another DOM element,
|
|
128
|
+
* first call {@link Player.destroy} and then {@link Player.attachTo}.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const player = new Player({
|
|
133
|
+
* sources: [{ source: 'https://example.com/a.mpd', mimeType: 'application/dash+xml' }],
|
|
134
|
+
* })
|
|
135
|
+
* document.addEventListener('DOMContentLoaded', () => {
|
|
136
|
+
* player.attachTo(document.getElementById('video-container'))
|
|
137
|
+
* })
|
|
138
|
+
* ```
|
|
115
139
|
*/
|
|
116
140
|
attachTo(playerElement: HTMLElement): void {
|
|
117
141
|
assert.ok(!this.player, 'Player already initialized')
|
|
@@ -134,7 +158,7 @@ export class Player {
|
|
|
134
158
|
}
|
|
135
159
|
|
|
136
160
|
/**
|
|
137
|
-
* Destroys the player, releasing all resources and
|
|
161
|
+
* Destroys the player, releasing all resources and unmounting its UI from the DOM.
|
|
138
162
|
*/
|
|
139
163
|
destroy() {
|
|
140
164
|
trace(`${T} destroy`, {
|
|
@@ -153,8 +177,11 @@ export class Player {
|
|
|
153
177
|
}
|
|
154
178
|
|
|
155
179
|
/**
|
|
156
|
-
* Current playback time
|
|
157
|
-
*
|
|
180
|
+
* Current playback (time since the beginning of the stream), if appropriate.
|
|
181
|
+
*
|
|
182
|
+
* @returns Time in seconds
|
|
183
|
+
* @remarks
|
|
184
|
+
* For live streams, it returns the current time within the current segment.
|
|
158
185
|
*/
|
|
159
186
|
getCurrentTime(): number {
|
|
160
187
|
if (!this.player) {
|
|
@@ -165,7 +192,10 @@ export class Player {
|
|
|
165
192
|
|
|
166
193
|
/**
|
|
167
194
|
* Duration of the current media in seconds, if appropriate.
|
|
168
|
-
*
|
|
195
|
+
*
|
|
196
|
+
* @returns Time in seconds
|
|
197
|
+
* @remarks
|
|
198
|
+
* For live streams, it returns the duration of the current segment.
|
|
169
199
|
*/
|
|
170
200
|
getDuration(): number {
|
|
171
201
|
if (!this.player) {
|
|
@@ -175,14 +205,28 @@ export class Player {
|
|
|
175
205
|
}
|
|
176
206
|
|
|
177
207
|
/**
|
|
178
|
-
*
|
|
208
|
+
* Indicates whether DVR is enabled.
|
|
209
|
+
*/
|
|
210
|
+
isDvrEnabled(): boolean {
|
|
211
|
+
return this.player?.isDvrEnabled() ?? false
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Indicates the playing state of the player.
|
|
216
|
+
*/
|
|
217
|
+
isPlaying(): boolean {
|
|
218
|
+
return this.player?.isPlaying() ?? false
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Mutes the sound of the video.
|
|
179
223
|
*/
|
|
180
224
|
mute() {
|
|
181
225
|
this.player?.mute()
|
|
182
226
|
}
|
|
183
227
|
|
|
184
228
|
/**
|
|
185
|
-
* Unmutes the
|
|
229
|
+
* Unmutes the video sound.
|
|
186
230
|
*/
|
|
187
231
|
unmute() {
|
|
188
232
|
this.player?.unmute()
|
|
@@ -205,6 +249,9 @@ export class Player {
|
|
|
205
249
|
/**
|
|
206
250
|
* Resizes the player container element and everything within it.
|
|
207
251
|
* @param newSize - new size of the player
|
|
252
|
+
* @remarks
|
|
253
|
+
* Use this method when the player itself does not detect the change in size of its container element.
|
|
254
|
+
* It can be a case for orientation change on some mobile devices.
|
|
208
255
|
*/
|
|
209
256
|
resize(newSize: { width: number; height: number }) {
|
|
210
257
|
this.player?.resize(newSize)
|
|
@@ -212,12 +259,32 @@ export class Player {
|
|
|
212
259
|
|
|
213
260
|
/**
|
|
214
261
|
* Seeks to the given time.
|
|
215
|
-
* @param time - time to seek to in seconds
|
|
262
|
+
* @param time - time to seek to in seconds (since the beginning of the stream)
|
|
216
263
|
*/
|
|
217
264
|
seek(time: number) {
|
|
218
265
|
this.player?.seek(time)
|
|
219
266
|
}
|
|
220
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Gets the current volume of the media content being played.
|
|
270
|
+
* @returns a number between 0 and 1
|
|
271
|
+
*/
|
|
272
|
+
getVolume(): number {
|
|
273
|
+
// This method is provided by the MediaControl plugin
|
|
274
|
+
// @ts-ignore
|
|
275
|
+
return this.player?.getVolume?.() || 0
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Sets the current volume of the media content being played.
|
|
280
|
+
* @param volume - a number between 0 and 1
|
|
281
|
+
*/
|
|
282
|
+
setVolume(volume: number) {
|
|
283
|
+
// This method is provided by the MediaControl plugin
|
|
284
|
+
// @ts-ignore
|
|
285
|
+
this.player?.setVolume?.(volume)
|
|
286
|
+
}
|
|
287
|
+
|
|
221
288
|
/**
|
|
222
289
|
* Stops playback.
|
|
223
290
|
*/
|
|
@@ -227,15 +294,28 @@ export class Player {
|
|
|
227
294
|
|
|
228
295
|
/**
|
|
229
296
|
* Registers a plugin.
|
|
230
|
-
* @param plugin - plugin
|
|
297
|
+
* @param plugin - a plugin class
|
|
298
|
+
* @remarks
|
|
299
|
+
* Use this method to extend the player with custom behavior.
|
|
300
|
+
* The plugin class must inherit from one of the Clappr UIPlugin, UIContainerPlugin or CorePlugin classes.
|
|
301
|
+
* A core plugin will be initialized and attached to the player when the player is initialized.
|
|
302
|
+
* A UI plugin will be initialized and attached to the player container is initialized.
|
|
303
|
+
*
|
|
304
|
+
* @see {@link https://github.com/clappr/clappr/wiki/Architecture}
|
|
305
|
+
* @example
|
|
306
|
+
* ```ts
|
|
307
|
+
* import MyPlugin from './MyPlugin.js'
|
|
308
|
+
*
|
|
309
|
+
* Player.registerPlugin(MyPlugin)
|
|
310
|
+
* ```
|
|
231
311
|
*/
|
|
232
312
|
static registerPlugin(plugin: PlayerPlugin) {
|
|
233
313
|
Loader.registerPlugin(plugin)
|
|
234
314
|
}
|
|
235
315
|
|
|
236
316
|
/**
|
|
237
|
-
* Unregisters a plugin.
|
|
238
|
-
* @param plugin - plugin
|
|
317
|
+
* Unregisters a plugin registered earlier with {@link Player.registerPlugin}.
|
|
318
|
+
* @param plugin - a plugin class
|
|
239
319
|
*/
|
|
240
320
|
static unregisterPlugin(plugin: PlayerPlugin) {
|
|
241
321
|
Loader.unregisterPlugin(plugin)
|
|
@@ -34,21 +34,27 @@ vi.mock('@clappr/core', async () => {
|
|
|
34
34
|
const imported = await import('@clappr/core')
|
|
35
35
|
const MockDashPlayback = {
|
|
36
36
|
_supported: true,
|
|
37
|
-
|
|
37
|
+
prototype: {
|
|
38
|
+
name: 'dash',
|
|
39
|
+
},
|
|
38
40
|
canPlay(source, mimeType) {
|
|
39
41
|
return this._supported && (mimeType === 'application/dash+xml' || source.endsWith('.mpd'))
|
|
40
42
|
},
|
|
41
43
|
}
|
|
42
44
|
const MockHlsPlayback = {
|
|
43
45
|
_supported: true,
|
|
44
|
-
|
|
46
|
+
prototype: {
|
|
47
|
+
name: 'hls',
|
|
48
|
+
},
|
|
45
49
|
canPlay(source, mimeType) {
|
|
46
50
|
return this._supported && (['application/vnd.apple.mpegurl', 'application/x-mpegurl'].includes(mimeType) || source.endsWith('.m3u8'))
|
|
47
51
|
},
|
|
48
52
|
}
|
|
49
53
|
const MockHTML5VideoPlayback = {
|
|
50
54
|
_supported: true,
|
|
51
|
-
|
|
55
|
+
prototype: {
|
|
56
|
+
name: 'html5_video',
|
|
57
|
+
},
|
|
52
58
|
canPlay(source, mimeType) {
|
|
53
59
|
return this._supported && ['video/mp4', 'application/vnd.apple.mpegurl'].includes(mimeType)
|
|
54
60
|
},
|
package/src/index.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
|
|
@@ -12,5 +12,4 @@ export { LogTracer, Logger, SentryTracer, reportError, setTracer, trace } from '
|
|
|
12
12
|
export * from './Player.js'
|
|
13
13
|
export * from './playback.types.js'
|
|
14
14
|
export * from './types.js'
|
|
15
|
-
export * from './utils/mediaSources.js'
|
|
16
15
|
export * from './version.js'
|
|
@@ -10,21 +10,27 @@ vi.mock('@clappr/core', () => ({
|
|
|
10
10
|
registeredPlaybacks: [
|
|
11
11
|
{
|
|
12
12
|
_supported: true,
|
|
13
|
+
prototype: {
|
|
13
14
|
name: 'dash',
|
|
15
|
+
},
|
|
14
16
|
canPlay(source, mimeType) {
|
|
15
17
|
return this._supported && (mimeType === 'application/dash+xml' || source.endsWith('.mpd'))
|
|
16
18
|
},
|
|
17
19
|
},
|
|
18
20
|
{
|
|
19
21
|
_supported: true,
|
|
20
|
-
|
|
22
|
+
prototype: {
|
|
23
|
+
name: 'hls',
|
|
24
|
+
},
|
|
21
25
|
canPlay(source, mimeType) {
|
|
22
26
|
return this._supported && (['application/vnd.apple.mpegurl', 'application/x-mpegurl'].includes(mimeType) || source.endsWith('.m3u8'))
|
|
23
27
|
},
|
|
24
28
|
},
|
|
25
29
|
{
|
|
26
30
|
_supported: true,
|
|
27
|
-
|
|
31
|
+
prototype: {
|
|
32
|
+
name: 'html5_video',
|
|
33
|
+
},
|
|
28
34
|
canPlay: function (source, mimeType) {
|
|
29
35
|
return this._supported && mimeType === 'video/mp4'
|
|
30
36
|
},
|