@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,18 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [PlayerMediaSource](./player.playermediasource.md)
4
+
5
+ ## PlayerMediaSource 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
+ A media source to fetch the media data from
11
+
12
+ **Signature:**
13
+
14
+ ```typescript
15
+ export type PlayerMediaSource = string | PlayerMediaSourceDesc;
16
+ ```
17
+ **References:** [PlayerMediaSourceDesc](./player.playermediasourcedesc.md)
18
+
@@ -0,0 +1,83 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [PlayerMediaSourceDesc](./player.playermediasourcedesc.md)
4
+
5
+ ## PlayerMediaSourceDesc interface
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
+ Describes a media source with its MIME type and URL.
11
+
12
+ **Signature:**
13
+
14
+ ```typescript
15
+ export interface PlayerMediaSourceDesc
16
+ ```
17
+
18
+ ## Remarks
19
+
20
+ When the MIME type is provided, it helps the player determine the appropriate playback engine. If omitted, the player will attempt to detect the type from the source URL extension.
21
+
22
+ ## Properties
23
+
24
+ <table><thead><tr><th>
25
+
26
+ Property
27
+
28
+
29
+ </th><th>
30
+
31
+ Modifiers
32
+
33
+
34
+ </th><th>
35
+
36
+ Type
37
+
38
+
39
+ </th><th>
40
+
41
+ Description
42
+
43
+
44
+ </th></tr></thead>
45
+ <tbody><tr><td>
46
+
47
+ [mimeType?](./player.playermediasourcedesc.mimetype.md)
48
+
49
+
50
+ </td><td>
51
+
52
+
53
+ </td><td>
54
+
55
+ string
56
+
57
+
58
+ </td><td>
59
+
60
+ **_(BETA)_** _(Optional)_ The MIME type of the media source (e.g. "video/mp4", "application/x-mpegURL")
61
+
62
+
63
+ </td></tr>
64
+ <tr><td>
65
+
66
+ [source](./player.playermediasourcedesc.source.md)
67
+
68
+
69
+ </td><td>
70
+
71
+
72
+ </td><td>
73
+
74
+ string
75
+
76
+
77
+ </td><td>
78
+
79
+ **_(BETA)_** URL of the media source
80
+
81
+
82
+ </td></tr>
83
+ </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; [PlayerMediaSourceDesc](./player.playermediasourcedesc.md) &gt; [mimeType](./player.playermediasourcedesc.mimetype.md)
4
+
5
+ ## PlayerMediaSourceDesc.mimeType property
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
+ The MIME type of the media source (e.g. "video/mp4", "application/x-mpegURL")
11
+
12
+ **Signature:**
13
+
14
+ ```typescript
15
+ mimeType?: string;
16
+ ```
@@ -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; [PlayerMediaSourceDesc](./player.playermediasourcedesc.md) &gt; [source](./player.playermediasourcedesc.source.md)
4
+
5
+ ## PlayerMediaSourceDesc.source property
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
+ URL of the media source
11
+
12
+ **Signature:**
13
+
14
+ ```typescript
15
+ source: string;
16
+ ```
@@ -0,0 +1,17 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [PlayerPlugin](./player.playerplugin.md)
4
+
5
+ ## PlayerPlugin 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
+ **Signature:**
11
+
12
+ ```typescript
13
+ export type PlayerPlugin = {
14
+ new (...args: any[]): unknown;
15
+ type: 'core' | 'container';
16
+ };
17
+ ```
@@ -0,0 +1,20 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [QualityLevel](./player.qualitylevel.md)
4
+
5
+ ## QualityLevel 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 QualityLevel = {
15
+ level: number;
16
+ width: number;
17
+ height: number;
18
+ bitrate: number;
19
+ };
20
+ ```
@@ -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; [TranslationKey](./player.translationkey.md)
4
+
5
+ ## TranslationKey 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 TranslationKey = string;
15
+ ```
@@ -0,0 +1,35 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [TranslationSettings](./player.translationsettings.md)
4
+
5
+ ## TranslationSettings 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
+ \[language\]\[key\] =<!-- -->&gt; string
11
+
12
+ **Signature:**
13
+
14
+ ```typescript
15
+ export type TranslationSettings = Partial<Record<LangTag, Record<TranslationKey, string>>>;
16
+ ```
17
+ **References:** [LangTag](./player.langtag.md)<!-- -->, [TranslationKey](./player.translationkey.md)
18
+
19
+ ## Example
20
+
21
+
22
+ ```
23
+ {
24
+ en: {
25
+ play: 'Play',
26
+ ...
27
+ },
28
+ es: {
29
+ play: 'Reproducir',
30
+ ...
31
+ },
32
+ ...
33
+ }
34
+ ```
35
+
@@ -0,0 +1,17 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [TransportPreference](./player.transportpreference.md)
4
+
5
+ ## TransportPreference 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 TransportPreference = MediaTransport | 'auto';
15
+ ```
16
+ **References:** [MediaTransport](./player.mediatransport.md)
17
+
@@ -0,0 +1,27 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [version](./player.version.md)
4
+
5
+ ## version() function
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
+ Version information about the gplayer and its main dependencies
11
+
12
+ **Signature:**
13
+
14
+ ```typescript
15
+ export declare function version(): {
16
+ gplayer: string;
17
+ clappr: string;
18
+ dashjs: string;
19
+ hlsjs: string;
20
+ };
21
+ ```
22
+ **Returns:**
23
+
24
+ { gplayer: string; clappr: string; dashjs: string; hlsjs: string; }
25
+
26
+ Version information about the gplayer and its main dependencies
27
+
package/lib/Player.d.ts CHANGED
@@ -1,8 +1,19 @@
1
1
  import type { PlayerPlugin } from './types.js';
2
2
  import { PlayerConfig, PlayerEvent } from './types.js';
3
- type PlayerEventHandler<T extends PlayerEvent> = () => void;
3
+ /**
4
+ * @beta
5
+ */
6
+ export type PlayerEventHandler<T extends PlayerEvent> = () => void;
7
+ /**
8
+ * @beta
9
+ */
4
10
  export type PlaybackModule = 'dash' | 'hls' | 'native';
5
11
  /**
12
+ * The main component to use in the application code.
13
+ * @remarks
14
+ * The Player object provides very basic API to control playback.
15
+ * To build a sophisticated UI, use the plugins framework to tap into the Clappr core.
16
+ * {@link https://github.com/clappr/clappr/wiki/Architecture}
6
17
  * @beta
7
18
  */
8
19
  export declare class Player {
@@ -14,22 +25,90 @@ export declare class Player {
14
25
  private tuneInTimerId;
15
26
  private tunedIn;
16
27
  constructor(config: PlayerConfig);
28
+ /**
29
+ * Adds a listener to a player event
30
+ * @param event - See {@link PlayerEvent}
31
+ * @param handler - See {@link PlayerEventHandler}
32
+ */
17
33
  on<T extends PlayerEvent>(event: T, handler: PlayerEventHandler<T>): void;
34
+ /**
35
+ * Removes a listener from a player event
36
+ * @param event - See {@link PlayerEvent}
37
+ * @param handler - See {@link PlayerEventHandler}
38
+ */
18
39
  off<T extends PlayerEvent>(event: T, handler: PlayerEventHandler<T>): void;
40
+ /**
41
+ * Configures the player.
42
+ *
43
+ * Can be called multiple times. Each consequent call extends the previous configuration.
44
+ * After a reconfiguration, if something significant has changed, the must be reinitialized (i.e, a `.destroy()` followed by an `.init()` call).
45
+ *
46
+ * @param config - complete or partial configuration
47
+ */
19
48
  configure(config: Partial<PlayerConfig>): void;
20
- private setConfig;
21
- init(playerElement: HTMLElement): Promise<void>;
49
+ /**
50
+ * Initializes the player at the given container element.
51
+ * @param playerElement - DOM element to host the player
52
+ */
53
+ attachTo(playerElement: HTMLElement): void;
54
+ /**
55
+ * Destroys the player, releasing all resources and removing any DOM elements added.
56
+ */
22
57
  destroy(): void;
58
+ /**
59
+ * Current playback time in seconds, if appropriate.
60
+ * @returns For live streams, it returns the current time of the current segment.
61
+ */
62
+ getCurrentTime(): number;
63
+ /**
64
+ * Duration of the current media in seconds, if appropriate.
65
+ * @returns For live streams, it returns the duration of the current segment.
66
+ */
67
+ getDuration(): number;
68
+ /**
69
+ * Mutes the player.
70
+ */
71
+ mute(): void;
72
+ /**
73
+ * Unmutes the player.
74
+ */
75
+ unmute(): void;
76
+ /**
77
+ * Pauses playback.
78
+ */
23
79
  pause(): void;
80
+ /**
81
+ * Starts playback.
82
+ */
24
83
  play(): void;
84
+ /**
85
+ * Resizes the player container element and everything within it.
86
+ * @param newSize - new size of the player
87
+ */
25
88
  resize(newSize: {
26
89
  width: number;
27
90
  height: number;
28
91
  }): void;
29
- seekTo(time: number): void;
92
+ /**
93
+ * Seeks to the given time.
94
+ * @param time - time to seek to in seconds
95
+ */
96
+ seek(time: number): void;
97
+ /**
98
+ * Stops playback.
99
+ */
30
100
  stop(): void;
101
+ /**
102
+ * Registers a plugin.
103
+ * @param plugin - plugin to register
104
+ */
31
105
  static registerPlugin(plugin: PlayerPlugin): void;
106
+ /**
107
+ * Unregisters a plugin.
108
+ * @param plugin - plugin to unregister
109
+ */
32
110
  static unregisterPlugin(plugin: PlayerPlugin): void;
111
+ private setConfig;
33
112
  private initPlayer;
34
113
  private tuneIn;
35
114
  private events;
@@ -37,5 +116,4 @@ export declare class Player {
37
116
  private configurePlaybacks;
38
117
  private selectMediaSource;
39
118
  }
40
- export {};
41
119
  //# sourceMappingURL=Player.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../src/Player.ts"],"names":[],"mapp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IAIJ;;OAEG;IACH,MAAM;IAIN;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,IAAI;IAIJ;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAIjD;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM;IAIjB;;OAEG;IACH,IAAI;IAIJ;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY;IAI1C;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,YAAY;IAI5C,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,UAAU;YAqBJ,MAAM;IA2EpB,OAAO,CAAC,MAAM,CAgDb;IAED,OAAO,CAAC,gBAAgB;IAkCxB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,iBAAiB;CAM1B"}
package/lib/Player.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Browser, Events as ClapprEvents, Log, Player as PlayerClappr, $, Loader, } from '@clappr/core';
2
+ import { reportError, trace } from '@gcorevideo/utils';
2
3
  import assert from 'assert';
3
4
  import EventLite from 'event-lite';
4
- import { reportError, trace } from './trace/index.js';
5
5
  import { PlayerEvent } from './types.js';
6
6
  import DashPlayback from './plugins/dash-playback/DashPlayback.js';
7
7
  import HlsPlayback from './plugins/hls-playback/HlsPlayback.js';
@@ -13,13 +13,16 @@ const DEFAULT_OPTIONS = {
13
13
  loop: false,
14
14
  mute: false,
15
15
  playbackType: 'vod',
16
- pluginSettings: {},
17
- poster: '',
18
16
  priorityTransport: 'dash',
19
17
  sources: [],
20
18
  strings: {},
21
19
  };
22
20
  /**
21
+ * The main component to use in the application code.
22
+ * @remarks
23
+ * The Player object provides very basic API to control playback.
24
+ * To build a sophisticated UI, use the plugins framework to tap into the Clappr core.
25
+ * {@link https://github.com/clappr/clappr/wiki/Architecture}
23
26
  * @beta
24
27
  */
25
28
  export class Player {
@@ -33,19 +36,38 @@ export class Player {
33
36
  constructor(config) {
34
37
  this.setConfig(config);
35
38
  }
39
+ /**
40
+ * Adds a listener to a player event
41
+ * @param event - See {@link PlayerEvent}
42
+ * @param handler - See {@link PlayerEventHandler}
43
+ */
36
44
  on(event, handler) {
37
45
  this.emitter.on(event, handler);
38
46
  }
47
+ /**
48
+ * Removes a listener from a player event
49
+ * @param event - See {@link PlayerEvent}
50
+ * @param handler - See {@link PlayerEventHandler}
51
+ */
39
52
  off(event, handler) {
40
53
  this.emitter.off(event, handler);
41
54
  }
55
+ /**
56
+ * Configures the player.
57
+ *
58
+ * Can be called multiple times. Each consequent call extends the previous configuration.
59
+ * After a reconfiguration, if something significant has changed, the must be reinitialized (i.e, a `.destroy()` followed by an `.init()` call).
60
+ *
61
+ * @param config - complete or partial configuration
62
+ */
42
63
  configure(config) {
43
64
  this.setConfig(config);
44
65
  }
45
- setConfig(config) {
46
- this.config = $.extend(true, this.config, config);
47
- }
48
- async init(playerElement) {
66
+ /**
67
+ * Initializes the player at the given container element.
68
+ * @param playerElement - DOM element to host the player
69
+ */
70
+ attachTo(playerElement) {
49
71
  assert.ok(!this.player, 'Player already initialized');
50
72
  assert.ok(playerElement, 'Player container element is required');
51
73
  if (this.config.debug === 'all' || this.config.debug === 'clappr') {
@@ -67,6 +89,9 @@ export class Player {
67
89
  };
68
90
  return this.initPlayer(coreOpts);
69
91
  }
92
+ /**
93
+ * Destroys the player, releasing all resources and removing any DOM elements added.
94
+ */
70
95
  destroy() {
71
96
  trace(`${T} destroy`, {
72
97
  player: !!this.player,
@@ -82,38 +107,87 @@ export class Player {
82
107
  this.tuneInTimerId = null;
83
108
  }
84
109
  }
110
+ /**
111
+ * Current playback time in seconds, if appropriate.
112
+ * @returns For live streams, it returns the current time of the current segment.
113
+ */
114
+ getCurrentTime() {
115
+ if (!this.player) {
116
+ return 0;
117
+ }
118
+ return this.player.getCurrentTime();
119
+ }
120
+ /**
121
+ * Duration of the current media in seconds, if appropriate.
122
+ * @returns For live streams, it returns the duration of the current segment.
123
+ */
124
+ getDuration() {
125
+ if (!this.player) {
126
+ return 0;
127
+ }
128
+ return this.player.getDuration();
129
+ }
130
+ /**
131
+ * Mutes the player.
132
+ */
133
+ mute() {
134
+ this.player?.mute();
135
+ }
136
+ /**
137
+ * Unmutes the player.
138
+ */
139
+ unmute() {
140
+ this.player?.unmute();
141
+ }
142
+ /**
143
+ * Pauses playback.
144
+ */
85
145
  pause() {
86
- assert.ok(this.player, 'Player not initialized');
87
- this.player.pause();
146
+ this.player?.pause();
88
147
  }
148
+ /**
149
+ * Starts playback.
150
+ */
89
151
  play() {
90
- assert.ok(this.player, 'Player not initialized');
91
- this.player.play();
152
+ this.player?.play();
92
153
  }
154
+ /**
155
+ * Resizes the player container element and everything within it.
156
+ * @param newSize - new size of the player
157
+ */
93
158
  resize(newSize) {
94
- if (!this.player) {
95
- trace(`${T} resize not initialized`, { newSize });
96
- return;
97
- }
98
- trace(`${T} resize`, {
99
- newSize,
100
- });
101
- this.player.resize(newSize);
159
+ this.player?.resize(newSize);
102
160
  }
103
- seekTo(time) {
104
- assert.ok(this.player, 'Player not initialized');
105
- this.player.seek(time);
161
+ /**
162
+ * Seeks to the given time.
163
+ * @param time - time to seek to in seconds
164
+ */
165
+ seek(time) {
166
+ this.player?.seek(time);
106
167
  }
168
+ /**
169
+ * Stops playback.
170
+ */
107
171
  stop() {
108
- assert.ok(this.player, 'Player not initialized');
109
- this.player.stop();
172
+ this.player?.stop();
110
173
  }
174
+ /**
175
+ * Registers a plugin.
176
+ * @param plugin - plugin to register
177
+ */
111
178
  static registerPlugin(plugin) {
112
179
  Loader.registerPlugin(plugin);
113
180
  }
181
+ /**
182
+ * Unregisters a plugin.
183
+ * @param plugin - plugin to unregister
184
+ */
114
185
  static unregisterPlugin(plugin) {
115
186
  Loader.unregisterPlugin(plugin);
116
187
  }
188
+ setConfig(config) {
189
+ this.config = $.extend(true, this.config, config);
190
+ }
117
191
  initPlayer(coreOptions) {
118
192
  trace(`${T} initPlayer`, {
119
193
  // TODO selected options
@@ -252,7 +326,7 @@ export class Player {
252
326
  const source = this.selectMediaSource();
253
327
  this.rootNode = rootNode;
254
328
  const coreOptions = {
255
- ...this.config.pluginSettings,
329
+ ...this.config, // plugin settings
256
330
  allowUserInteraction: true,
257
331
  autoPlay: false,
258
332
  dash: this.config.dash,
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;CAO1B,CAAC;AAEF,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,cAAc,mBAAmB;IACjC,kBAAkB,aAAa;CAChC"}
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";