@gcorevideo/player 2.8.2 → 2.10.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.
Files changed (103) hide show
  1. package/README.md +39 -0
  2. package/api-extractor.json +454 -0
  3. package/dist/index.js +1032 -182
  4. package/dist/player.d.ts +407 -0
  5. package/docs/api/index.md +31 -0
  6. package/docs/api/player.dashsettings.md +16 -0
  7. package/docs/api/player.langtag.md +15 -0
  8. package/docs/api/player.md +295 -0
  9. package/docs/api/player.mediatransport.md +15 -0
  10. package/docs/api/player.playbackmodule.md +15 -0
  11. package/docs/api/player.playbacktype.md +16 -0
  12. package/docs/api/player.player._constructor_.md +50 -0
  13. package/docs/api/player.player.attachto.md +56 -0
  14. package/docs/api/player.player.configure.md +58 -0
  15. package/docs/api/player.player.destroy.md +20 -0
  16. package/docs/api/player.player.getcurrenttime.md +22 -0
  17. package/docs/api/player.player.getduration.md +22 -0
  18. package/docs/api/player.player.md +304 -0
  19. package/docs/api/player.player.mute.md +20 -0
  20. package/docs/api/player.player.off.md +72 -0
  21. package/docs/api/player.player.on.md +72 -0
  22. package/docs/api/player.player.pause.md +20 -0
  23. package/docs/api/player.player.play.md +20 -0
  24. package/docs/api/player.player.registerplugin.md +56 -0
  25. package/docs/api/player.player.resize.md +59 -0
  26. package/docs/api/player.player.seek.md +56 -0
  27. package/docs/api/player.player.stop.md +20 -0
  28. package/docs/api/player.player.unmute.md +20 -0
  29. package/docs/api/player.player.unregisterplugin.md +56 -0
  30. package/docs/api/player.playerconfig.autoplay.md +16 -0
  31. package/docs/api/player.playerconfig.dash.md +16 -0
  32. package/docs/api/player.playerconfig.debug.md +16 -0
  33. package/docs/api/player.playerconfig.language.md +16 -0
  34. package/docs/api/player.playerconfig.loop.md +16 -0
  35. package/docs/api/player.playerconfig.md +266 -0
  36. package/docs/api/player.playerconfig.mute.md +16 -0
  37. package/docs/api/player.playerconfig.playbacktype.md +16 -0
  38. package/docs/api/player.playerconfig.prioritytransport.md +16 -0
  39. package/docs/api/player.playerconfig.sources.md +16 -0
  40. package/docs/api/player.playerconfig.strings.md +16 -0
  41. package/docs/api/player.playerdebugsettings.md +20 -0
  42. package/docs/api/player.playerdebugtag.md +15 -0
  43. package/docs/api/player.playerevent.md +116 -0
  44. package/docs/api/player.playereventhandler.md +17 -0
  45. package/docs/api/player.playermediasource.md +18 -0
  46. package/docs/api/player.playermediasourcedesc.md +83 -0
  47. package/docs/api/player.playermediasourcedesc.mimetype.md +16 -0
  48. package/docs/api/player.playermediasourcedesc.source.md +16 -0
  49. package/docs/api/player.playerplugin.md +17 -0
  50. package/docs/api/player.qualitylevel.md +20 -0
  51. package/docs/api/player.translationkey.md +15 -0
  52. package/docs/api/player.translationsettings.md +35 -0
  53. package/docs/api/player.transportpreference.md +17 -0
  54. package/docs/api/player.version.md +27 -0
  55. package/lib/Player.d.ts +83 -5
  56. package/lib/Player.d.ts.map +1 -1
  57. package/lib/Player.js +99 -25
  58. package/lib/constants.d.ts +0 -18
  59. package/lib/constants.d.ts.map +1 -1
  60. package/lib/constants.js +1 -18
  61. package/lib/gcore.types.d.ts +84 -0
  62. package/lib/gcore.types.d.ts.map +1 -0
  63. package/lib/gcore.types.js +9 -0
  64. package/lib/index.d.ts +10 -5
  65. package/lib/index.d.ts.map +1 -1
  66. package/lib/index.js +10 -5
  67. package/lib/internal.types.d.ts +28 -11
  68. package/lib/internal.types.d.ts.map +1 -1
  69. package/lib/playback.types.d.ts +19 -5
  70. package/lib/playback.types.d.ts.map +1 -1
  71. package/lib/plugins/dash-playback/DashPlayback.js +1 -1
  72. package/lib/plugins/hls-playback/HlsPlayback.js +1 -1
  73. package/lib/tsdoc-metadata.json +11 -0
  74. package/lib/types.d.ts +179 -62
  75. package/lib/types.d.ts.map +1 -1
  76. package/lib/types.js +19 -0
  77. package/lib/utils/mediaSources.d.ts +1 -3
  78. package/lib/utils/mediaSources.d.ts.map +1 -1
  79. package/lib/utils/mediaSources.js +0 -9
  80. package/lib/version.d.ts +5 -0
  81. package/lib/version.d.ts.map +1 -1
  82. package/lib/version.js +5 -0
  83. package/package.json +6 -1
  84. package/src/Player.ts +113 -32
  85. package/src/index.ts +11 -5
  86. package/src/internal.types.ts +28 -15
  87. package/src/playback.types.ts +20 -6
  88. package/src/plugins/dash-playback/DashPlayback.ts +1 -1
  89. package/src/plugins/hls-playback/HlsPlayback.ts +1 -1
  90. package/src/types.ts +196 -74
  91. package/src/utils/mediaSources.ts +1 -15
  92. package/src/version.ts +5 -0
  93. package/temp/player.api.json +1950 -0
  94. package/tsconfig.tsbuildinfo +1 -1
  95. package/src/constants.ts +0 -17
  96. package/src/plugins/dash-playback/_DashPlayback.js +0 -688
  97. package/src/trace/LogTracer.ts +0 -23
  98. package/src/trace/SentryTracer.ts +0 -21
  99. package/src/trace/Tracer.ts +0 -27
  100. package/src/trace/index.ts +0 -32
  101. package/src/trace/types.ts +0 -7
  102. package/src/typings/@clappr/plugins.d.ts +0 -23
  103. package/src/utils/Logger.ts +0 -107
@@ -0,0 +1,407 @@
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
+
11
+ import { setTracer } from '@gcorevideo/utils';
12
+
13
+ /**
14
+ * @beta
15
+ * {@link https://cdn.dashjs.org/latest/jsdoc/module-Settings.html | DASH.js settings}
16
+ */
17
+ export declare type DashSettings = Record<string, unknown>;
18
+
19
+ /**
20
+ * @beta
21
+ */
22
+ export declare type LangTag = string;
23
+
24
+ /**
25
+ * @beta
26
+ */
27
+ export declare type MediaTransport = 'dash' | 'hls' | 'mpegts';
28
+
29
+ /**
30
+ * @beta
31
+ */
32
+ export declare type PlaybackModule = 'dash' | 'hls' | 'native';
33
+
34
+ /**
35
+ * Type of a stream playback
36
+ * @beta
37
+ */
38
+ export declare type PlaybackType = 'live' | 'vod';
39
+
40
+ /**
41
+ * The main component to use in the application code.
42
+ * @remarks
43
+ * The Player object provides very basic API to control playback.
44
+ * To build a sophisticated UI, use the plugins framework to tap into the Clappr core.
45
+ * {@link https://github.com/clappr/clappr/wiki/Architecture}
46
+ * @beta
47
+ */
48
+ export declare class Player {
49
+ private config;
50
+ private emitter;
51
+ private player;
52
+ private ready;
53
+ private rootNode;
54
+ private tuneInTimerId;
55
+ private tunedIn;
56
+ constructor(config: PlayerConfig);
57
+ /**
58
+ * Adds a listener to a player event
59
+ * @param event - See {@link PlayerEvent}
60
+ * @param handler - See {@link PlayerEventHandler}
61
+ */
62
+ on<T extends PlayerEvent>(event: T, handler: PlayerEventHandler<T>): void;
63
+ /**
64
+ * Removes a listener from a player event
65
+ * @param event - See {@link PlayerEvent}
66
+ * @param handler - See {@link PlayerEventHandler}
67
+ */
68
+ off<T extends PlayerEvent>(event: T, handler: PlayerEventHandler<T>): void;
69
+ /**
70
+ * Configures the player.
71
+ *
72
+ * Can be called multiple times. Each consequent call extends the previous configuration.
73
+ * After a reconfiguration, if something significant has changed, the must be reinitialized (i.e, a `.destroy()` followed by an `.init()` call).
74
+ *
75
+ * @param config - complete or partial configuration
76
+ */
77
+ configure(config: Partial<PlayerConfig>): void;
78
+ /**
79
+ * Initializes the player at the given container element.
80
+ * @param playerElement - DOM element to host the player
81
+ */
82
+ attachTo(playerElement: HTMLElement): void;
83
+ /**
84
+ * Destroys the player, releasing all resources and removing any DOM elements added.
85
+ */
86
+ destroy(): void;
87
+ /**
88
+ * Current playback time in seconds, if appropriate.
89
+ * @returns For live streams, it returns the current time of the current segment.
90
+ */
91
+ getCurrentTime(): number;
92
+ /**
93
+ * Duration of the current media in seconds, if appropriate.
94
+ * @returns For live streams, it returns the duration of the current segment.
95
+ */
96
+ getDuration(): number;
97
+ /**
98
+ * Mutes the player.
99
+ */
100
+ mute(): void;
101
+ /**
102
+ * Unmutes the player.
103
+ */
104
+ unmute(): void;
105
+ /**
106
+ * Pauses playback.
107
+ */
108
+ pause(): void;
109
+ /**
110
+ * Starts playback.
111
+ */
112
+ play(): void;
113
+ /**
114
+ * Resizes the player container element and everything within it.
115
+ * @param newSize - new size of the player
116
+ */
117
+ resize(newSize: {
118
+ width: number;
119
+ height: number;
120
+ }): void;
121
+ /**
122
+ * Seeks to the given time.
123
+ * @param time - time to seek to in seconds
124
+ */
125
+ seek(time: number): void;
126
+ /**
127
+ * Stops playback.
128
+ */
129
+ stop(): void;
130
+ /**
131
+ * Registers a plugin.
132
+ * @param plugin - plugin to register
133
+ */
134
+ static registerPlugin(plugin: PlayerPlugin): void;
135
+ /**
136
+ * Unregisters a plugin.
137
+ * @param plugin - plugin to unregister
138
+ */
139
+ static unregisterPlugin(plugin: PlayerPlugin): void;
140
+ private setConfig;
141
+ private initPlayer;
142
+ private tuneIn;
143
+ private events;
144
+ private buildCoreOptions;
145
+ private configurePlaybacks;
146
+ private selectMediaSource;
147
+ }
148
+
149
+ /**
150
+ * Configuration options for the player
151
+ *
152
+ * @remarks
153
+ * You can specify multiple sources, each in two forms: just a plain URL or a full object with `source` and `mimeType` fields {@link PlayerMediaSource}.
154
+ * The player will pick the first viable media source according to the source availability, and either the transport preference or standard transport selection order.
155
+ *
156
+ * `priorityTransport` is used to specify the preferred transport protocol
157
+ * when multiple sources are available.
158
+ * It will first try to use the transport specified if it's supported (by a playback engine) and the source is available.
159
+ * Otherwise it will try the other transports in the regular order (dash, hls, mpegts).
160
+ *
161
+ * The `autoPlay` option should be used together with the {@link PlayerConfig.mute | mute} to avoid issues with the browsers' autoplay policies.
162
+ *
163
+ * Note that the `playbackType` is specified explicitly in the examle below, but a playback engine might be able to detect the type of the stream automatically.
164
+ *
165
+ * A plugin options can be specified in the configuration object under a unique key, typically corresponding to the plugin name.
166
+ * The plugin object will have access to the internal normalized configuration object that contains all the custom options.
167
+ * in the examle below, the `poster` field is the `Poster` plugin configuration options.
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * {
172
+ * autoPlay: true,
173
+ * mute: true,
174
+ * playbackType: 'live',
175
+ * priorityTransport: 'dash',
176
+ * sources: [{
177
+ * source: 'https://example.com/myownair66.mpd',
178
+ * mimeType: 'application/dash+xml',
179
+ * }, {
180
+ * source: 'https://example.com/myownair66.m3u8',
181
+ * mimeType: 'application/x-mpegURL',
182
+ * }],
183
+ * poster: {
184
+ * url: settings.poster,
185
+ * },
186
+ * }
187
+ * ```
188
+ * @beta
189
+ */
190
+ export declare interface PlayerConfig extends Record<string, unknown> {
191
+ /**
192
+ * Start playback automatically when the player is ready
193
+ * @defaultValue false
194
+ */
195
+ autoPlay?: boolean;
196
+ /**
197
+ * Configuration settings for the DASH playback engine
198
+ * @defaultValue \{\}
199
+ * {@link https://cdn.dashjs.org/latest/jsdoc/module-Settings.html}
200
+ */
201
+ dash?: DashSettings;
202
+ /**
203
+ * Controls the debug output level
204
+ * @defaultValue 'none'
205
+ */
206
+ debug?: PlayerDebugSettings;
207
+ /**
208
+ * A language code for the player UI, for example, `es`. Must reference a key in the {@link PlayerConfig.strings | strings} record.
209
+ * @defaultValue 'en'
210
+ */
211
+ language?: string;
212
+ /**
213
+ * Repeat playback when the media ends.
214
+ * Is used with the `vod` {@link PlayerConfig.playbackType | playbackType}
215
+ * @defaultValue false
216
+ */
217
+ loop?: boolean;
218
+ /**
219
+ * Mute the audio output in order to comply with browsers' autoplay policy.
220
+ * @defaultValue false
221
+ */
222
+ mute?: boolean;
223
+ /**
224
+ * The type of playback (live stream or video on demand).
225
+ *
226
+ * @defaultValue 'vod'
227
+ */
228
+ playbackType?: PlaybackType;
229
+ /**
230
+ * Preferred transport protocol when multiple sources are available.
231
+ * @defaultValue 'auto'
232
+ */
233
+ priorityTransport?: TransportPreference;
234
+ /**
235
+ * List of media sources, at least one is required.
236
+ */
237
+ sources: PlayerMediaSource[];
238
+ /**
239
+ * Localization strings for the player UI.
240
+ */
241
+ strings: TranslationSettings;
242
+ }
243
+
244
+ /**
245
+ * @remarks true is equivalent to 'all', false is equivalent to 'none'
246
+ * @beta
247
+ */
248
+ export declare type PlayerDebugSettings = PlayerDebugTag | boolean;
249
+
250
+ /**
251
+ * @beta
252
+ */
253
+ export declare type PlayerDebugTag = 'all' | 'clappr' | 'dash' | 'hls' | 'none';
254
+
255
+ /**
256
+ * A top-level event on the player object
257
+ * @beta
258
+ */
259
+ export declare enum PlayerEvent {
260
+ /**
261
+ * The player is ready to use.
262
+ */
263
+ Ready = "ready",
264
+ /**
265
+ * Playback has started.
266
+ */
267
+ Play = "play",
268
+ /**
269
+ * Playback has been paused.
270
+ */
271
+ Pause = "pause",
272
+ /**
273
+ * Playback has been stopped.
274
+ */
275
+ Stop = "stop",
276
+ /**
277
+ * Playback has reached the end of the media.
278
+ */
279
+ Ended = "ended"
280
+ }
281
+
282
+ /**
283
+ * @beta
284
+ */
285
+ export declare type PlayerEventHandler<T extends PlayerEvent> = () => void;
286
+
287
+ /**
288
+ * A media source to fetch the media data from
289
+ * @beta
290
+ */
291
+ export declare type PlayerMediaSource = string | PlayerMediaSourceDesc;
292
+
293
+ /**
294
+ * Describes a media source with its MIME type and URL.
295
+ *
296
+ * @remarks
297
+ * When the MIME type is provided, it helps the player determine the appropriate playback engine.
298
+ * If omitted, the player will attempt to detect the type from the source URL extension.
299
+ * @beta
300
+ */
301
+ export declare interface PlayerMediaSourceDesc {
302
+ /**
303
+ * The MIME type of the media source (e.g. "video/mp4", "application/x-mpegURL")
304
+ */
305
+ mimeType?: string;
306
+ /**
307
+ * URL of the media source
308
+ */
309
+ source: string;
310
+ }
311
+
312
+ /**
313
+ * @beta
314
+ * @see {@link https://clappr.github.io/classes/UIContainerPlugin.html}, {@link https://clappr.github.io/classes/ContainerPlugin.html}
315
+ */
316
+ export declare type PlayerPlugin = {
317
+ new (...args: any[]): unknown;
318
+ type: 'core' | 'container';
319
+ };
320
+
321
+ /**
322
+ * @beta
323
+ */
324
+ export declare type QualityLevel = {
325
+ level: number;
326
+ width: number;
327
+ height: number;
328
+ bitrate: number;
329
+ };
330
+
331
+ export { setTracer }
332
+
333
+ /**
334
+ * For the plugin development
335
+ * @internal
336
+ */
337
+ export declare type TimePosition = {
338
+ current: TimeValue;
339
+ total: TimeValue;
340
+ };
341
+
342
+ /**
343
+ * For the plugin development
344
+ * @internal
345
+ */
346
+ export declare type TimeProgress = TimePosition & {
347
+ start: number;
348
+ };
349
+
350
+ /**
351
+ * For the plugin development
352
+ * @internal
353
+ */
354
+ export declare type TimeUpdate = TimePosition & {
355
+ firstFragDateTime: number;
356
+ };
357
+
358
+ /**
359
+ * For the plugin development
360
+ * @internal
361
+ */
362
+ export declare type TimeValue = number;
363
+
364
+ /**
365
+ * @beta
366
+ */
367
+ export declare type TranslationKey = string;
368
+
369
+ /**
370
+ * [language][key] =\> string
371
+ * @example
372
+ * ```
373
+ * {
374
+ * en: {
375
+ * play: 'Play',
376
+ * ...
377
+ * },
378
+ * es: {
379
+ * play: 'Reproducir',
380
+ * ...
381
+ * },
382
+ * ...
383
+ * }
384
+ * ```
385
+ *
386
+ * @beta
387
+ */
388
+ export declare type TranslationSettings = Partial<Record<LangTag, Record<TranslationKey, string>>>;
389
+
390
+ /**
391
+ * @beta
392
+ */
393
+ export declare type TransportPreference = MediaTransport | 'auto';
394
+
395
+ /**
396
+ * Version information about the gplayer and its main dependencies
397
+ * @returns Version information about the gplayer and its main dependencies
398
+ * @beta
399
+ */
400
+ export declare function version(): {
401
+ gplayer: string;
402
+ clappr: string;
403
+ dashjs: string;
404
+ hlsjs: string;
405
+ };
406
+
407
+ export { }
@@ -0,0 +1,31 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md)
4
+
5
+ ## API Reference
6
+
7
+ ## Packages
8
+
9
+ <table><thead><tr><th>
10
+
11
+ Package
12
+
13
+
14
+ </th><th>
15
+
16
+ Description
17
+
18
+
19
+ </th></tr></thead>
20
+ <tbody><tr><td>
21
+
22
+ [@gcorevideo/player](./player.md)
23
+
24
+
25
+ </td><td>
26
+
27
+ Video player for the GCore streaming platform
28
+
29
+
30
+ </td></tr>
31
+ </tbody></table>
@@ -0,0 +1,16 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [DashSettings](./player.dashsettings.md)
4
+
5
+ ## DashSettings type
6
+
7
+ > This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
8
+ >
9
+
10
+ [DASH.js settings](https://cdn.dashjs.org/latest/jsdoc/module-Settings.html)
11
+
12
+ **Signature:**
13
+
14
+ ```typescript
15
+ export type DashSettings = Record<string, unknown>;
16
+ ```
@@ -0,0 +1,15 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [LangTag](./player.langtag.md)
4
+
5
+ ## LangTag type
6
+
7
+ > This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
8
+ >
9
+
10
+
11
+ **Signature:**
12
+
13
+ ```typescript
14
+ export type LangTag = string;
15
+ ```