@vindral/web-sdk 3.2.4 → 3.3.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.
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,8 @@ interface ClientOverrides {
103
366
  minBufferTime?: number;
104
367
  maxBufferTime?: number;
105
368
  burstEnabled?: boolean;
369
+ sizeBasedResolutionCapEnabled?: boolean;
370
+ separateVideoSocketEnabled?: boolean;
106
371
  }
107
372
  interface ChannelWithRenditionsAndOverrides extends Channel {
108
373
  renditions: Rendition[];
@@ -192,20 +457,7 @@ export declare class ApiClient {
192
457
  private toChannel;
193
458
  }
194
459
  /**
195
- * Represents a timed metadata event
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
460
+ * Available events to listen to
209
461
  */
210
462
  export interface CastSenderEvents {
211
463
  /**
@@ -323,51 +575,6 @@ export declare class CastSender extends Emitter<CastSenderEvents> {
323
575
  private castLibrariesAdded;
324
576
  private verifyCastLibraries;
325
577
  }
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
578
  interface VindralErrorProps {
372
579
  isFatal: boolean;
373
580
  type?: ErrorType;
@@ -411,6 +618,26 @@ export declare class VindralError extends Error {
411
618
  */
412
619
  toStringifiable: () => Record<string, unknown>;
413
620
  }
621
+ type PlaybackState = "buffering" | "playing" | "paused";
622
+ type BufferStateEvent = "filled" | "drained";
623
+ interface PlaybackModuleStatistics {
624
+ /**
625
+ * Current target buffer time if using dynamic buffer. Otherwise, this is the statically set buffer time from instantiation.
626
+ */
627
+ bufferTime: number;
628
+ needsInputForAudioCount: number;
629
+ needsInputForVideoCount: number;
630
+ }
631
+ interface NeedsUserInputContext {
632
+ /**
633
+ * True if user input is needed for audio
634
+ */
635
+ forAudio: boolean;
636
+ /**
637
+ * True if user input is needed for video
638
+ */
639
+ forVideo: boolean;
640
+ }
414
641
  type State = "connected" | "disconnected" | "connecting";
415
642
  type ContextSwitchState = "completed" | "started";
416
643
  interface ConnectionStatistics {
@@ -433,20 +660,165 @@ interface ConnectionStatistics {
433
660
  connectionAttemptCount: number;
434
661
  }
435
662
  /**
436
- * Represents a rendition (quality level).
663
+ * Contextual information about the language switch
437
664
  */
438
- export interface RenditionLevel {
439
- audio?: AudioRendition;
440
- video?: VideoRendition;
665
+ export interface LanguageSwitchContext {
666
+ /**
667
+ * The new language that was switched to
668
+ */
669
+ language: string;
441
670
  }
442
- type RenditionLevelChangedReason = "abr" | "manual";
443
671
  /**
444
- * Contextual information about the rendition level change.
672
+ * Contextual information about the channel switch
445
673
  */
446
- export interface RenditionLevelChanged {
447
- from?: RenditionLevel;
448
- to?: RenditionLevel;
449
- reason: RenditionLevelChangedReason;
674
+ export interface ChannelSwitchContext {
675
+ /**
676
+ * The new channel id that was switched to
677
+ */
678
+ channelId: string;
679
+ }
680
+ interface VolumeState {
681
+ /**
682
+ * Wether the audio is muted
683
+ */
684
+ isMuted: boolean;
685
+ /**
686
+ * The volume level
687
+ */
688
+ volume: number;
689
+ }
690
+ /**
691
+ * The events that can be emitted from the Vindral instance
692
+ */
693
+ export interface PublicVindralEvents {
694
+ /**
695
+ * When an error that requires action has occured
696
+ *
697
+ * Can be a fatal error that will unload the Vindral instance - this is indicated by `isFatal()` on the error object returning true.
698
+ *
699
+ * 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
700
+ * 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.
701
+ */
702
+ ["error"]: Readonly<VindralError>;
703
+ /**
704
+ * When the instance needs user input to activate audio or sometimes video playback.
705
+ * Is called with an object
706
+ * ```javascript
707
+ * {
708
+ * forAudio: boolean // true if user input is needed for audio playback
709
+ * forVideo: boolean // true if user input is needed for video playback
710
+ * }
711
+ * ```
712
+ */
713
+ ["needs user input"]: NeedsUserInputContext;
714
+ /**
715
+ * When a timed metadata event has been triggered
716
+ */
717
+ ["metadata"]: Readonly<Metadata>;
718
+ /**
719
+ * When the playback state changes
720
+ */
721
+ ["playback state"]: Readonly<PlaybackState>;
722
+ /**
723
+ * When the connection state changes
724
+ */
725
+ ["connection state"]: Readonly<State>;
726
+ /**
727
+ * When the available rendition levels is changed
728
+ */
729
+ ["rendition levels"]: ReadonlyArray<RenditionLevel>;
730
+ /**
731
+ * When the rendition level is changed
732
+ */
733
+ ["rendition level"]: Readonly<RenditionLevel>;
734
+ /**
735
+ * When the available languages is changed
736
+ */
737
+ ["languages"]: ReadonlyArray<string>;
738
+ /**
739
+ * When the available channels is changed
740
+ */
741
+ ["channels"]: ReadonlyArray<Channel>;
742
+ /**
743
+ * When a context switch state change has occured.
744
+ * E.g. when a channel change has been requested, or quality is changed.
745
+ */
746
+ ["context switch"]: Readonly<ContextSwitchState>;
747
+ /**
748
+ * Emitted when a wallclock time message has been received from the server.
749
+ *
750
+ * Note: This is the edge server wallclock time and thus may differ slightly
751
+ * between two viewers if they are connected to different edge servers.
752
+ */
753
+ ["server wallclock time"]: Readonly<number>;
754
+ /**
755
+ * Is emitted during connection whether the channel is live or not.
756
+ *
757
+ * If the channel is not live, the Vindral instance will try to reconnect until the `reconnectHandler`
758
+ * determines that no more retries should be made.
759
+ *
760
+ * Note: If the web-sdk is instantiated at the same time as you are starting the stream it is possible
761
+ * that this emits false until the started state has propagated through the system.
762
+ */
763
+ ["is live"]: boolean;
764
+ /**
765
+ * Emitted when a channel switch has been completed and the first frame of the new channel is rendered.
766
+ * A string containing the channel id of the new channel is provided as an argument.
767
+ */
768
+ ["channel switch"]: Readonly<ChannelSwitchContext>;
769
+ /**
770
+ * Emitted when a language switch has been completed and the new language starts playing.
771
+ */
772
+ ["language switch"]: Readonly<LanguageSwitchContext>;
773
+ /**
774
+ * Emitted when the volume state changes.
775
+ *
776
+ * This is triggered triggered both when the user changes the volume through the Vindral instance, but also
777
+ * from external sources such as OS media shortcuts or other native UI outside of the browser.
778
+ */
779
+ ["volume state"]: Readonly<VolumeState>;
780
+ ["buffer state event"]: Readonly<BufferStateEvent>;
781
+ ["initialized media"]: void;
782
+ }
783
+ declare const defaultOptions: {
784
+ sizeBasedResolutionCapEnabled: boolean;
785
+ pictureInPictureEnabled: boolean;
786
+ abrEnabled: boolean;
787
+ burstEnabled: boolean;
788
+ mseEnabled: boolean;
789
+ mseOpusEnabled: boolean;
790
+ muted: boolean;
791
+ minBufferTime: number;
792
+ maxBufferTime: number;
793
+ logLevel: Level;
794
+ maxSize: Size;
795
+ maxVideoBitRate: number;
796
+ maxAudioBitRate: number;
797
+ tags: string[];
798
+ media: Media;
799
+ poster: string | boolean;
800
+ reconnectHandler: (state: ReconnectState) => Promise<boolean> | boolean;
801
+ iosWakeLockEnabled: boolean;
802
+ telemetryEnabled: boolean;
803
+ iosMediaElementEnabled: boolean;
804
+ pauseSupportEnabled: boolean;
805
+ advanced: {
806
+ wasmDecodingConstraint: Partial<VideoConstraint>;
807
+ };
808
+ videoCodecs: VideoCodec[];
809
+ };
810
+ interface AdaptivityStatistics {
811
+ /**
812
+ * True if adaptive bitrate (ABR) is enabled.
813
+ */
814
+ isAbrEnabled: boolean;
815
+ }
816
+ interface BufferTimeStatistics {
817
+ /**
818
+ * Number of time buffer time has been adjusted. This will only happen when using dynamic buffer time
819
+ * (different min/max values of bufferTime).
820
+ */
821
+ bufferTimeAdjustmentCount: number;
450
822
  }
451
823
  interface RenditionsModuleStatistics {
452
824
  /**
@@ -552,12 +924,6 @@ interface IncomingDataModuleStatistics {
552
924
  */
553
925
  bytesReceived: number;
554
926
  }
555
- interface VideoPlayerStatistics {
556
- renderedFrameCount: number;
557
- rendererDroppedFrameCount: number;
558
- contextLostCount: number;
559
- contextRestoredCount: number;
560
- }
561
927
  interface MseModuleStatistics {
562
928
  quotaErrorCount: number;
563
929
  mediaSourceOpenTime: number;
@@ -594,20 +960,35 @@ interface SyncModuleStatistics {
594
960
  timeshiftDriftAdjustmentCount: number;
595
961
  seekTime: number;
596
962
  }
597
- declare class UserAgentInformation {
598
- private highEntropyValues?;
599
- constructor();
600
- getUserAgentInformation(): {
601
- userAgentLegacy: string;
602
- ua: {
603
- browser: {
604
- brands: string[];
605
- fullVersionBrands: string[];
606
- majorVersions: string[];
607
- };
608
- device: string;
609
- os: {
610
- family: string;
963
+ interface TelemetryModuleStatistics {
964
+ /**
965
+ * The total amount of errors being spawned. Note that some media errors can trigger
966
+ * thousands of errors for a single client in a few seconds before recovering. Therefore,
967
+ * consider the number of viewers with errors, not just the total amount. Also, consider the median
968
+ * instead of the mean for average calculation.
969
+ */
970
+ errorCount: number;
971
+ }
972
+ interface VideoPlayerStatistics {
973
+ renderedFrameCount: number;
974
+ rendererDroppedFrameCount: number;
975
+ contextLostCount: number;
976
+ contextRestoredCount: number;
977
+ }
978
+ declare class UserAgentInformation {
979
+ private highEntropyValues?;
980
+ constructor();
981
+ getUserAgentInformation(): {
982
+ userAgentLegacy: string;
983
+ ua: {
984
+ browser: {
985
+ brands: string[];
986
+ fullVersionBrands: string[];
987
+ majorVersions: string[];
988
+ };
989
+ device: string;
990
+ os: {
991
+ family: string;
611
992
  version: string;
612
993
  major_version: number;
613
994
  };
@@ -1072,380 +1453,6 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1072
1453
  private timeToFirstFrame;
1073
1454
  private willUseMediaSource;
1074
1455
  }
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;
1236
- /**
1237
- * Controls video element background behaviour while loading.
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
1242
- */
1243
- poster?: boolean | string;
1244
- /**
1245
- * Whether to start the player muted or to try to start playing audio automatically.
1246
- */
1247
- muted?: boolean;
1248
- /**
1249
- * Provide a custom reconnect handler to control when the instance should stop trying to
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
- * ```
1269
- */
1270
- reconnectHandler?: (state: ReconnectState) => Promise<boolean> | boolean;
1271
- tags?: string[];
1272
- ownerSessionId?: string;
1273
- edgeUrl?: string;
1274
- logShippingEnabled?: boolean;
1275
- statsShippingEnabled?: boolean;
1276
- /**
1277
- * Enable wake lock for iOS devices.
1278
- * The wake lock requires that the audio has been activated at least once for the instance, othwerwise it will not work.
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.
1284
- */
1285
- iosWakeLockEnabled?: boolean;
1286
- /**
1287
- * Disabling this will revert to legacy behaviour where Vindral will try to always keep the video element playing.
1288
- */
1289
- pauseSupportEnabled?: boolean;
1290
- /**
1291
- * Enables iOS devices to use a media element for playback. This enables fullscreen and picture in picture support on iOS.
1292
- */
1293
- iosMediaElementEnabled?: boolean;
1294
- /**
1295
- * Advanced options to override default behaviour.
1296
- */
1297
- advanced?: AdvancedOptions;
1298
- media?: Media;
1299
- videoCodecs?: VideoCodec[];
1300
- }
1301
- /**
1302
- * Contextual information about the language switch
1303
- */
1304
- export interface LanguageSwitchContext {
1305
- /**
1306
- * The new language that was switched to
1307
- */
1308
- language: string;
1309
- }
1310
- /**
1311
- * Contextual information about the channel switch
1312
- */
1313
- export interface ChannelSwitchContext {
1314
- /**
1315
- * The new channel id that was switched to
1316
- */
1317
- channelId: string;
1318
- }
1319
- interface VolumeState {
1320
- /**
1321
- * Wether the audio is muted
1322
- */
1323
- isMuted: boolean;
1324
- /**
1325
- * The volume level
1326
- */
1327
- volume: number;
1328
- }
1329
- /**
1330
- * The events that can be emitted from the Vindral instance
1331
- */
1332
- export interface PublicVindralEvents {
1333
- /**
1334
- * When an error that requires action has occured
1335
- *
1336
- * Can be a fatal error that will unload the Vindral instance - this is indicated by `isFatal()` on the error object returning true.
1337
- *
1338
- * 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
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.
1340
- */
1341
- ["error"]: Readonly<VindralError>;
1342
- /**
1343
- * When the instance needs user input to activate audio or sometimes video playback.
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
- * ```
1351
- */
1352
- ["needs user input"]: NeedsUserInputContext;
1353
- /**
1354
- * When a timed metadata event has been triggered
1355
- */
1356
- ["metadata"]: Readonly<Metadata>;
1357
- /**
1358
- * When the playback state changes
1359
- */
1360
- ["playback state"]: Readonly<PlaybackState>;
1361
- /**
1362
- * When the connection state changes
1363
- */
1364
- ["connection state"]: Readonly<State>;
1365
- /**
1366
- * When the available rendition levels is changed
1367
- */
1368
- ["rendition levels"]: ReadonlyArray<RenditionLevel>;
1369
- /**
1370
- * When the rendition level is changed
1371
- */
1372
- ["rendition level"]: Readonly<RenditionLevel>;
1373
- /**
1374
- * When the available languages is changed
1375
- */
1376
- ["languages"]: ReadonlyArray<string>;
1377
- /**
1378
- * When the available channels is changed
1379
- */
1380
- ["channels"]: ReadonlyArray<Channel>;
1381
- /**
1382
- * When a context switch state change has occured.
1383
- * E.g. when a channel change has been requested, or quality is changed.
1384
- */
1385
- ["context switch"]: Readonly<ContextSwitchState>;
1386
- /**
1387
- * Emitted when a wallclock time message has been received from the server.
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.
1391
- */
1392
- ["server wallclock time"]: Readonly<number>;
1393
- /**
1394
- * Is emitted during connection whether the channel is live or not.
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.
1401
- */
1402
- ["is live"]: boolean;
1403
- /**
1404
- * Emitted when a channel switch has been completed and the first frame of the new channel is rendered.
1405
- * A string containing the channel id of the new channel is provided as an argument.
1406
- */
1407
- ["channel switch"]: Readonly<ChannelSwitchContext>;
1408
- /**
1409
- * Emitted when a language switch has been completed and the new language starts playing.
1410
- */
1411
- ["language switch"]: Readonly<LanguageSwitchContext>;
1412
- /**
1413
- * Emitted when the volume state changes.
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.
1417
- */
1418
- ["volume state"]: Readonly<VolumeState>;
1419
- ["buffer state event"]: Readonly<BufferStateEvent>;
1420
- ["initialized media"]: void;
1421
- }
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
1456
  /**
1450
1457
  * Available options when initializing the Player. Used for enabling/disabling features
1451
1458
  * and hiding/showing buttons in the control pane
@@ -1576,8 +1583,18 @@ export declare class Player {
1576
1583
  */
1577
1584
  private triggerUserInput;
1578
1585
  private toggleOneToOne;
1579
- private enterFullscreen;
1580
- private exitFullscreen;
1586
+ /**
1587
+ * Returns true if the player is currently in fullscreen mode
1588
+ */
1589
+ isInFullscreen: () => boolean;
1590
+ /**
1591
+ * Enter fullscreen mode
1592
+ */
1593
+ enterFullscreen: () => Promise<void>;
1594
+ /**
1595
+ * Exit fullscreen mode
1596
+ */
1597
+ exitFullscreen: () => Promise<void>;
1581
1598
  private lockOrientation;
1582
1599
  private unlockOrientation;
1583
1600
  private checkState;