@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.
Files changed (37) hide show
  1. package/README.md +68 -19
  2. package/dist/index.js +93 -19
  3. package/dist/player.d.ts +82 -51
  4. package/docs/api/index.md +1 -1
  5. package/docs/api/player.md +2 -2
  6. package/docs/api/player.playbackerrorcode.md +4 -4
  7. package/docs/api/player.player.attachto.md +26 -0
  8. package/docs/api/player.player.configure.md +6 -2
  9. package/docs/api/player.player.destroy.md +1 -1
  10. package/docs/api/player.player.getcurrenttime.md +6 -2
  11. package/docs/api/player.player.getduration.md +4 -0
  12. package/docs/api/player.player.getvolume.md +22 -0
  13. package/docs/api/player.player.isdvrenabled.md +20 -0
  14. package/docs/api/player.player.isplaying.md +20 -0
  15. package/docs/api/player.player.md +62 -8
  16. package/docs/api/player.player.mute.md +1 -1
  17. package/docs/api/player.player.off.md +1 -1
  18. package/docs/api/player.player.registerplugin.md +14 -1
  19. package/docs/api/player.player.resize.md +4 -0
  20. package/docs/api/player.player.seek.md +1 -1
  21. package/docs/api/player.player.setvolume.md +56 -0
  22. package/docs/api/player.player.unmute.md +1 -1
  23. package/docs/api/player.player.unregisterplugin.md +2 -2
  24. package/lib/Player.d.ts +79 -14
  25. package/lib/Player.d.ts.map +1 -1
  26. package/lib/Player.js +91 -14
  27. package/lib/index.d.ts +2 -3
  28. package/lib/index.d.ts.map +1 -1
  29. package/lib/index.js +2 -3
  30. package/package.json +1 -1
  31. package/rollup.config.js +1 -1
  32. package/src/Player.ts +95 -15
  33. package/src/__tests__/Player.test.ts +9 -3
  34. package/src/index.ts +2 -3
  35. package/src/utils/__tests__/mediaSources.test.ts +8 -2
  36. package/temp/player.api.json +162 -21
  37. package/tsconfig.tsbuildinfo +1 -1
package/README.md CHANGED
@@ -6,33 +6,82 @@
6
6
  npm install @gcorevideo/player
7
7
  ```
8
8
 
9
+ Or use a script on the CDN directly in your HTML:
10
+
11
+ ```html
12
+ <script src="https://player.gvideo.co/v2/assets/player/2.16.7/index.js"></script>
13
+ ```
14
+
15
+ See also the [plugins package](../player-plugins/README.md) which almost always used with the player.
16
+
9
17
  ## Usage
10
18
 
11
- ```ts
12
- import { Player } from '@gcorevideo/player'
19
+ See the complete example app on Vercel: [https://github.com/dmitritz/gcore-videoplayer-js-nuxt](https://github.com/dmitritz/gcore-videoplayer-js-nuxt)
13
20
 
14
- import { MyFancyPlugin } from './plugins/my-fancy-plugin'
21
+ ### Plain HTML example
15
22
 
16
- Player.registerPlugin(MyFancyPlugin)
23
+ ```html
24
+ <html>
25
+ <head>
26
+ <link rel="stylesheet" href="https://player.gvideo.co/v2/assets/player-plugins/0.10.2/index.css" />
27
+ ...
28
+ <style>
29
+ #container {
30
+ width: 100%;
31
+ height: 0;
32
+ padding-bottom: 56.25%;
33
+ position: relative;
34
+ background-color:black;
35
+ color:#fff
36
+ }
37
+ #wrapper {
38
+ max-width: 400px;
39
+ margin: 1rem auto;
40
+ }
41
+ </style>
42
+ </head>
43
+ <body>
44
+ <div id="wrapper">
45
+ <div id="container"></div>
46
+ </div>
47
+ <script type="module">
48
+ import {
49
+ Player,
50
+ } from 'https://player.gvideo.co/v2/assets/player/2.16.7/index.js'
51
+ import {
52
+ MediaControl,
53
+ SourceController,
54
+ Spinner,
55
+ } from 'https://player.gvideo.co/v2/assets/player-plugins/0.10.2/index.js'
17
56
 
18
- const player = new Player({
19
- autoPlay: true,
20
- mute: true,
21
- sources: [{
22
- source: 'https://example.com/myownair66.mpd',
23
- mimeType: 'application/dash+xml',
24
- }],
25
- myFancyPlugin: {
26
- color: 'rainbow',
27
- }
28
- })
57
+ Player.registerPlugin(MediaControl)
58
+ Player.registerPlugin(SourceController)
59
+ Player.registerPlugin(Spinner)
29
60
 
30
- document.addEventListener('DOMContentLoaded', () => {
31
- player.attachTo(document.getElementById('video-container'))
32
- })
61
+ const player = new Player({
62
+ autoPlay: true,
63
+ mute: true,
64
+ sources: [{
65
+ source: 'https://demo.gvideo.io/cmaf/2675_19146/index.mpd,
66
+ type: 'application/dash+xml',
67
+ }, {
68
+ source: 'https://demo.gvideo.io/cmaf/2675_19146/master.m3u8',
69
+ type: 'application/x-mpegURL',
70
+ }],
71
+ spinner: {
72
+ showOnError: true,
73
+ showOnStart: true,
74
+ }
75
+ })
76
+ document.addEventListener('DOMContentLoaded', () => {
77
+ player.attachTo(document.getElementById('container'))
78
+ })
79
+ </script>
80
+ </body>
81
+ </html>
33
82
  ```
34
83
 
35
- See the complete example app on Vercel: [https://github.com/dmitritz/gcore-videoplayer-js-nuxt](https://github.com/dmitritz/gcore-videoplayer-js-nuxt)
84
+ [Example codepen](https://codepen.io/dmitritz/pen/OPLdEab)
36
85
 
37
86
  ## Documentation
38
87
 
package/dist/index.js CHANGED
@@ -12273,9 +12273,6 @@ function buildMediaSourcesList(sources, priorityTransport = 'dash') {
12273
12273
  }, [[], []]);
12274
12274
  return preferred.concat(rest);
12275
12275
  }
12276
- function unwrapSource(s) {
12277
- return typeof s === 'string' ? s : s.source;
12278
- }
12279
12276
  function wrapSource(s) {
12280
12277
  return typeof s === 'string' ? { source: s, mimeType: guessMimeType(s) } : s;
12281
12278
  }
@@ -42290,7 +42287,7 @@ class Player {
42290
42287
  this.emitter.on(event, handler);
42291
42288
  }
42292
42289
  /**
42293
- * Removes a listener from a player event
42290
+ * Removes a previously added event listener
42294
42291
  * @param event - See {@link PlayerEvent}
42295
42292
  * @param handler - See {@link PlayerEventHandler}
42296
42293
  */
@@ -42300,10 +42297,12 @@ class Player {
42300
42297
  /**
42301
42298
  * Configures the player.
42302
42299
  *
42303
- * Can be called multiple times. Each consequent call extends the previous configuration.
42304
- * After a reconfiguration, if something significant has changed, the must be reinitialized (i.e, a `.destroy()` followed by an `.init()` call).
42305
- *
42306
42300
  * @param config - complete or partial configuration
42301
+ * @remarks
42302
+ * Can be called multiple times.
42303
+ * Each consequent call extends the previous configuration with only the new keys overridden.
42304
+ *
42305
+ * After a reconfiguration, if something significant has changed, it might make sense reinitialize the player (i.e, a `.destroy()` followed by an `.init()` call).
42307
42306
  */
42308
42307
  configure(config) {
42309
42308
  this.setConfig(config);
@@ -42311,6 +42310,29 @@ class Player {
42311
42310
  /**
42312
42311
  * Initializes the player at the given container element.
42313
42312
  * @param playerElement - DOM element to host the player
42313
+ * @remarks
42314
+ * The player will be initialized and attached to the given element.
42315
+ *
42316
+ * All the core plugins will be initialized at this point.
42317
+ *
42318
+ * If no sources were configured, it will trigger an error.
42319
+ *
42320
+ * The player container will be initialized and then all the registered UI plugins.
42321
+ *
42322
+ * If the `autoPlay` option is set, then it will trigger playback immediately.
42323
+ *
42324
+ * It is an error to call this method twice. If you need to attache player to another DOM element,
42325
+ * first call {@link Player.destroy} and then {@link Player.attachTo}.
42326
+ *
42327
+ * @example
42328
+ * ```ts
42329
+ * const player = new Player({
42330
+ * sources: [{ source: 'https://example.com/a.mpd', mimeType: 'application/dash+xml' }],
42331
+ * })
42332
+ * document.addEventListener('DOMContentLoaded', () => {
42333
+ * player.attachTo(document.getElementById('video-container'))
42334
+ * })
42335
+ * ```
42314
42336
  */
42315
42337
  attachTo(playerElement) {
42316
42338
  assert.ok(!this.player, 'Player already initialized');
@@ -42331,7 +42353,7 @@ class Player {
42331
42353
  return this.initPlayer(coreOpts);
42332
42354
  }
42333
42355
  /**
42334
- * Destroys the player, releasing all resources and removing any DOM elements added.
42356
+ * Destroys the player, releasing all resources and unmounting its UI from the DOM.
42335
42357
  */
42336
42358
  destroy() {
42337
42359
  trace(`${T} destroy`, {
@@ -42349,8 +42371,11 @@ class Player {
42349
42371
  }
42350
42372
  }
42351
42373
  /**
42352
- * Current playback time in seconds, if appropriate.
42353
- * @returns For live streams, it returns the current time of the current segment.
42374
+ * Current playback (time since the beginning of the stream), if appropriate.
42375
+ *
42376
+ * @returns Time in seconds
42377
+ * @remarks
42378
+ * For live streams, it returns the current time within the current segment.
42354
42379
  */
42355
42380
  getCurrentTime() {
42356
42381
  if (!this.player) {
@@ -42360,7 +42385,10 @@ class Player {
42360
42385
  }
42361
42386
  /**
42362
42387
  * Duration of the current media in seconds, if appropriate.
42363
- * @returns For live streams, it returns the duration of the current segment.
42388
+ *
42389
+ * @returns Time in seconds
42390
+ * @remarks
42391
+ * For live streams, it returns the duration of the current segment.
42364
42392
  */
42365
42393
  getDuration() {
42366
42394
  if (!this.player) {
@@ -42369,13 +42397,25 @@ class Player {
42369
42397
  return this.player.getDuration();
42370
42398
  }
42371
42399
  /**
42372
- * Mutes the player.
42400
+ * Indicates whether DVR is enabled.
42401
+ */
42402
+ isDvrEnabled() {
42403
+ return this.player?.isDvrEnabled() ?? false;
42404
+ }
42405
+ /**
42406
+ * Indicates the playing state of the player.
42407
+ */
42408
+ isPlaying() {
42409
+ return this.player?.isPlaying() ?? false;
42410
+ }
42411
+ /**
42412
+ * Mutes the sound of the video.
42373
42413
  */
42374
42414
  mute() {
42375
42415
  this.player?.mute();
42376
42416
  }
42377
42417
  /**
42378
- * Unmutes the player.
42418
+ * Unmutes the video sound.
42379
42419
  */
42380
42420
  unmute() {
42381
42421
  this.player?.unmute();
@@ -42395,17 +42435,38 @@ class Player {
42395
42435
  /**
42396
42436
  * Resizes the player container element and everything within it.
42397
42437
  * @param newSize - new size of the player
42438
+ * @remarks
42439
+ * Use this method when the player itself does not detect the change in size of its container element.
42440
+ * It can be a case for orientation change on some mobile devices.
42398
42441
  */
42399
42442
  resize(newSize) {
42400
42443
  this.player?.resize(newSize);
42401
42444
  }
42402
42445
  /**
42403
42446
  * Seeks to the given time.
42404
- * @param time - time to seek to in seconds
42447
+ * @param time - time to seek to in seconds (since the beginning of the stream)
42405
42448
  */
42406
42449
  seek(time) {
42407
42450
  this.player?.seek(time);
42408
42451
  }
42452
+ /**
42453
+ * Gets the current volume of the media content being played.
42454
+ * @returns a number between 0 and 1
42455
+ */
42456
+ getVolume() {
42457
+ // This method is provided by the MediaControl plugin
42458
+ // @ts-ignore
42459
+ return this.player?.getVolume?.() || 0;
42460
+ }
42461
+ /**
42462
+ * Sets the current volume of the media content being played.
42463
+ * @param volume - a number between 0 and 1
42464
+ */
42465
+ setVolume(volume) {
42466
+ // This method is provided by the MediaControl plugin
42467
+ // @ts-ignore
42468
+ this.player?.setVolume?.(volume);
42469
+ }
42409
42470
  /**
42410
42471
  * Stops playback.
42411
42472
  */
@@ -42414,14 +42475,27 @@ class Player {
42414
42475
  }
42415
42476
  /**
42416
42477
  * Registers a plugin.
42417
- * @param plugin - plugin to register
42478
+ * @param plugin - a plugin class
42479
+ * @remarks
42480
+ * Use this method to extend the player with custom behavior.
42481
+ * The plugin class must inherit from one of the Clappr UIPlugin, UIContainerPlugin or CorePlugin classes.
42482
+ * A core plugin will be initialized and attached to the player when the player is initialized.
42483
+ * A UI plugin will be initialized and attached to the player container is initialized.
42484
+ *
42485
+ * @see {@link https://github.com/clappr/clappr/wiki/Architecture}
42486
+ * @example
42487
+ * ```ts
42488
+ * import MyPlugin from './MyPlugin.js'
42489
+ *
42490
+ * Player.registerPlugin(MyPlugin)
42491
+ * ```
42418
42492
  */
42419
42493
  static registerPlugin(plugin) {
42420
42494
  Loader.registerPlugin(plugin);
42421
42495
  }
42422
42496
  /**
42423
- * Unregisters a plugin.
42424
- * @param plugin - plugin to unregister
42497
+ * Unregisters a plugin registered earlier with {@link Player.registerPlugin}.
42498
+ * @param plugin - a plugin class
42425
42499
  */
42426
42500
  static unregisterPlugin(plugin) {
42427
42501
  Loader.unregisterPlugin(plugin);
@@ -42619,7 +42693,7 @@ class Player {
42619
42693
  }
42620
42694
  }
42621
42695
 
42622
- var version$1 = "2.16.17";
42696
+ var version$1 = "2.17.0";
42623
42697
 
42624
42698
  var packages = {
42625
42699
  "node_modules/@clappr/core": {
@@ -42643,4 +42717,4 @@ function version() {
42643
42717
  };
42644
42718
  }
42645
42719
 
42646
- export { LogTracer, Logger, PlaybackErrorCode, Player, PlayerEvent, SentryTracer, buildMediaSourcesList, isDashSource, isHlsSource, reportError, setTracer, trace, unwrapSource, version, wrapSource };
42720
+ export { LogTracer, Logger, PlaybackErrorCode, Player, PlayerEvent, SentryTracer, reportError, setTracer, trace, version };
package/dist/player.d.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  /**
2
- * Video player for the GCore streaming platform
2
+ * Video player for the Gcore streaming platform
3
3
  *
4
4
  * @remarks
5
- * This package provides a video player for the GCore streaming platform.
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
9
9
  */
10
10
 
11
- import EventLite from 'event-lite';
12
11
  import { Logger } from '@gcorevideo/utils';
13
12
  import { LogTracer } from '@gcorevideo/utils';
14
13
  import { reportError as reportError_2 } from '@gcorevideo/utils';
@@ -41,39 +40,6 @@ export { LogTracer }
41
40
  */
42
41
  export declare type MediaTransport = 'dash' | 'hls';
43
42
 
44
- /**
45
- * @internal
46
- */
47
- export declare class _MockPlayback extends EventLite {
48
- protected options: any;
49
- readonly i18n: any;
50
- protected playerError?: any | undefined;
51
- constructor(options: any, i18n: any, playerError?: any | undefined);
52
- get name(): string;
53
- consent(): void;
54
- play(): void;
55
- pause(): void;
56
- stop(): void;
57
- destroy(): void;
58
- seek(): void;
59
- seekPercentage(): void;
60
- getDuration(): number;
61
- enterPiP(): void;
62
- exitPiP(): void;
63
- getPlaybackType(): string;
64
- getStartTimeOffset(): number;
65
- getCurrentTime(): number;
66
- isHighDefinitionInUse(): boolean;
67
- mute(): void;
68
- unmute(): void;
69
- volume(): void;
70
- configure(): void;
71
- attemptAutoPlay(): boolean;
72
- canAutoPlay(): boolean;
73
- onResize(): boolean;
74
- trigger(event: string, ...args: any[]): void;
75
- }
76
-
77
43
  /**
78
44
  * @beta
79
45
  */
@@ -90,7 +56,7 @@ export declare interface PlaybackError {
90
56
  export declare enum PlaybackErrorCode {
91
57
  Generic = 0,
92
58
  MediaSourceUnavailable = 1,
93
- QualityLevelUnavailable = 2
59
+ MediaSourceAccessDenied = 3
94
60
  }
95
61
 
96
62
  /**
@@ -128,7 +94,7 @@ export declare class Player {
128
94
  */
129
95
  on<T extends PlayerEvent>(event: T, handler: PlayerEventHandler<T>): void;
130
96
  /**
131
- * Removes a listener from a player event
97
+ * Removes a previously added event listener
132
98
  * @param event - See {@link PlayerEvent}
133
99
  * @param handler - See {@link PlayerEventHandler}
134
100
  */
@@ -136,37 +102,76 @@ export declare class Player {
136
102
  /**
137
103
  * Configures the player.
138
104
  *
139
- * Can be called multiple times. Each consequent call extends the previous configuration.
140
- * After a reconfiguration, if something significant has changed, the must be reinitialized (i.e, a `.destroy()` followed by an `.init()` call).
141
- *
142
105
  * @param config - complete or partial configuration
106
+ * @remarks
107
+ * Can be called multiple times.
108
+ * Each consequent call extends the previous configuration with only the new keys overridden.
109
+ *
110
+ * After a reconfiguration, if something significant has changed, it might make sense reinitialize the player (i.e, a `.destroy()` followed by an `.init()` call).
143
111
  */
144
112
  configure(config: Partial<PlayerConfig>): void;
145
113
  /**
146
114
  * Initializes the player at the given container element.
147
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
+ * ```
148
139
  */
149
140
  attachTo(playerElement: HTMLElement): void;
150
141
  /**
151
- * Destroys the player, releasing all resources and removing any DOM elements added.
142
+ * Destroys the player, releasing all resources and unmounting its UI from the DOM.
152
143
  */
153
144
  destroy(): void;
154
145
  /**
155
- * Current playback time in seconds, if appropriate.
156
- * @returns For live streams, it returns the current time of the current segment.
146
+ * Current playback (time since the beginning of the stream), if appropriate.
147
+ *
148
+ * @returns Time in seconds
149
+ * @remarks
150
+ * For live streams, it returns the current time within the current segment.
157
151
  */
158
152
  getCurrentTime(): number;
159
153
  /**
160
154
  * Duration of the current media in seconds, if appropriate.
161
- * @returns For live streams, it returns the duration of the current segment.
155
+ *
156
+ * @returns Time in seconds
157
+ * @remarks
158
+ * For live streams, it returns the duration of the current segment.
162
159
  */
163
160
  getDuration(): number;
164
161
  /**
165
- * Mutes the player.
162
+ * Indicates whether DVR is enabled.
163
+ */
164
+ isDvrEnabled(): boolean;
165
+ /**
166
+ * Indicates the playing state of the player.
167
+ */
168
+ isPlaying(): boolean;
169
+ /**
170
+ * Mutes the sound of the video.
166
171
  */
167
172
  mute(): void;
168
173
  /**
169
- * Unmutes the player.
174
+ * Unmutes the video sound.
170
175
  */
171
176
  unmute(): void;
172
177
  /**
@@ -180,6 +185,9 @@ export declare class Player {
180
185
  /**
181
186
  * Resizes the player container element and everything within it.
182
187
  * @param newSize - new size of the player
188
+ * @remarks
189
+ * Use this method when the player itself does not detect the change in size of its container element.
190
+ * It can be a case for orientation change on some mobile devices.
183
191
  */
184
192
  resize(newSize: {
185
193
  width: number;
@@ -187,21 +195,44 @@ export declare class Player {
187
195
  }): void;
188
196
  /**
189
197
  * Seeks to the given time.
190
- * @param time - time to seek to in seconds
198
+ * @param time - time to seek to in seconds (since the beginning of the stream)
191
199
  */
192
200
  seek(time: number): void;
201
+ /**
202
+ * Gets the current volume of the media content being played.
203
+ * @returns a number between 0 and 1
204
+ */
205
+ getVolume(): number;
206
+ /**
207
+ * Sets the current volume of the media content being played.
208
+ * @param volume - a number between 0 and 1
209
+ */
210
+ setVolume(volume: number): void;
193
211
  /**
194
212
  * Stops playback.
195
213
  */
196
214
  stop(): void;
197
215
  /**
198
216
  * Registers a plugin.
199
- * @param plugin - plugin to register
217
+ * @param plugin - a plugin class
218
+ * @remarks
219
+ * Use this method to extend the player with custom behavior.
220
+ * The plugin class must inherit from one of the Clappr UIPlugin, UIContainerPlugin or CorePlugin classes.
221
+ * A core plugin will be initialized and attached to the player when the player is initialized.
222
+ * A UI plugin will be initialized and attached to the player container is initialized.
223
+ *
224
+ * @see {@link https://github.com/clappr/clappr/wiki/Architecture}
225
+ * @example
226
+ * ```ts
227
+ * import MyPlugin from './MyPlugin.js'
228
+ *
229
+ * Player.registerPlugin(MyPlugin)
230
+ * ```
200
231
  */
201
232
  static registerPlugin(plugin: PlayerPlugin): void;
202
233
  /**
203
- * Unregisters a plugin.
204
- * @param plugin - plugin to unregister
234
+ * Unregisters a plugin registered earlier with {@link Player.registerPlugin}.
235
+ * @param plugin - a plugin class
205
236
  */
206
237
  static unregisterPlugin(plugin: PlayerPlugin): void;
207
238
  private setConfig;
package/docs/api/index.md CHANGED
@@ -24,7 +24,7 @@ Description
24
24
 
25
25
  </td><td>
26
26
 
27
- Video player for the GCore streaming platform
27
+ Video player for the Gcore streaming platform
28
28
 
29
29
 
30
30
  </td></tr>
@@ -4,11 +4,11 @@
4
4
 
5
5
  ## player package
6
6
 
7
- Video player for the GCore streaming platform
7
+ Video player for the Gcore streaming platform
8
8
 
9
9
  ## Remarks
10
10
 
11
- This package provides a video player for the GCore streaming platform. It is built on top of the Clappr library and provides a framework for building custom integrations.
11
+ This package provides a video player for the Gcore streaming platform. It is built on top of the Clappr library and provides a framework for building custom integrations.
12
12
 
13
13
  ## Classes
14
14
 
@@ -50,12 +50,12 @@ Generic
50
50
  </td></tr>
51
51
  <tr><td>
52
52
 
53
- MediaSourceUnavailable
53
+ MediaSourceAccessDenied
54
54
 
55
55
 
56
56
  </td><td>
57
57
 
58
- `1`
58
+ `3`
59
59
 
60
60
 
61
61
  </td><td>
@@ -66,12 +66,12 @@ MediaSourceUnavailable
66
66
  </td></tr>
67
67
  <tr><td>
68
68
 
69
- QualityLevelUnavailable
69
+ MediaSourceUnavailable
70
70
 
71
71
 
72
72
  </td><td>
73
73
 
74
- `2`
74
+ `1`
75
75
 
76
76
 
77
77
  </td><td>
@@ -54,3 +54,29 @@ DOM element to host the player
54
54
 
55
55
  void
56
56
 
57
+ ## Remarks
58
+
59
+ The player will be initialized and attached to the given element.
60
+
61
+ All the core plugins will be initialized at this point.
62
+
63
+ If no sources were configured, it will trigger an error.
64
+
65
+ The player container will be initialized and then all the registered UI plugins.
66
+
67
+ If the `autoPlay` option is set, then it will trigger playback immediately.
68
+
69
+ It is an error to call this method twice. If you need to attache player to another DOM element, first call [Player.destroy()](./player.player.destroy.md) and then [Player.attachTo()](./player.player.attachto.md)<!-- -->.
70
+
71
+ ## Example
72
+
73
+
74
+ ```ts
75
+ const player = new Player({
76
+ sources: [{ source: 'https://example.com/a.mpd', mimeType: 'application/dash+xml' }],
77
+ })
78
+ document.addEventListener('DOMContentLoaded', () => {
79
+ player.attachTo(document.getElementById('video-container'))
80
+ })
81
+ ```
82
+
@@ -9,8 +9,6 @@
9
9
 
10
10
  Configures the player.
11
11
 
12
- Can be called multiple times. Each consequent call extends the previous configuration. After a reconfiguration, if something significant has changed, the must be reinitialized (i.e, a `.destroy()` followed by an `.init()` call).
13
-
14
12
  **Signature:**
15
13
 
16
14
  ```typescript
@@ -56,3 +54,9 @@ complete or partial configuration
56
54
 
57
55
  void
58
56
 
57
+ ## Remarks
58
+
59
+ Can be called multiple times. Each consequent call extends the previous configuration with only the new keys overridden.
60
+
61
+ After a reconfiguration, if something significant has changed, it might make sense reinitialize the player (i.e, a `.destroy()` followed by an `.init()` call).
62
+
@@ -7,7 +7,7 @@
7
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
8
  >
9
9
 
10
- Destroys the player, releasing all resources and removing any DOM elements added.
10
+ Destroys the player, releasing all resources and unmounting its UI from the DOM.
11
11
 
12
12
  **Signature:**
13
13
 
@@ -7,7 +7,7 @@
7
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
8
  >
9
9
 
10
- Current playback time in seconds, if appropriate.
10
+ Current playback (time since the beginning of the stream), if appropriate.
11
11
 
12
12
  **Signature:**
13
13
 
@@ -18,5 +18,9 @@ getCurrentTime(): number;
18
18
 
19
19
  number
20
20
 
21
- For live streams, it returns the current time of the current segment.
21
+ Time in seconds
22
+
23
+ ## Remarks
24
+
25
+ For live streams, it returns the current time within the current segment.
22
26
 
@@ -18,5 +18,9 @@ getDuration(): number;
18
18
 
19
19
  number
20
20
 
21
+ Time in seconds
22
+
23
+ ## Remarks
24
+
21
25
  For live streams, it returns the duration of the current segment.
22
26