@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
package/src/types.ts CHANGED
@@ -1,109 +1,231 @@
1
- import { PlayerMediaSource } from "./internal.types"
1
+ /**
2
+ * Describes a media source with its MIME type and URL.
3
+ *
4
+ * @remarks
5
+ * When the MIME type is provided, it helps the player determine the appropriate playback engine.
6
+ * If omitted, the player will attempt to detect the type from the source URL extension.
7
+ * @beta
8
+ */
9
+ export interface PlayerMediaSourceDesc {
10
+ /**
11
+ * The MIME type of the media source (e.g. "video/mp4", "application/x-mpegURL")
12
+ */
13
+ mimeType?: string
14
+
15
+ /**
16
+ * URL of the media source
17
+ */
18
+ source: string
19
+ }
2
20
 
21
+ /**
22
+ * A media source to fetch the media data from
23
+ * @beta
24
+ */
25
+ export type PlayerMediaSource = string | PlayerMediaSourceDesc
26
+
27
+ /**
28
+ * @beta
29
+ */
3
30
  export type PlayerDebugTag = 'all' | 'clappr' | 'dash' | 'hls' | 'none'
31
+
32
+ /**
33
+ * @remarks true is equivalent to 'all', false is equivalent to 'none'
34
+ * @beta
35
+ */
4
36
  export type PlayerDebugSettings = PlayerDebugTag | boolean
5
37
 
38
+ /**
39
+ * Type of a stream playback
40
+ * @beta
41
+ */
6
42
  export type PlaybackType = 'live' | 'vod'
43
+
44
+ /**
45
+ * @beta
46
+ */
7
47
  export type MediaTransport = 'dash' | 'hls' | 'mpegts'
48
+
49
+ /**
50
+ * @beta
51
+ */
8
52
  export type TransportPreference = MediaTransport | 'auto'
9
53
 
54
+ /**
55
+ * @beta
56
+ * @see {@link https://clappr.github.io/classes/UIContainerPlugin.html}, {@link https://clappr.github.io/classes/ContainerPlugin.html}
57
+ */
10
58
  export type PlayerPlugin = {
11
59
  new (...args: any[]): unknown
12
- type: string // 'core' | 'container' | 'playback';
60
+ type: 'core' | 'container'
13
61
  }
14
62
 
15
- export type PlayerConfig = {
63
+ /**
64
+ * Configuration options for the player
65
+ *
66
+ * @remarks
67
+ * You can specify multiple sources, each in two forms: just a plain URL or a full object with `source` and `mimeType` fields {@link PlayerMediaSource}.
68
+ * The player will pick the first viable media source according to the source availability, and either the transport preference or standard transport selection order.
69
+ *
70
+ * `priorityTransport` is used to specify the preferred transport protocol
71
+ * when multiple sources are available.
72
+ * It will first try to use the transport specified if it's supported (by a playback engine) and the source is available.
73
+ * Otherwise it will try the other transports in the regular order (dash, hls, mpegts).
74
+ *
75
+ * The `autoPlay` option should be used together with the {@link PlayerConfig.mute | mute} to avoid issues with the browsers' autoplay policies.
76
+ *
77
+ * 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.
78
+ *
79
+ * A plugin options can be specified in the configuration object under a unique key, typically corresponding to the plugin name.
80
+ * The plugin object will have access to the internal normalized configuration object that contains all the custom options.
81
+ * in the examle below, the `poster` field is the `Poster` plugin configuration options.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * {
86
+ * autoPlay: true,
87
+ * mute: true,
88
+ * playbackType: 'live',
89
+ * priorityTransport: 'dash',
90
+ * sources: [{
91
+ * source: 'https://example.com/myownair66.mpd',
92
+ * mimeType: 'application/dash+xml',
93
+ * }, {
94
+ * source: 'https://example.com/myownair66.m3u8',
95
+ * mimeType: 'application/x-mpegURL',
96
+ * }],
97
+ * poster: {
98
+ * url: settings.poster,
99
+ * },
100
+ * }
101
+ * ```
102
+ * @beta
103
+ */
104
+ export interface PlayerConfig extends Record<string, unknown> {
105
+ /**
106
+ * Start playback automatically when the player is ready
107
+ * @defaultValue false
108
+ */
16
109
  autoPlay?: boolean
110
+
111
+ /**
112
+ * Configuration settings for the DASH playback engine
113
+ * @defaultValue \{\}
114
+ * {@link https://cdn.dashjs.org/latest/jsdoc/module-Settings.html}
115
+ */
17
116
  dash?: DashSettings
18
- debug?: PlayerDebugSettings
19
- language?: string
20
- loop?: boolean
21
- mute?: boolean
22
- playbackType?: PlaybackType
23
- pluginSettings?: Record<string, unknown>
24
- poster?: string
25
- priorityTransport?: TransportPreference
26
- sources: PlayerMediaSource[];
27
- strings: TranslationSettings
28
- }
29
117
 
30
- export type PlayerOptionsThumbnails = {
31
- sprite?: string | null
32
- vtt?: string | null
33
- }
118
+ /**
119
+ * Controls the debug output level
120
+ * @defaultValue 'none'
121
+ */
122
+ debug?: PlayerDebugSettings
34
123
 
35
- export type ContextMenuSettings = {
36
- preventShowContextMenu?: boolean
37
- }
124
+ /**
125
+ * A language code for the player UI, for example, `es`. Must reference a key in the {@link PlayerConfig.strings | strings} record.
126
+ * @defaultValue 'en'
127
+ */
128
+ language?: string
38
129
 
39
- type LangTag = string
40
- type TranslationKey = string
130
+ /**
131
+ * Repeat playback when the media ends.
132
+ * Is used with the `vod` {@link PlayerConfig.playbackType | playbackType}
133
+ * @defaultValue false
134
+ */
135
+ loop?: boolean
41
136
 
42
- export type BroadcastSettings = {
43
- status?: 'live' | 'noActiveStreams'
44
- }
137
+ /**
138
+ * Mute the audio output in order to comply with browsers' autoplay policy.
139
+ * @defaultValue false
140
+ */
141
+ mute?: boolean
45
142
 
46
- export type ClipsPluginOptions = Record<string, unknown> // TODO
143
+ /**
144
+ * The type of playback (live stream or video on demand).
145
+ *
146
+ * @defaultValue 'vod'
147
+ */
148
+ playbackType?: PlaybackType
47
149
 
48
- export type PlaybackSettings = {
49
- hlsjsConfig?: Record<string, unknown>
50
- playInline?: boolean
51
- preload?: 'auto' | 'metadata' | 'none'
52
- triggerFatalErrorOnResourceDenied?: boolean
53
- }
150
+ /**
151
+ * Preferred transport protocol when multiple sources are available.
152
+ * @defaultValue 'auto'
153
+ */
154
+ priorityTransport?: TransportPreference
54
155
 
55
- export type DashSettings = Record<string, unknown> //
56
-
57
- // TODO consult with the Broadcaster team
58
- // TODO turn into camel case convert at user level
59
- export type StreamMediaSourceDto = {
60
- description: string
61
- dvr: boolean
62
- hls_cmaf_url?: string
63
- hls_mpegts_url?: string
64
- id: number
65
- live: boolean
66
- priority_transport: TransportPreference
67
- poster: string | null
68
- projection: ProjectionType | null
69
- screenshot: string | null
70
- source: string
71
- source_dash: string | null
72
- sprite: string | null
73
- title: string
74
- vtt: string | null
75
- }
156
+ /**
157
+ * List of media sources, at least one is required.
158
+ */
159
+ sources: PlayerMediaSource[]
76
160
 
77
- // TODO split into sources and source attributes
78
- export type StreamMediaSource = {
79
- description: string
80
- dvr: boolean
81
- hlsCmafUrl: string | null
82
- hlsMpegtsUrl: string | null
83
- id: number
84
- live: boolean
85
- priorityTransport: TransportPreference
86
- poster: string | null
87
- projection: ProjectionType | null
88
- screenshot: string | null
89
- source: string | null
90
- sourceDash: string | null
91
- sprite: string | null
92
- title: string
93
- vtt: string | null
161
+ /**
162
+ * Localization strings for the player UI.
163
+ */
164
+ strings: TranslationSettings
94
165
  }
95
166
 
96
- export type SrcProjectionType = 'regular' | '360' | 'vr180' | 'vr360tb'
97
- export type ProjectionType = '360' | '180' | '360_TB'
98
-
167
+ /**
168
+ * @beta
169
+ */
170
+ export type LangTag = string
171
+
172
+ /**
173
+ * @beta
174
+ */
175
+ export type TranslationKey = string
176
+
177
+ /**
178
+ * @beta
179
+ * {@link https://cdn.dashjs.org/latest/jsdoc/module-Settings.html | DASH.js settings}
180
+ */
181
+ export type DashSettings = Record<string, unknown>
182
+
183
+ /**
184
+ * [language][key] =\> string
185
+ * @example
186
+ * ```
187
+ * {
188
+ * en: {
189
+ * play: 'Play',
190
+ * ...
191
+ * },
192
+ * es: {
193
+ * play: 'Reproducir',
194
+ * ...
195
+ * },
196
+ * ...
197
+ * }
198
+ * ```
199
+ *
200
+ * @beta
201
+ */
99
202
  export type TranslationSettings = Partial<
100
203
  Record<LangTag, Record<TranslationKey, string>>
101
204
  >
102
205
 
206
+ /**
207
+ * A top-level event on the player object
208
+ * @beta
209
+ */
103
210
  export enum PlayerEvent {
211
+ /**
212
+ * The player is ready to use.
213
+ */
104
214
  Ready = 'ready',
215
+ /**
216
+ * Playback has started.
217
+ */
105
218
  Play = 'play',
219
+ /**
220
+ * Playback has been paused.
221
+ */
106
222
  Pause = 'pause',
223
+ /**
224
+ * Playback has been stopped.
225
+ */
107
226
  Stop = 'stop',
227
+ /**
228
+ * Playback has reached the end of the media.
229
+ */
108
230
  Ended = 'ended',
109
231
  }
@@ -1,7 +1,6 @@
1
- import { PlayerMediaSource } from '../internal.types'
2
1
  import DashPlayback from '../plugins/dash-playback/DashPlayback'
3
2
  import HlsPlayback from '../plugins/hls-playback/HlsPlayback'
4
- import { StreamMediaSource, TransportPreference } from '../types'
3
+ import type { PlayerMediaSource, TransportPreference } from '../types'
5
4
 
6
5
  export type SourceVariants = {
7
6
  dash: string | null
@@ -89,16 +88,3 @@ export function buildSourcesPriorityList(
89
88
  export function unwrapSource(s: PlayerMediaSource): string {
90
89
  return typeof s === 'string' ? s : s.source
91
90
  }
92
-
93
- export function buildGcoreStreamSourcesList(
94
- ms: StreamMediaSource,
95
- priorityTransport: TransportPreference,
96
- ): PlayerMediaSource[] {
97
- const sources: Record<'dash' | 'master' | 'hls' | 'mpegts', string | null> = {
98
- dash: ms.sourceDash,
99
- master: ms.source,
100
- hls: ms.hlsCmafUrl,
101
- mpegts: ms.hlsMpegtsUrl,
102
- }
103
- return buildSourcesPriorityList(sources, priorityTransport)
104
- }
package/src/version.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import * as pkg from '../package.json' with { "type": "json" };
2
2
  import * as lock from '../package-lock.json' with { "type": "json" };
3
3
 
4
+ /**
5
+ * Version information about the gplayer and its main dependencies
6
+ * @returns Version information about the gplayer and its main dependencies
7
+ * @beta
8
+ */
4
9
  export function version() {
5
10
  return {
6
11
  gplayer: pkg.version,