@vindral/web-sdk 3.2.5 → 3.3.1
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 +2 -0
- package/index.d.ts +600 -512
- package/{index.mjs → index.js} +2357 -2303
- package/index.umd.cjs +37 -0
- package/package.json +7 -7
- package/style.css +1 -1
- package/index.umd.js +0 -37
package/index.d.ts
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
type AudioCodec = "aac" | "opus" | "mp3";
|
|
2
2
|
type VideoCodec = "h264" | "av1";
|
|
3
|
+
/**
|
|
4
|
+
* Log level
|
|
5
|
+
* @enum
|
|
6
|
+
*/
|
|
7
|
+
export declare const Level: {
|
|
8
|
+
readonly CRITICAL: "critical";
|
|
9
|
+
readonly ERROR: "error";
|
|
10
|
+
readonly WARN: "warn";
|
|
11
|
+
readonly INFO: "info";
|
|
12
|
+
readonly DEBUG: "debug";
|
|
13
|
+
readonly TRACE: "trace";
|
|
14
|
+
};
|
|
15
|
+
export type Level = (typeof Level)[keyof typeof Level];
|
|
16
|
+
/**
|
|
17
|
+
* Represents a timed metadata event
|
|
18
|
+
*/
|
|
19
|
+
export interface Metadata {
|
|
20
|
+
/**
|
|
21
|
+
* The raw string content as it was ingested (if using JSON, it needs to be parsed on your end)
|
|
22
|
+
*/
|
|
23
|
+
content: string;
|
|
24
|
+
/**
|
|
25
|
+
* Timestamp in ms
|
|
26
|
+
*/
|
|
27
|
+
timestamp: number;
|
|
28
|
+
}
|
|
3
29
|
type MatchingKeys<TRecord, TMatch, K extends keyof TRecord = keyof TRecord> = K extends (TRecord[K] extends TMatch ? K : never) ? K : never;
|
|
4
30
|
type VoidKeys<Record> = MatchingKeys<Record, void>;
|
|
5
31
|
type EventListenerReturnType = (() => void) | void;
|
|
@@ -42,6 +68,22 @@ interface MinMaxAverage {
|
|
|
42
68
|
*/
|
|
43
69
|
min: number;
|
|
44
70
|
}
|
|
71
|
+
export interface TimeRange {
|
|
72
|
+
start: number;
|
|
73
|
+
end: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The current reconnect state to use to decide whether to kep reconnecting or not
|
|
77
|
+
*/
|
|
78
|
+
export interface ReconnectState {
|
|
79
|
+
/**
|
|
80
|
+
* The number or retry attempts so far.
|
|
81
|
+
* This gets reset on every successful connect, so it will start from zero every
|
|
82
|
+
* time the client instance gets disconnected and will increment until the
|
|
83
|
+
* client instance makes a connection attempt is successful.
|
|
84
|
+
*/
|
|
85
|
+
reconnectRetries: number;
|
|
86
|
+
}
|
|
45
87
|
interface RenditionProps {
|
|
46
88
|
id: number;
|
|
47
89
|
bitRate: number;
|
|
@@ -77,6 +119,227 @@ interface VideoConstraint {
|
|
|
77
119
|
codec?: VideoCodec;
|
|
78
120
|
codecString?: string;
|
|
79
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Advanced options to override default behaviour.
|
|
124
|
+
*/
|
|
125
|
+
export interface AdvancedOptions {
|
|
126
|
+
/**
|
|
127
|
+
* Constrains wasm decoding to this resolution.
|
|
128
|
+
* By default it is set to 1280 in width and height.
|
|
129
|
+
* This guarantees better performance on older devices and reduces battery drain in general.
|
|
130
|
+
*/
|
|
131
|
+
wasmDecodingConstraint: Partial<VideoConstraint>;
|
|
132
|
+
}
|
|
133
|
+
type Media = "audio" | "video" | "audio+video";
|
|
134
|
+
/**
|
|
135
|
+
* Options for the Vindral instance
|
|
136
|
+
*
|
|
137
|
+
*/
|
|
138
|
+
export interface Options {
|
|
139
|
+
/**
|
|
140
|
+
* URL to use when connecting to the stream
|
|
141
|
+
*/
|
|
142
|
+
url: string;
|
|
143
|
+
/**
|
|
144
|
+
* Channel ID to connect to initially - can be changed later mid-stream when connected to a channel group.
|
|
145
|
+
*/
|
|
146
|
+
channelId: string;
|
|
147
|
+
/**
|
|
148
|
+
* Channel group to connect to
|
|
149
|
+
* Note: Only needed for fast channel switching
|
|
150
|
+
*/
|
|
151
|
+
channelGroupId?: string;
|
|
152
|
+
/**
|
|
153
|
+
* A container to attach the video view in - can be provided later with .attach() on the vindral core instance
|
|
154
|
+
*/
|
|
155
|
+
container?: HTMLElement;
|
|
156
|
+
/**
|
|
157
|
+
* An authentication token to provide to the server when connecting - only needed for channels with authentication enabled
|
|
158
|
+
* Note: If not supplied when needed, an "Authentication Failed" error will be raised.
|
|
159
|
+
*/
|
|
160
|
+
authenticationToken?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Language to use initially - can be changed during during runtime on the vindral instance
|
|
163
|
+
* Note: Only needed when multiple languages are provided - if no language is specified, one will be automatically selected.
|
|
164
|
+
*/
|
|
165
|
+
language?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Sets the log level - defaults to info
|
|
168
|
+
*/
|
|
169
|
+
logLevel?: Level;
|
|
170
|
+
/**
|
|
171
|
+
* Sets the minimum and initial buffer time
|
|
172
|
+
*/
|
|
173
|
+
minBufferTime?: number;
|
|
174
|
+
/**
|
|
175
|
+
* Sets the maximum buffer time allowed. The vindral instance will automatically slowly increase
|
|
176
|
+
* the buffer time if the use experiences to much buffering with the initial buffer time.
|
|
177
|
+
*
|
|
178
|
+
* Note: This is not yet implemented
|
|
179
|
+
*/
|
|
180
|
+
maxBufferTime?: number;
|
|
181
|
+
/**
|
|
182
|
+
* Enables or disables user bandwidth savings by capping the video resolution to the size of the video element.
|
|
183
|
+
*
|
|
184
|
+
* Is enabled by default.
|
|
185
|
+
*
|
|
186
|
+
* Note: This is automatically set to false when abrEnabled is set to false.
|
|
187
|
+
*/
|
|
188
|
+
sizeBasedResolutionCapEnabled?: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Enables or disables picture in picture support.
|
|
191
|
+
*/
|
|
192
|
+
pictureInPictureEnabled?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Enable bursting for initial connection and channel switches. This makes time to first frame faster at the
|
|
195
|
+
* cost of stability (more demanding due to the sudden burst of live content)
|
|
196
|
+
*
|
|
197
|
+
* Is disabled by default.
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
burstEnabled?: boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Enable usage of the MediaSource API on supported browsers.
|
|
203
|
+
*
|
|
204
|
+
* Is enabled by default.
|
|
205
|
+
*
|
|
206
|
+
* Note: We recommend to keep this at the default value unless you have very specific needs.
|
|
207
|
+
*/
|
|
208
|
+
mseEnabled?: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Enable Opus with the MediaSource API on supported browsers.
|
|
211
|
+
*
|
|
212
|
+
* Is enabled by default.
|
|
213
|
+
*
|
|
214
|
+
* Note: Opus generally provides better audio quality and is therefore recommended to keep enabled.
|
|
215
|
+
*/
|
|
216
|
+
mseOpusEnabled?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Enable or disable support for playing audio in the background for iOS devices.
|
|
219
|
+
*
|
|
220
|
+
* Is false (disabled) by default.
|
|
221
|
+
*
|
|
222
|
+
* Note: This may be enabled by default in a future (major) release
|
|
223
|
+
*/
|
|
224
|
+
iosBackgroundPlayEnabled?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Enable or disable Adaptive Bit Rate. This allows for automatically adapting the incoming bit rate based on
|
|
227
|
+
* the viewers bandwidth and thus avoiding buffering events. This also disables the
|
|
228
|
+
* sizeBasedResolutionCapEnabled option.
|
|
229
|
+
*
|
|
230
|
+
* Is enabled by default.
|
|
231
|
+
*
|
|
232
|
+
* Note: It is strongly recommended to keep this enabled as user experience can greatly suffer without ABR.
|
|
233
|
+
*/
|
|
234
|
+
abrEnabled?: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Enable or disable telemetry. This allows for telemetry and errors being collected.
|
|
237
|
+
*
|
|
238
|
+
* Is enabled by default.
|
|
239
|
+
*
|
|
240
|
+
* We appreciate you turning it off during development/staging to not bloat real telemetry data.
|
|
241
|
+
*
|
|
242
|
+
* Note: It is strongly recommended to keep this enabled in production as it is required for insights and KPIs.
|
|
243
|
+
*/
|
|
244
|
+
telemetryEnabled?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Set a cap on the maximum video size.
|
|
247
|
+
* This can be used to provide user options to limit the video bandwidth usage.
|
|
248
|
+
*
|
|
249
|
+
* Note: This takes presedence over any size based resolution caps.
|
|
250
|
+
*/
|
|
251
|
+
maxSize?: Size;
|
|
252
|
+
/**
|
|
253
|
+
* Maximum audio bit rate allowed.
|
|
254
|
+
* This can be used to provide user options to limit the audio bandwidth usage.
|
|
255
|
+
*/
|
|
256
|
+
maxAudioBitRate?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Maximum video bit rate allowed.
|
|
259
|
+
* This can be used to provide user options to limit the video bandwidth usage.
|
|
260
|
+
*/
|
|
261
|
+
maxVideoBitRate?: number;
|
|
262
|
+
/**
|
|
263
|
+
* Controls video element background behaviour while loading.
|
|
264
|
+
* - If `false`, a black background will be shown.
|
|
265
|
+
* - If undefined or `true`, a live thumbnail will be shown.
|
|
266
|
+
* - If set to a string containing a URL (https://urltoimage), use that.
|
|
267
|
+
* Default `true` - meaning a live thumbnail is shown
|
|
268
|
+
*/
|
|
269
|
+
poster?: boolean | string;
|
|
270
|
+
/**
|
|
271
|
+
* Whether to start the player muted or to try to start playing audio automatically.
|
|
272
|
+
*/
|
|
273
|
+
muted?: boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Provide a custom reconnect handler to control when the instance should stop trying to
|
|
276
|
+
* reconnect. The reconnect handler should either return true to allow the reconnect or
|
|
277
|
+
* false to stop reconnecting. It can also return a promise with true or false if it needs
|
|
278
|
+
* to make any async calls before determining wether to reconnect.
|
|
279
|
+
*
|
|
280
|
+
* The default reconnect handler allows 30 reconnects before stopping.
|
|
281
|
+
*
|
|
282
|
+
* Note: the ReconnectState gets reset every time the client instance makes a successful connection.
|
|
283
|
+
* This means the default reconnect handler will only stop reconnecting after 30 _consecutive_ failed connections.
|
|
284
|
+
*
|
|
285
|
+
* ```typescript
|
|
286
|
+
* // An example reconnect handler that will reconnect forever
|
|
287
|
+
* const reconnectHandler = (state: ReconnectState) => true
|
|
288
|
+
*
|
|
289
|
+
* // An example reconnect handler that will fetch an url and determine whether to reconnect
|
|
290
|
+
* const reconnectHandler = async (state: ReconnectState) => {
|
|
291
|
+
* const result = await fetch("https://should-i-reconnect-now.com")
|
|
292
|
+
* return result.ok
|
|
293
|
+
* },
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
reconnectHandler?: (state: ReconnectState) => Promise<boolean> | boolean;
|
|
297
|
+
tags?: string[];
|
|
298
|
+
ownerSessionId?: string;
|
|
299
|
+
edgeUrl?: string;
|
|
300
|
+
logShippingEnabled?: boolean;
|
|
301
|
+
statsShippingEnabled?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Enable wake lock for iOS devices.
|
|
304
|
+
* The wake lock requires that the audio has been activated at least once for the instance, othwerwise it will not work.
|
|
305
|
+
* Other devices already provide wake lock by default.
|
|
306
|
+
*
|
|
307
|
+
* This option is redundant and has no effect if iosMediaElementEnabled is enabled since that automatically enables wake lock.
|
|
308
|
+
*
|
|
309
|
+
* Disabled by default.
|
|
310
|
+
*/
|
|
311
|
+
iosWakeLockEnabled?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Disabling this will revert to legacy behaviour where Vindral will try to always keep the video element playing.
|
|
314
|
+
*/
|
|
315
|
+
pauseSupportEnabled?: boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Enables iOS devices to use a media element for playback. This enables fullscreen and picture in picture support on iOS.
|
|
318
|
+
*/
|
|
319
|
+
iosMediaElementEnabled?: boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Advanced options to override default behaviour.
|
|
322
|
+
*/
|
|
323
|
+
advanced?: AdvancedOptions;
|
|
324
|
+
media?: Media;
|
|
325
|
+
videoCodecs?: VideoCodec[];
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Represents a rendition (quality level).
|
|
329
|
+
*/
|
|
330
|
+
export interface RenditionLevel {
|
|
331
|
+
audio?: AudioRendition;
|
|
332
|
+
video?: VideoRendition;
|
|
333
|
+
}
|
|
334
|
+
type RenditionLevelChangedReason = "abr" | "manual";
|
|
335
|
+
/**
|
|
336
|
+
* Contextual information about the rendition level change.
|
|
337
|
+
*/
|
|
338
|
+
export interface RenditionLevelChanged {
|
|
339
|
+
from?: RenditionLevel;
|
|
340
|
+
to?: RenditionLevel;
|
|
341
|
+
reason: RenditionLevelChangedReason;
|
|
342
|
+
}
|
|
80
343
|
/**
|
|
81
344
|
* Channel
|
|
82
345
|
*/
|
|
@@ -103,6 +366,9 @@ interface ClientOverrides {
|
|
|
103
366
|
minBufferTime?: number;
|
|
104
367
|
maxBufferTime?: number;
|
|
105
368
|
burstEnabled?: boolean;
|
|
369
|
+
sizeBasedResolutionCapEnabled?: boolean;
|
|
370
|
+
separateVideoSocketEnabled?: boolean;
|
|
371
|
+
videoCodecs?: string[];
|
|
106
372
|
}
|
|
107
373
|
interface ChannelWithRenditionsAndOverrides extends Channel {
|
|
108
374
|
renditions: Rendition[];
|
|
@@ -192,20 +458,7 @@ export declare class ApiClient {
|
|
|
192
458
|
private toChannel;
|
|
193
459
|
}
|
|
194
460
|
/**
|
|
195
|
-
*
|
|
196
|
-
*/
|
|
197
|
-
export interface Metadata {
|
|
198
|
-
/**
|
|
199
|
-
* The raw string content as it was ingested (if using JSON, it needs to be parsed on your end)
|
|
200
|
-
*/
|
|
201
|
-
content: string;
|
|
202
|
-
/**
|
|
203
|
-
* Timestamp in ms
|
|
204
|
-
*/
|
|
205
|
-
timestamp: number;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Available events to listen to
|
|
461
|
+
* Available events to listen to
|
|
209
462
|
*/
|
|
210
463
|
export interface CastSenderEvents {
|
|
211
464
|
/**
|
|
@@ -323,51 +576,6 @@ export declare class CastSender extends Emitter<CastSenderEvents> {
|
|
|
323
576
|
private castLibrariesAdded;
|
|
324
577
|
private verifyCastLibraries;
|
|
325
578
|
}
|
|
326
|
-
export interface TimeRange {
|
|
327
|
-
start: number;
|
|
328
|
-
end: number;
|
|
329
|
-
}
|
|
330
|
-
export declare enum Level {
|
|
331
|
-
TRACE = "trace",
|
|
332
|
-
DEBUG = "debug",
|
|
333
|
-
INFO = "info",
|
|
334
|
-
WARN = "warn",
|
|
335
|
-
ERROR = "error",
|
|
336
|
-
CRITICAL = "critical"
|
|
337
|
-
}
|
|
338
|
-
interface NeedsUserInputContext {
|
|
339
|
-
/**
|
|
340
|
-
* True if user input is needed for audio
|
|
341
|
-
*/
|
|
342
|
-
forAudio: boolean;
|
|
343
|
-
/**
|
|
344
|
-
* True if user input is needed for video
|
|
345
|
-
*/
|
|
346
|
-
forVideo: boolean;
|
|
347
|
-
}
|
|
348
|
-
type PlaybackState = "buffering" | "playing" | "paused";
|
|
349
|
-
type BufferStateEvent = "filled" | "drained";
|
|
350
|
-
interface PlaybackModuleStatistics {
|
|
351
|
-
/**
|
|
352
|
-
* Current target buffer time if using dynamic buffer. Otherwise, this is the statically set buffer time from instantiation.
|
|
353
|
-
*/
|
|
354
|
-
bufferTime: number;
|
|
355
|
-
needsInputForAudioCount: number;
|
|
356
|
-
needsInputForVideoCount: number;
|
|
357
|
-
}
|
|
358
|
-
interface AdaptivityStatistics {
|
|
359
|
-
/**
|
|
360
|
-
* True if adaptive bitrate (ABR) is enabled.
|
|
361
|
-
*/
|
|
362
|
-
isAbrEnabled: boolean;
|
|
363
|
-
}
|
|
364
|
-
interface BufferTimeStatistics {
|
|
365
|
-
/**
|
|
366
|
-
* Number of time buffer time has been adjusted. This will only happen when using dynamic buffer time
|
|
367
|
-
* (different min/max values of bufferTime).
|
|
368
|
-
*/
|
|
369
|
-
bufferTimeAdjustmentCount: number;
|
|
370
|
-
}
|
|
371
579
|
interface VindralErrorProps {
|
|
372
580
|
isFatal: boolean;
|
|
373
581
|
type?: ErrorType;
|
|
@@ -411,6 +619,26 @@ export declare class VindralError extends Error {
|
|
|
411
619
|
*/
|
|
412
620
|
toStringifiable: () => Record<string, unknown>;
|
|
413
621
|
}
|
|
622
|
+
type PlaybackState = "buffering" | "playing" | "paused";
|
|
623
|
+
type BufferStateEvent = "filled" | "drained";
|
|
624
|
+
interface PlaybackModuleStatistics {
|
|
625
|
+
/**
|
|
626
|
+
* Current target buffer time if using dynamic buffer. Otherwise, this is the statically set buffer time from instantiation.
|
|
627
|
+
*/
|
|
628
|
+
bufferTime: number;
|
|
629
|
+
needsInputForAudioCount: number;
|
|
630
|
+
needsInputForVideoCount: number;
|
|
631
|
+
}
|
|
632
|
+
interface NeedsUserInputContext {
|
|
633
|
+
/**
|
|
634
|
+
* True if user input is needed for audio
|
|
635
|
+
*/
|
|
636
|
+
forAudio: boolean;
|
|
637
|
+
/**
|
|
638
|
+
* True if user input is needed for video
|
|
639
|
+
*/
|
|
640
|
+
forVideo: boolean;
|
|
641
|
+
}
|
|
414
642
|
type State = "connected" | "disconnected" | "connecting";
|
|
415
643
|
type ContextSwitchState = "completed" | "started";
|
|
416
644
|
interface ConnectionStatistics {
|
|
@@ -433,20 +661,165 @@ interface ConnectionStatistics {
|
|
|
433
661
|
connectionAttemptCount: number;
|
|
434
662
|
}
|
|
435
663
|
/**
|
|
436
|
-
*
|
|
664
|
+
* Contextual information about the language switch
|
|
437
665
|
*/
|
|
438
|
-
export interface
|
|
439
|
-
|
|
440
|
-
|
|
666
|
+
export interface LanguageSwitchContext {
|
|
667
|
+
/**
|
|
668
|
+
* The new language that was switched to
|
|
669
|
+
*/
|
|
670
|
+
language: string;
|
|
441
671
|
}
|
|
442
|
-
type RenditionLevelChangedReason = "abr" | "manual";
|
|
443
672
|
/**
|
|
444
|
-
* Contextual information about the
|
|
673
|
+
* Contextual information about the channel switch
|
|
445
674
|
*/
|
|
446
|
-
export interface
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
675
|
+
export interface ChannelSwitchContext {
|
|
676
|
+
/**
|
|
677
|
+
* The new channel id that was switched to
|
|
678
|
+
*/
|
|
679
|
+
channelId: string;
|
|
680
|
+
}
|
|
681
|
+
interface VolumeState {
|
|
682
|
+
/**
|
|
683
|
+
* Wether the audio is muted
|
|
684
|
+
*/
|
|
685
|
+
isMuted: boolean;
|
|
686
|
+
/**
|
|
687
|
+
* The volume level
|
|
688
|
+
*/
|
|
689
|
+
volume: number;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* The events that can be emitted from the Vindral instance
|
|
693
|
+
*/
|
|
694
|
+
export interface PublicVindralEvents {
|
|
695
|
+
/**
|
|
696
|
+
* When an error that requires action has occured
|
|
697
|
+
*
|
|
698
|
+
* Can be a fatal error that will unload the Vindral instance - this is indicated by `isFatal()` on the error object returning true.
|
|
699
|
+
*
|
|
700
|
+
* In case of a fatal error it is appropriate to indicate what the error was to the user, either by displaying the error.message or
|
|
701
|
+
* by using the error.code() as a key to look up a localization string. To resume streaming it is required to create a new Vindral instance.
|
|
702
|
+
*/
|
|
703
|
+
["error"]: Readonly<VindralError>;
|
|
704
|
+
/**
|
|
705
|
+
* When the instance needs user input to activate audio or sometimes video playback.
|
|
706
|
+
* Is called with an object
|
|
707
|
+
* ```javascript
|
|
708
|
+
* {
|
|
709
|
+
* forAudio: boolean // true if user input is needed for audio playback
|
|
710
|
+
* forVideo: boolean // true if user input is needed for video playback
|
|
711
|
+
* }
|
|
712
|
+
* ```
|
|
713
|
+
*/
|
|
714
|
+
["needs user input"]: NeedsUserInputContext;
|
|
715
|
+
/**
|
|
716
|
+
* When a timed metadata event has been triggered
|
|
717
|
+
*/
|
|
718
|
+
["metadata"]: Readonly<Metadata>;
|
|
719
|
+
/**
|
|
720
|
+
* When the playback state changes
|
|
721
|
+
*/
|
|
722
|
+
["playback state"]: Readonly<PlaybackState>;
|
|
723
|
+
/**
|
|
724
|
+
* When the connection state changes
|
|
725
|
+
*/
|
|
726
|
+
["connection state"]: Readonly<State>;
|
|
727
|
+
/**
|
|
728
|
+
* When the available rendition levels is changed
|
|
729
|
+
*/
|
|
730
|
+
["rendition levels"]: ReadonlyArray<RenditionLevel>;
|
|
731
|
+
/**
|
|
732
|
+
* When the rendition level is changed
|
|
733
|
+
*/
|
|
734
|
+
["rendition level"]: Readonly<RenditionLevel>;
|
|
735
|
+
/**
|
|
736
|
+
* When the available languages is changed
|
|
737
|
+
*/
|
|
738
|
+
["languages"]: ReadonlyArray<string>;
|
|
739
|
+
/**
|
|
740
|
+
* When the available channels is changed
|
|
741
|
+
*/
|
|
742
|
+
["channels"]: ReadonlyArray<Channel>;
|
|
743
|
+
/**
|
|
744
|
+
* When a context switch state change has occured.
|
|
745
|
+
* E.g. when a channel change has been requested, or quality is changed.
|
|
746
|
+
*/
|
|
747
|
+
["context switch"]: Readonly<ContextSwitchState>;
|
|
748
|
+
/**
|
|
749
|
+
* Emitted when a wallclock time message has been received from the server.
|
|
750
|
+
*
|
|
751
|
+
* Note: This is the edge server wallclock time and thus may differ slightly
|
|
752
|
+
* between two viewers if they are connected to different edge servers.
|
|
753
|
+
*/
|
|
754
|
+
["server wallclock time"]: Readonly<number>;
|
|
755
|
+
/**
|
|
756
|
+
* Is emitted during connection whether the channel is live or not.
|
|
757
|
+
*
|
|
758
|
+
* If the channel is not live, the Vindral instance will try to reconnect until the `reconnectHandler`
|
|
759
|
+
* determines that no more retries should be made.
|
|
760
|
+
*
|
|
761
|
+
* Note: If the web-sdk is instantiated at the same time as you are starting the stream it is possible
|
|
762
|
+
* that this emits false until the started state has propagated through the system.
|
|
763
|
+
*/
|
|
764
|
+
["is live"]: boolean;
|
|
765
|
+
/**
|
|
766
|
+
* Emitted when a channel switch has been completed and the first frame of the new channel is rendered.
|
|
767
|
+
* A string containing the channel id of the new channel is provided as an argument.
|
|
768
|
+
*/
|
|
769
|
+
["channel switch"]: Readonly<ChannelSwitchContext>;
|
|
770
|
+
/**
|
|
771
|
+
* Emitted when a language switch has been completed and the new language starts playing.
|
|
772
|
+
*/
|
|
773
|
+
["language switch"]: Readonly<LanguageSwitchContext>;
|
|
774
|
+
/**
|
|
775
|
+
* Emitted when the volume state changes.
|
|
776
|
+
*
|
|
777
|
+
* This is triggered triggered both when the user changes the volume through the Vindral instance, but also
|
|
778
|
+
* from external sources such as OS media shortcuts or other native UI outside of the browser.
|
|
779
|
+
*/
|
|
780
|
+
["volume state"]: Readonly<VolumeState>;
|
|
781
|
+
["buffer state event"]: Readonly<BufferStateEvent>;
|
|
782
|
+
["initialized media"]: void;
|
|
783
|
+
}
|
|
784
|
+
declare const defaultOptions: {
|
|
785
|
+
sizeBasedResolutionCapEnabled: boolean;
|
|
786
|
+
pictureInPictureEnabled: boolean;
|
|
787
|
+
abrEnabled: boolean;
|
|
788
|
+
burstEnabled: boolean;
|
|
789
|
+
mseEnabled: boolean;
|
|
790
|
+
mseOpusEnabled: boolean;
|
|
791
|
+
muted: boolean;
|
|
792
|
+
minBufferTime: number;
|
|
793
|
+
maxBufferTime: number;
|
|
794
|
+
logLevel: Level;
|
|
795
|
+
maxSize: Size;
|
|
796
|
+
maxVideoBitRate: number;
|
|
797
|
+
maxAudioBitRate: number;
|
|
798
|
+
tags: string[];
|
|
799
|
+
media: Media;
|
|
800
|
+
poster: string | boolean;
|
|
801
|
+
reconnectHandler: (state: ReconnectState) => Promise<boolean> | boolean;
|
|
802
|
+
iosWakeLockEnabled: boolean;
|
|
803
|
+
telemetryEnabled: boolean;
|
|
804
|
+
iosMediaElementEnabled: boolean;
|
|
805
|
+
pauseSupportEnabled: boolean;
|
|
806
|
+
advanced: {
|
|
807
|
+
wasmDecodingConstraint: Partial<VideoConstraint>;
|
|
808
|
+
};
|
|
809
|
+
videoCodecs: VideoCodec[];
|
|
810
|
+
};
|
|
811
|
+
interface AdaptivityStatistics {
|
|
812
|
+
/**
|
|
813
|
+
* True if adaptive bitrate (ABR) is enabled.
|
|
814
|
+
*/
|
|
815
|
+
isAbrEnabled: boolean;
|
|
816
|
+
}
|
|
817
|
+
interface BufferTimeStatistics {
|
|
818
|
+
/**
|
|
819
|
+
* Number of time buffer time has been adjusted. This will only happen when using dynamic buffer time
|
|
820
|
+
* (different min/max values of bufferTime).
|
|
821
|
+
*/
|
|
822
|
+
bufferTimeAdjustmentCount: number;
|
|
450
823
|
}
|
|
451
824
|
interface RenditionsModuleStatistics {
|
|
452
825
|
/**
|
|
@@ -552,12 +925,6 @@ interface IncomingDataModuleStatistics {
|
|
|
552
925
|
*/
|
|
553
926
|
bytesReceived: number;
|
|
554
927
|
}
|
|
555
|
-
interface VideoPlayerStatistics {
|
|
556
|
-
renderedFrameCount: number;
|
|
557
|
-
rendererDroppedFrameCount: number;
|
|
558
|
-
contextLostCount: number;
|
|
559
|
-
contextRestoredCount: number;
|
|
560
|
-
}
|
|
561
928
|
interface MseModuleStatistics {
|
|
562
929
|
quotaErrorCount: number;
|
|
563
930
|
mediaSourceOpenTime: number;
|
|
@@ -594,20 +961,35 @@ interface SyncModuleStatistics {
|
|
|
594
961
|
timeshiftDriftAdjustmentCount: number;
|
|
595
962
|
seekTime: number;
|
|
596
963
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
964
|
+
interface TelemetryModuleStatistics {
|
|
965
|
+
/**
|
|
966
|
+
* The total amount of errors being spawned. Note that some media errors can trigger
|
|
967
|
+
* thousands of errors for a single client in a few seconds before recovering. Therefore,
|
|
968
|
+
* consider the number of viewers with errors, not just the total amount. Also, consider the median
|
|
969
|
+
* instead of the mean for average calculation.
|
|
970
|
+
*/
|
|
971
|
+
errorCount: number;
|
|
972
|
+
}
|
|
973
|
+
interface VideoPlayerStatistics {
|
|
974
|
+
renderedFrameCount: number;
|
|
975
|
+
rendererDroppedFrameCount: number;
|
|
976
|
+
contextLostCount: number;
|
|
977
|
+
contextRestoredCount: number;
|
|
978
|
+
}
|
|
979
|
+
declare class UserAgentInformation {
|
|
980
|
+
private highEntropyValues?;
|
|
981
|
+
constructor();
|
|
982
|
+
getUserAgentInformation(): {
|
|
983
|
+
userAgentLegacy: string;
|
|
984
|
+
ua: {
|
|
985
|
+
browser: {
|
|
986
|
+
brands: string[];
|
|
987
|
+
fullVersionBrands: string[];
|
|
988
|
+
majorVersions: string[];
|
|
989
|
+
};
|
|
990
|
+
device: string;
|
|
991
|
+
os: {
|
|
992
|
+
family: string;
|
|
611
993
|
version: string;
|
|
612
994
|
major_version: number;
|
|
613
995
|
};
|
|
@@ -969,483 +1351,176 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
|
|
|
969
1351
|
get bufferingRatios(): Map<string, number>;
|
|
970
1352
|
get timeSpentBuffering(): number;
|
|
971
1353
|
get timeActive(): number;
|
|
972
|
-
get mediaElement(): HTMLMediaElement | HTMLCanvasElement;
|
|
973
|
-
/**
|
|
974
|
-
* Get active Vindral Options
|
|
975
|
-
*/
|
|
976
|
-
getOptions: () => Options & typeof defaultOptions;
|
|
977
|
-
/**
|
|
978
|
-
* Get url for fetching thumbnail. Note that fetching thumbnails only works for an active channel.
|
|
979
|
-
*/
|
|
980
|
-
getThumbnailUrl: () => string;
|
|
981
|
-
/**
|
|
982
|
-
* Update authentication token on an already established and authenticated connection
|
|
983
|
-
*/
|
|
984
|
-
updateAuthenticationToken: (token: string) => void;
|
|
985
|
-
/**
|
|
986
|
-
* @deprecated since 3.0.0 Use play instead.
|
|
987
|
-
* Connects to the configured channel and starts streaming
|
|
988
|
-
*/
|
|
989
|
-
connect: () => void;
|
|
990
|
-
private _connect;
|
|
991
|
-
/**
|
|
992
|
-
* Get options that can be used for CastSender
|
|
993
|
-
*/
|
|
994
|
-
getCastOptions: () => Options;
|
|
995
|
-
private connectionInfo;
|
|
996
|
-
private estimateRTT;
|
|
997
|
-
private connectHandler;
|
|
998
|
-
private emitLanguagesIfChanged;
|
|
999
|
-
private filterRenditions;
|
|
1000
|
-
/**
|
|
1001
|
-
* Patch the subscription with properties from the channel that isn't known until connection
|
|
1002
|
-
* @param channel Channel with the renditions to patch the subscription based on
|
|
1003
|
-
*/
|
|
1004
|
-
private patchSubscription;
|
|
1005
|
-
private isSupportedVideoCodecProfile;
|
|
1006
|
-
private supportedAudioCodecs;
|
|
1007
|
-
private initializeDecodingModule;
|
|
1008
|
-
/**
|
|
1009
|
-
* Fully unloads the instance. This disconnects the clients and stops any background tasks.
|
|
1010
|
-
* This client instance can not be used after this has been called.
|
|
1011
|
-
*/
|
|
1012
|
-
unload: () => Promise<void>;
|
|
1013
|
-
/**
|
|
1014
|
-
* @deprecated since 3.0.0 Use play instead.
|
|
1015
|
-
*
|
|
1016
|
-
* Activates audio or video on web browsers that require a user gesture to enable media playback.
|
|
1017
|
-
* The Vindral instance will emit a "needs user input" event to indicate when this is needed.
|
|
1018
|
-
* But it is also safe to pre-emptively call this if it is more convenient - such as in cases where
|
|
1019
|
-
* the Vindral instance itself is created in a user input event.
|
|
1020
|
-
*
|
|
1021
|
-
* Requirements: This method needs to be called within an user-input event handler to function properly, such as
|
|
1022
|
-
* an onclick handler.
|
|
1023
|
-
*
|
|
1024
|
-
* Note: Even if you pre-emptively call this it is still recommended to listen to "needs user input"
|
|
1025
|
-
* and handle that event gracefully.
|
|
1026
|
-
*/
|
|
1027
|
-
userInput: () => void;
|
|
1028
|
-
/**
|
|
1029
|
-
* Pauses the stream. Call .play() to resume playback again.
|
|
1030
|
-
*/
|
|
1031
|
-
pause: () => void;
|
|
1032
|
-
/**
|
|
1033
|
-
*
|
|
1034
|
-
* Start playing the stream.
|
|
1035
|
-
*
|
|
1036
|
-
* This method also activates audio or video on web browsers that require a user gesture to enable media playback.
|
|
1037
|
-
* The Vindral instance will emit a "needs user input" event to indicate when this is needed.
|
|
1038
|
-
* But it is also safe to pre-emptively call this if it is more convenient - such as in cases where
|
|
1039
|
-
* the Vindral instance itself is created in a user input event.
|
|
1040
|
-
*
|
|
1041
|
-
* Note: In most browsers this method needs to be called within an user-input event handler, such as
|
|
1042
|
-
* an onclick handler in order to activate audio. Most implementations call this directly after constructing the Vindral
|
|
1043
|
-
* instance once in order to start playing, and then listen to a user-event in order to allow audio to be activated.
|
|
1044
|
-
*
|
|
1045
|
-
* Note 2: Even if you pre-emptively call this it is still recommended to listen to "needs user input"
|
|
1046
|
-
* and handle that event gracefully.
|
|
1047
|
-
*/
|
|
1048
|
-
play: () => Promise<void>;
|
|
1049
|
-
/**
|
|
1050
|
-
* How long in milliseconds since the instance was created
|
|
1051
|
-
*/
|
|
1052
|
-
get uptime(): number;
|
|
1053
|
-
/**
|
|
1054
|
-
* This method collects a statistics report from internal modules. While many of the report's properties are documented, the report may also contain undocumented
|
|
1055
|
-
* properties used internally or temporarily for monitoring and improving the performance of the service.
|
|
1056
|
-
*
|
|
1057
|
-
* Use undocumented properties at your own risk.
|
|
1058
|
-
*/
|
|
1059
|
-
getStatistics: () => Statistics;
|
|
1060
|
-
private resetModules;
|
|
1061
|
-
private suspend;
|
|
1062
|
-
private unsuspend;
|
|
1063
|
-
private getRuntimeInfo;
|
|
1064
|
-
private onMediaElementState;
|
|
1065
|
-
private onBufferEvent;
|
|
1066
|
-
/**
|
|
1067
|
-
* Aligns size and bitrate to match a rendition level correctly
|
|
1068
|
-
*/
|
|
1069
|
-
private alignSizeAndBitRate;
|
|
1070
|
-
private get currentSubscription();
|
|
1071
|
-
private get targetSubscription();
|
|
1072
|
-
private timeToFirstFrame;
|
|
1073
|
-
private willUseMediaSource;
|
|
1074
|
-
}
|
|
1075
|
-
interface TelemetryModuleStatistics {
|
|
1076
|
-
/**
|
|
1077
|
-
* The total amount of errors being spawned. Note that some media errors can trigger
|
|
1078
|
-
* thousands of errors for a single client in a few seconds before recovering. Therefore,
|
|
1079
|
-
* consider the number of viewers with errors, not just the total amount. Also, consider the median
|
|
1080
|
-
* instead of the mean for average calculation.
|
|
1081
|
-
*/
|
|
1082
|
-
errorCount: number;
|
|
1083
|
-
}
|
|
1084
|
-
/**
|
|
1085
|
-
* The current reconnect state to use to decide whether to kep reconnecting or not
|
|
1086
|
-
*/
|
|
1087
|
-
export interface ReconnectState {
|
|
1088
|
-
/**
|
|
1089
|
-
* The number or retry attempts so far.
|
|
1090
|
-
* This gets reset on every successful connect, so it will start from zero every
|
|
1091
|
-
* time the client instance gets disconnected and will increment until the
|
|
1092
|
-
* client instance makes a connection attempt is successful.
|
|
1093
|
-
*/
|
|
1094
|
-
reconnectRetries: number;
|
|
1095
|
-
}
|
|
1096
|
-
/**
|
|
1097
|
-
* Advanced options to override default behaviour.
|
|
1098
|
-
*/
|
|
1099
|
-
export interface AdvancedOptions {
|
|
1100
|
-
/**
|
|
1101
|
-
* Constrains wasm decoding to this resolution.
|
|
1102
|
-
* By default it is set to 1280 in width and height.
|
|
1103
|
-
* This guarantees better performance on older devices and reduces battery drain in general.
|
|
1104
|
-
*/
|
|
1105
|
-
wasmDecodingConstraint: Partial<VideoConstraint>;
|
|
1106
|
-
}
|
|
1107
|
-
type Media = "audio" | "video" | "audio+video";
|
|
1108
|
-
/**
|
|
1109
|
-
* Options for the Vindral instance
|
|
1110
|
-
*
|
|
1111
|
-
*/
|
|
1112
|
-
export interface Options {
|
|
1113
|
-
/**
|
|
1114
|
-
* URL to use when connecting to the stream
|
|
1115
|
-
*/
|
|
1116
|
-
url: string;
|
|
1117
|
-
/**
|
|
1118
|
-
* Channel ID to connect to initially - can be changed later mid-stream when connected to a channel group.
|
|
1119
|
-
*/
|
|
1120
|
-
channelId: string;
|
|
1121
|
-
/**
|
|
1122
|
-
* Channel group to connect to
|
|
1123
|
-
* Note: Only needed for fast channel switching
|
|
1124
|
-
*/
|
|
1125
|
-
channelGroupId?: string;
|
|
1126
|
-
/**
|
|
1127
|
-
* A container to attach the video view in - can be provided later with .attach() on the vindral core instance
|
|
1128
|
-
*/
|
|
1129
|
-
container?: HTMLElement;
|
|
1130
|
-
/**
|
|
1131
|
-
* An authentication token to provide to the server when connecting - only needed for channels with authentication enabled
|
|
1132
|
-
* Note: If not supplied when needed, an "Authentication Failed" error will be raised.
|
|
1133
|
-
*/
|
|
1134
|
-
authenticationToken?: string;
|
|
1135
|
-
/**
|
|
1136
|
-
* Language to use initially - can be changed during during runtime on the vindral instance
|
|
1137
|
-
* Note: Only needed when multiple languages are provided - if no language is specified, one will be automatically selected.
|
|
1138
|
-
*/
|
|
1139
|
-
language?: string;
|
|
1140
|
-
/**
|
|
1141
|
-
* Sets the log level - defaults to info
|
|
1142
|
-
*/
|
|
1143
|
-
logLevel?: Level;
|
|
1144
|
-
/**
|
|
1145
|
-
* Sets the minimum and initial buffer time
|
|
1146
|
-
*/
|
|
1147
|
-
minBufferTime?: number;
|
|
1148
|
-
/**
|
|
1149
|
-
* Sets the maximum buffer time allowed. The vindral instance will automatically slowly increase
|
|
1150
|
-
* the buffer time if the use experiences to much buffering with the initial buffer time.
|
|
1151
|
-
*
|
|
1152
|
-
* Note: This is not yet implemented
|
|
1153
|
-
*/
|
|
1154
|
-
maxBufferTime?: number;
|
|
1155
|
-
/**
|
|
1156
|
-
* Enables or disables user bandwidth savings by capping the video resolution to the size of the video element.
|
|
1157
|
-
*
|
|
1158
|
-
* Is enabled by default.
|
|
1159
|
-
*
|
|
1160
|
-
* Note: This is automatically set to false when abrEnabled is set to false.
|
|
1161
|
-
*/
|
|
1162
|
-
sizeBasedResolutionCapEnabled?: boolean;
|
|
1163
|
-
/**
|
|
1164
|
-
* Enables or disables picture in picture support.
|
|
1165
|
-
*/
|
|
1166
|
-
pictureInPictureEnabled?: boolean;
|
|
1167
|
-
/**
|
|
1168
|
-
* Enable bursting for initial connection and channel switches. This makes time to first frame faster at the
|
|
1169
|
-
* cost of stability (more demanding due to the sudden burst of live content)
|
|
1170
|
-
*
|
|
1171
|
-
* Is disabled by default.
|
|
1172
|
-
*
|
|
1173
|
-
*/
|
|
1174
|
-
burstEnabled?: boolean;
|
|
1175
|
-
/**
|
|
1176
|
-
* Enable usage of the MediaSource API on supported browsers.
|
|
1177
|
-
*
|
|
1178
|
-
* Is enabled by default.
|
|
1179
|
-
*
|
|
1180
|
-
* Note: We recommend to keep this at the default value unless you have very specific needs.
|
|
1181
|
-
*/
|
|
1182
|
-
mseEnabled?: boolean;
|
|
1183
|
-
/**
|
|
1184
|
-
* Enable Opus with the MediaSource API on supported browsers.
|
|
1185
|
-
*
|
|
1186
|
-
* Is enabled by default.
|
|
1187
|
-
*
|
|
1188
|
-
* Note: Opus generally provides better audio quality and is therefore recommended to keep enabled.
|
|
1189
|
-
*/
|
|
1190
|
-
mseOpusEnabled?: boolean;
|
|
1191
|
-
/**
|
|
1192
|
-
* Enable or disable support for playing audio in the background for iOS devices.
|
|
1193
|
-
*
|
|
1194
|
-
* Is false (disabled) by default.
|
|
1195
|
-
*
|
|
1196
|
-
* Note: This may be enabled by default in a future (major) release
|
|
1197
|
-
*/
|
|
1198
|
-
iosBackgroundPlayEnabled?: boolean;
|
|
1199
|
-
/**
|
|
1200
|
-
* Enable or disable Adaptive Bit Rate. This allows for automatically adapting the incoming bit rate based on
|
|
1201
|
-
* the viewers bandwidth and thus avoiding buffering events. This also disables the
|
|
1202
|
-
* sizeBasedResolutionCapEnabled option.
|
|
1203
|
-
*
|
|
1204
|
-
* Is enabled by default.
|
|
1205
|
-
*
|
|
1206
|
-
* Note: It is strongly recommended to keep this enabled as user experience can greatly suffer without ABR.
|
|
1207
|
-
*/
|
|
1208
|
-
abrEnabled?: boolean;
|
|
1209
|
-
/**
|
|
1210
|
-
* Enable or disable telemetry. This allows for telemetry and errors being collected.
|
|
1211
|
-
*
|
|
1212
|
-
* Is enabled by default.
|
|
1213
|
-
*
|
|
1214
|
-
* We appreciate you turning it off during development/staging to not bloat real telemetry data.
|
|
1215
|
-
*
|
|
1216
|
-
* Note: It is strongly recommended to keep this enabled in production as it is required for insights and KPIs.
|
|
1217
|
-
*/
|
|
1218
|
-
telemetryEnabled?: boolean;
|
|
1219
|
-
/**
|
|
1220
|
-
* Set a cap on the maximum video size.
|
|
1221
|
-
* This can be used to provide user options to limit the video bandwidth usage.
|
|
1222
|
-
*
|
|
1223
|
-
* Note: This takes presedence over any size based resolution caps.
|
|
1224
|
-
*/
|
|
1225
|
-
maxSize?: Size;
|
|
1226
|
-
/**
|
|
1227
|
-
* Maximum audio bit rate allowed.
|
|
1228
|
-
* This can be used to provide user options to limit the audio bandwidth usage.
|
|
1229
|
-
*/
|
|
1230
|
-
maxAudioBitRate?: number;
|
|
1231
|
-
/**
|
|
1232
|
-
* Maximum video bit rate allowed.
|
|
1233
|
-
* This can be used to provide user options to limit the video bandwidth usage.
|
|
1234
|
-
*/
|
|
1235
|
-
maxVideoBitRate?: number;
|
|
1354
|
+
get mediaElement(): HTMLMediaElement | HTMLCanvasElement;
|
|
1236
1355
|
/**
|
|
1237
|
-
*
|
|
1238
|
-
* - If `false`, a black background will be shown.
|
|
1239
|
-
* - If undefined or `true`, a live thumbnail will be shown.
|
|
1240
|
-
* - If set to a string containing a URL (https://urltoimage), use that.
|
|
1241
|
-
* Default `true` - meaning a live thumbnail is shown
|
|
1356
|
+
* Get active Vindral Options
|
|
1242
1357
|
*/
|
|
1243
|
-
|
|
1358
|
+
getOptions: () => Options & typeof defaultOptions;
|
|
1244
1359
|
/**
|
|
1245
|
-
*
|
|
1360
|
+
* Get url for fetching thumbnail. Note that fetching thumbnails only works for an active channel.
|
|
1246
1361
|
*/
|
|
1247
|
-
|
|
1362
|
+
getThumbnailUrl: () => string;
|
|
1248
1363
|
/**
|
|
1249
|
-
*
|
|
1250
|
-
* reconnect. The reconnect handler should either return true to allow the reconnect or
|
|
1251
|
-
* false to stop reconnecting. It can also return a promise with true or false if it needs
|
|
1252
|
-
* to make any async calls before determining wether to reconnect.
|
|
1253
|
-
*
|
|
1254
|
-
* The default reconnect handler allows 30 reconnects before stopping.
|
|
1255
|
-
*
|
|
1256
|
-
* Note: the ReconnectState gets reset every time the client instance makes a successful connection.
|
|
1257
|
-
* This means the default reconnect handler will only stop reconnecting after 30 _consecutive_ failed connections.
|
|
1258
|
-
*
|
|
1259
|
-
* ```typescript
|
|
1260
|
-
* // An example reconnect handler that will reconnect forever
|
|
1261
|
-
* const reconnectHandler = (state: ReconnectState) => true
|
|
1262
|
-
*
|
|
1263
|
-
* // An example reconnect handler that will fetch an url and determine whether to reconnect
|
|
1264
|
-
* const reconnectHandler = async (state: ReconnectState) => {
|
|
1265
|
-
* const result = await fetch("https://should-i-reconnect-now.com")
|
|
1266
|
-
* return result.ok
|
|
1267
|
-
* },
|
|
1268
|
-
* ```
|
|
1364
|
+
* Update authentication token on an already established and authenticated connection
|
|
1269
1365
|
*/
|
|
1270
|
-
|
|
1271
|
-
tags?: string[];
|
|
1272
|
-
ownerSessionId?: string;
|
|
1273
|
-
edgeUrl?: string;
|
|
1274
|
-
logShippingEnabled?: boolean;
|
|
1275
|
-
statsShippingEnabled?: boolean;
|
|
1366
|
+
updateAuthenticationToken: (token: string) => void;
|
|
1276
1367
|
/**
|
|
1277
|
-
*
|
|
1278
|
-
*
|
|
1279
|
-
* Other devices already provide wake lock by default.
|
|
1280
|
-
*
|
|
1281
|
-
* This option is redundant and has no effect if iosMediaElementEnabled is enabled since that automatically enables wake lock.
|
|
1282
|
-
*
|
|
1283
|
-
* Disabled by default.
|
|
1368
|
+
* @deprecated since 3.0.0 Use play instead.
|
|
1369
|
+
* Connects to the configured channel and starts streaming
|
|
1284
1370
|
*/
|
|
1285
|
-
|
|
1371
|
+
connect: () => void;
|
|
1372
|
+
private _connect;
|
|
1286
1373
|
/**
|
|
1287
|
-
*
|
|
1374
|
+
* Get options that can be used for CastSender
|
|
1288
1375
|
*/
|
|
1289
|
-
|
|
1376
|
+
getCastOptions: () => Options;
|
|
1377
|
+
private connectionInfo;
|
|
1378
|
+
private estimateRTT;
|
|
1379
|
+
private connectHandler;
|
|
1380
|
+
private emitLanguagesIfChanged;
|
|
1381
|
+
private filterRenditions;
|
|
1290
1382
|
/**
|
|
1291
|
-
*
|
|
1383
|
+
* Patch the subscription with properties from the channel that isn't known until connection
|
|
1384
|
+
* @param channel Channel with the renditions to patch the subscription based on
|
|
1292
1385
|
*/
|
|
1293
|
-
|
|
1386
|
+
private patchSubscription;
|
|
1387
|
+
private isSupportedVideoCodecProfile;
|
|
1388
|
+
private supportedAudioCodecs;
|
|
1389
|
+
private initializeDecodingModule;
|
|
1294
1390
|
/**
|
|
1295
|
-
*
|
|
1391
|
+
* Fully unloads the instance. This disconnects the clients and stops any background tasks.
|
|
1392
|
+
* This client instance can not be used after this has been called.
|
|
1296
1393
|
*/
|
|
1297
|
-
|
|
1298
|
-
media?: Media;
|
|
1299
|
-
videoCodecs?: VideoCodec[];
|
|
1300
|
-
}
|
|
1301
|
-
/**
|
|
1302
|
-
* Contextual information about the language switch
|
|
1303
|
-
*/
|
|
1304
|
-
export interface LanguageSwitchContext {
|
|
1394
|
+
unload: () => Promise<void>;
|
|
1305
1395
|
/**
|
|
1306
|
-
*
|
|
1396
|
+
* @deprecated since 3.0.0 Use play instead.
|
|
1397
|
+
*
|
|
1398
|
+
* Activates audio or video on web browsers that require a user gesture to enable media playback.
|
|
1399
|
+
* The Vindral instance will emit a "needs user input" event to indicate when this is needed.
|
|
1400
|
+
* But it is also safe to pre-emptively call this if it is more convenient - such as in cases where
|
|
1401
|
+
* the Vindral instance itself is created in a user input event.
|
|
1402
|
+
*
|
|
1403
|
+
* Requirements: This method needs to be called within an user-input event handler to function properly, such as
|
|
1404
|
+
* an onclick handler.
|
|
1405
|
+
*
|
|
1406
|
+
* Note: Even if you pre-emptively call this it is still recommended to listen to "needs user input"
|
|
1407
|
+
* and handle that event gracefully.
|
|
1307
1408
|
*/
|
|
1308
|
-
|
|
1309
|
-
}
|
|
1310
|
-
/**
|
|
1311
|
-
* Contextual information about the channel switch
|
|
1312
|
-
*/
|
|
1313
|
-
export interface ChannelSwitchContext {
|
|
1409
|
+
userInput: () => void;
|
|
1314
1410
|
/**
|
|
1315
|
-
*
|
|
1411
|
+
* Pauses the stream. Call .play() to resume playback again.
|
|
1316
1412
|
*/
|
|
1317
|
-
|
|
1318
|
-
}
|
|
1319
|
-
interface VolumeState {
|
|
1413
|
+
pause: () => void;
|
|
1320
1414
|
/**
|
|
1321
|
-
*
|
|
1415
|
+
*
|
|
1416
|
+
* Start playing the stream.
|
|
1417
|
+
*
|
|
1418
|
+
* This method also activates audio or video on web browsers that require a user gesture to enable media playback.
|
|
1419
|
+
* The Vindral instance will emit a "needs user input" event to indicate when this is needed.
|
|
1420
|
+
* But it is also safe to pre-emptively call this if it is more convenient - such as in cases where
|
|
1421
|
+
* the Vindral instance itself is created in a user input event.
|
|
1422
|
+
*
|
|
1423
|
+
* Note: In most browsers this method needs to be called within an user-input event handler, such as
|
|
1424
|
+
* an onclick handler in order to activate audio. Most implementations call this directly after constructing the Vindral
|
|
1425
|
+
* instance once in order to start playing, and then listen to a user-event in order to allow audio to be activated.
|
|
1426
|
+
*
|
|
1427
|
+
* Note 2: Even if you pre-emptively call this it is still recommended to listen to "needs user input"
|
|
1428
|
+
* and handle that event gracefully.
|
|
1322
1429
|
*/
|
|
1323
|
-
|
|
1430
|
+
play: () => Promise<void>;
|
|
1324
1431
|
/**
|
|
1325
|
-
*
|
|
1432
|
+
* How long in milliseconds since the instance was created
|
|
1326
1433
|
*/
|
|
1327
|
-
|
|
1328
|
-
}
|
|
1329
|
-
/**
|
|
1330
|
-
* The events that can be emitted from the Vindral instance
|
|
1331
|
-
*/
|
|
1332
|
-
export interface PublicVindralEvents {
|
|
1434
|
+
get uptime(): number;
|
|
1333
1435
|
/**
|
|
1334
|
-
*
|
|
1335
|
-
*
|
|
1336
|
-
* Can be a fatal error that will unload the Vindral instance - this is indicated by `isFatal()` on the error object returning true.
|
|
1436
|
+
* This method collects a statistics report from internal modules. While many of the report's properties are documented, the report may also contain undocumented
|
|
1437
|
+
* properties used internally or temporarily for monitoring and improving the performance of the service.
|
|
1337
1438
|
*
|
|
1338
|
-
*
|
|
1339
|
-
* by using the error.code() as a key to look up a localization string. To resume streaming it is required to create a new Vindral instance.
|
|
1439
|
+
* Use undocumented properties at your own risk.
|
|
1340
1440
|
*/
|
|
1341
|
-
|
|
1441
|
+
getStatistics: () => Statistics;
|
|
1442
|
+
private resetModules;
|
|
1443
|
+
private suspend;
|
|
1444
|
+
private unsuspend;
|
|
1445
|
+
private getRuntimeInfo;
|
|
1446
|
+
private onMediaElementState;
|
|
1447
|
+
private onBufferEvent;
|
|
1342
1448
|
/**
|
|
1343
|
-
*
|
|
1344
|
-
* Is called with an object
|
|
1345
|
-
* ```javascript
|
|
1346
|
-
* {
|
|
1347
|
-
* forAudio: boolean // true if user input is needed for audio playback
|
|
1348
|
-
* forVideo: boolean // true if user input is needed for video playback
|
|
1349
|
-
* }
|
|
1350
|
-
* ```
|
|
1449
|
+
* Aligns size and bitrate to match a rendition level correctly
|
|
1351
1450
|
*/
|
|
1352
|
-
|
|
1451
|
+
private alignSizeAndBitRate;
|
|
1452
|
+
private get currentSubscription();
|
|
1453
|
+
private get targetSubscription();
|
|
1454
|
+
private timeToFirstFrame;
|
|
1455
|
+
private willUseMediaSource;
|
|
1456
|
+
}
|
|
1457
|
+
interface AirPlaySenderEvents {
|
|
1353
1458
|
/**
|
|
1354
|
-
* When
|
|
1459
|
+
* When airplay targets are available.
|
|
1355
1460
|
*/
|
|
1356
|
-
["
|
|
1461
|
+
["available"]: void;
|
|
1357
1462
|
/**
|
|
1358
|
-
* When
|
|
1463
|
+
* When a connection has been established with an airplay target.
|
|
1359
1464
|
*/
|
|
1360
|
-
["
|
|
1465
|
+
["connected"]: void;
|
|
1361
1466
|
/**
|
|
1362
|
-
* When the
|
|
1467
|
+
* When the airplay target has lost or stopped a connection.
|
|
1363
1468
|
*/
|
|
1364
|
-
["
|
|
1469
|
+
["disconnected"]: void;
|
|
1470
|
+
}
|
|
1471
|
+
interface AirPlayConfig {
|
|
1365
1472
|
/**
|
|
1366
|
-
*
|
|
1473
|
+
* URL to use when connecting to the stream.
|
|
1367
1474
|
*/
|
|
1368
|
-
|
|
1475
|
+
url: string;
|
|
1369
1476
|
/**
|
|
1370
|
-
*
|
|
1477
|
+
* Channel ID to connect to.
|
|
1371
1478
|
*/
|
|
1372
|
-
|
|
1479
|
+
channelId: string;
|
|
1373
1480
|
/**
|
|
1374
|
-
*
|
|
1481
|
+
* A container to attach the video element in. This should be the same container that the vindral video element is attached to.
|
|
1375
1482
|
*/
|
|
1376
|
-
|
|
1483
|
+
container: HTMLElement;
|
|
1377
1484
|
/**
|
|
1378
|
-
*
|
|
1485
|
+
* An authentication token to provide to the server when connecting - only needed for channels with authentication enabled
|
|
1486
|
+
* Note: If not supplied when needed, an "Authentication Failed" error will be raised.
|
|
1379
1487
|
*/
|
|
1380
|
-
|
|
1488
|
+
authenticationToken?: string;
|
|
1489
|
+
}
|
|
1490
|
+
declare class AirPlaySender extends Emitter<AirPlaySenderEvents> {
|
|
1491
|
+
private config;
|
|
1492
|
+
private hlsUrl;
|
|
1493
|
+
private element;
|
|
1494
|
+
private connectingTimeout?;
|
|
1495
|
+
private browser;
|
|
1496
|
+
constructor(config: AirPlayConfig);
|
|
1381
1497
|
/**
|
|
1382
|
-
*
|
|
1383
|
-
* E.g. when a channel change has been requested, or quality is changed.
|
|
1498
|
+
* True if the instance is casting right now.
|
|
1384
1499
|
*/
|
|
1385
|
-
|
|
1500
|
+
get casting(): boolean;
|
|
1386
1501
|
/**
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1389
|
-
* Note: This is the edge server wallclock time and thus may differ slightly
|
|
1390
|
-
* between two viewers if they are connected to different edge servers.
|
|
1502
|
+
* Set the current channelId.
|
|
1391
1503
|
*/
|
|
1392
|
-
|
|
1504
|
+
set channelId(channelId: string);
|
|
1393
1505
|
/**
|
|
1394
|
-
*
|
|
1395
|
-
*
|
|
1396
|
-
* If the channel is not live, the Vindral instance will try to reconnect until the `reconnectHandler`
|
|
1397
|
-
* determines that no more retries should be made.
|
|
1398
|
-
*
|
|
1399
|
-
* Note: If the web-sdk is instantiated at the same time as you are starting the stream it is possible
|
|
1400
|
-
* that this emits false until the started state has propagated through the system.
|
|
1506
|
+
* Update authentication token on an already established and authenticated connection.
|
|
1401
1507
|
*/
|
|
1402
|
-
|
|
1508
|
+
updateAuthenticationToken: (_token: string) => void;
|
|
1403
1509
|
/**
|
|
1404
|
-
*
|
|
1405
|
-
* A string containing the channel id of the new channel is provided as an argument.
|
|
1510
|
+
* Fully unloads the instance. This disconnects the current listeners.
|
|
1406
1511
|
*/
|
|
1407
|
-
|
|
1512
|
+
unload: () => void;
|
|
1408
1513
|
/**
|
|
1409
|
-
*
|
|
1514
|
+
* Show the AirPlay picker.
|
|
1410
1515
|
*/
|
|
1411
|
-
|
|
1516
|
+
showPlaybackTargetPicker(): void;
|
|
1412
1517
|
/**
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
* This is triggered triggered both when the user changes the volume through the Vindral instance, but also
|
|
1416
|
-
* from external sources such as OS media shortcuts or other native UI outside of the browser.
|
|
1518
|
+
* Returns if AirPlay is supported.
|
|
1417
1519
|
*/
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1520
|
+
static isAirPlaySupported(): boolean;
|
|
1521
|
+
private onAirPlayAvailable;
|
|
1522
|
+
private onAirPlayPlaybackChanged;
|
|
1421
1523
|
}
|
|
1422
|
-
declare const defaultOptions: {
|
|
1423
|
-
sizeBasedResolutionCapEnabled: boolean;
|
|
1424
|
-
pictureInPictureEnabled: boolean;
|
|
1425
|
-
abrEnabled: boolean;
|
|
1426
|
-
burstEnabled: boolean;
|
|
1427
|
-
mseEnabled: boolean;
|
|
1428
|
-
mseOpusEnabled: boolean;
|
|
1429
|
-
muted: boolean;
|
|
1430
|
-
minBufferTime: number;
|
|
1431
|
-
maxBufferTime: number;
|
|
1432
|
-
logLevel: Level;
|
|
1433
|
-
maxSize: Size;
|
|
1434
|
-
maxVideoBitRate: number;
|
|
1435
|
-
maxAudioBitRate: number;
|
|
1436
|
-
tags: string[];
|
|
1437
|
-
media: Media;
|
|
1438
|
-
poster: string | boolean;
|
|
1439
|
-
reconnectHandler: (state: ReconnectState) => Promise<boolean> | boolean;
|
|
1440
|
-
iosWakeLockEnabled: boolean;
|
|
1441
|
-
telemetryEnabled: boolean;
|
|
1442
|
-
iosMediaElementEnabled: boolean;
|
|
1443
|
-
pauseSupportEnabled: boolean;
|
|
1444
|
-
advanced: {
|
|
1445
|
-
wasmDecodingConstraint: Partial<VideoConstraint>;
|
|
1446
|
-
};
|
|
1447
|
-
videoCodecs: VideoCodec[];
|
|
1448
|
-
};
|
|
1449
1524
|
/**
|
|
1450
1525
|
* Available options when initializing the Player. Used for enabling/disabling features
|
|
1451
1526
|
* and hiding/showing buttons in the control pane
|
|
@@ -1520,6 +1595,10 @@ export interface PlayerOptions {
|
|
|
1520
1595
|
* Enable or disable the pause and play button
|
|
1521
1596
|
*/
|
|
1522
1597
|
pauseButtonEnabled?: boolean;
|
|
1598
|
+
/**
|
|
1599
|
+
* Enable or disable the AirPlay button
|
|
1600
|
+
*/
|
|
1601
|
+
airPlayButtonEnabled?: boolean;
|
|
1523
1602
|
}
|
|
1524
1603
|
/**
|
|
1525
1604
|
* Represents a Vindral player
|
|
@@ -1541,6 +1620,10 @@ export declare class Player {
|
|
|
1541
1620
|
* The CastSender instance
|
|
1542
1621
|
*/
|
|
1543
1622
|
readonly castSender: CastSender;
|
|
1623
|
+
/**
|
|
1624
|
+
* The AirPlaySender instance
|
|
1625
|
+
*/
|
|
1626
|
+
readonly airPlaySender?: AirPlaySender;
|
|
1544
1627
|
private options;
|
|
1545
1628
|
private state;
|
|
1546
1629
|
private playerElement;
|
|
@@ -1562,6 +1645,7 @@ export declare class Player {
|
|
|
1562
1645
|
*/
|
|
1563
1646
|
attach: (container: HTMLElement) => void;
|
|
1564
1647
|
private setupCastSender;
|
|
1648
|
+
private setupAirPlaySender;
|
|
1565
1649
|
private onMouseMove;
|
|
1566
1650
|
private onClick;
|
|
1567
1651
|
private togglePip;
|
|
@@ -1588,6 +1672,10 @@ export declare class Player {
|
|
|
1588
1672
|
* Exit fullscreen mode
|
|
1589
1673
|
*/
|
|
1590
1674
|
exitFullscreen: () => Promise<void>;
|
|
1675
|
+
/**
|
|
1676
|
+
* Show the AirPlay picker
|
|
1677
|
+
*/
|
|
1678
|
+
showAirPlayPicker: () => void;
|
|
1591
1679
|
private lockOrientation;
|
|
1592
1680
|
private unlockOrientation;
|
|
1593
1681
|
private checkState;
|