@vindral/web-sdk 2.0.7 → 2.0.11

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
@@ -85,6 +85,7 @@ declare class Emitter<TEvents, TEmits = TEvents, ArgLessEvents extends VoidKeys<
85
85
  once<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => void): void;
86
86
  private add;
87
87
  }
88
+ declare type FilterFunc<T> = (item: T) => boolean;
88
89
  declare class Fifo<T> {
89
90
  readonly maxSize: number;
90
91
  private values;
@@ -97,6 +98,7 @@ declare class Fifo<T> {
97
98
  isFull: () => boolean;
98
99
  isEmpty: () => boolean;
99
100
  items: () => ReadonlyArray<T>;
101
+ filterPop: (filter: FilterFunc<T>) => void;
100
102
  }
101
103
  declare type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<T>;
102
104
  interface MinMaxAverage {
@@ -171,6 +173,62 @@ declare class LoggerInstance implements Logger {
171
173
  error: (message: string, meta?: Meta | undefined) => void;
172
174
  critical: (message: string, meta?: Meta | undefined) => void;
173
175
  }
176
+ export declare type PlayInitiator = "user input" | "programatically";
177
+ export interface PlaybackSource {
178
+ volume: number;
179
+ muted: boolean;
180
+ currentTime: number;
181
+ playbackRate?: number;
182
+ readonly seekTime: number;
183
+ readonly isSeeking: boolean;
184
+ play(initiator: PlayInitiator): Promise<void>;
185
+ }
186
+ interface MediaElementOptions {
187
+ autoplay: boolean;
188
+ muted: boolean;
189
+ type: "audio" | "video";
190
+ logger: Logger;
191
+ }
192
+ interface NeedsUserInputContext {
193
+ forAudio: boolean;
194
+ forVideo: boolean;
195
+ }
196
+ interface MediaElementEvents {
197
+ ["needs user input"]: NeedsUserInputContext;
198
+ ["buffer state"]: Readonly<BufferState>;
199
+ }
200
+ declare class MediaElement extends Emitter<MediaElementEvents> {
201
+ readonly element: HTMLMediaElement;
202
+ private logger;
203
+ private seekTimes;
204
+ private seekStartTime?;
205
+ private _userProvidedMuted;
206
+ private _userHasProvidedInput;
207
+ constructor({ type, autoplay, muted, logger }: MediaElementOptions);
208
+ attach: (container: HTMLElement) => void;
209
+ get seekTime(): number;
210
+ get isSeeking(): boolean;
211
+ get currentTime(): number;
212
+ set currentTime(value: number);
213
+ get playbackRate(): number;
214
+ set playbackRate(rate: number);
215
+ get volume(): number;
216
+ set volume(volume: number);
217
+ get muted(): boolean;
218
+ set muted(muted: boolean);
219
+ get userHasProvidedInput(): boolean;
220
+ get paused(): boolean;
221
+ getPlaybackRate: () => number;
222
+ getPlaybackState: () => PlaybackState;
223
+ setPlaybackRate: (rate: number) => void;
224
+ getBuffer: () => TimeRange[];
225
+ play: (initiator: PlayInitiator) => Promise<void>;
226
+ private _play;
227
+ private onEvent;
228
+ private onBufferStateChange;
229
+ private onSeekStart;
230
+ private onSeekEnd;
231
+ }
174
232
  declare type PlaybackState = "buffering" | "playing";
175
233
  declare type BufferStateEvent = "filled" | "drained";
176
234
  declare type BufferState = {
@@ -180,6 +238,7 @@ declare type BufferState = {
180
238
  };
181
239
  interface PlaybackModuleListeners {
182
240
  ["buffer state"]: Readonly<BufferState>;
241
+ ["needs user input"]: NeedsUserInputContext;
183
242
  }
184
243
  interface PlaybackModuleEvents {
185
244
  ["buffer state event"]: Readonly<BufferStateEvent>;
@@ -191,6 +250,8 @@ interface ClockSource {
191
250
  }
192
251
  interface PlaybackModuleStatistics {
193
252
  bufferTime: number;
253
+ needsInputForAudioCount: number;
254
+ needsInputForVideoCount: number;
194
255
  }
195
256
  declare class PlaybackModule {
196
257
  private emitter;
@@ -201,6 +262,8 @@ declare class PlaybackModule {
201
262
  private targetBufferTime;
202
263
  private lastBufferStateEvent;
203
264
  private firstFrameTime?;
265
+ private needsInputForAudioCount;
266
+ private needsInputForVideoCount;
204
267
  constructor(emitter: Emitter<PlaybackModuleListeners, PlaybackModuleEvents>, logger: Logger, clockSource: ClockSource, targetBufferTime: number);
205
268
  static create: (emitter: Emitter<PlaybackModuleListeners, PlaybackModuleEvents>, logger: Logger, clockSource: ClockSource, targetBufferTime: number) => PlaybackModule;
206
269
  unload: () => void;
@@ -212,6 +275,7 @@ declare class PlaybackModule {
212
275
  getFirstFrameTime: () => number | undefined;
213
276
  getStatistics: () => PlaybackModuleStatistics;
214
277
  private onBufferedStateChanged;
278
+ private onNeedsUserInput;
215
279
  }
216
280
  declare type Direction = "upgrade" | "downgrade" | "double downgrade" | "reconnect";
217
281
  interface QualityOfServiceConfig {
@@ -267,10 +331,6 @@ declare class AdaptivityModule {
267
331
  private tooMuchTimeBuffering;
268
332
  private tooManyBufferingEvents;
269
333
  }
270
- interface NeedsUserInputContext {
271
- forAudio: boolean;
272
- forVideo: boolean;
273
- }
274
334
  interface AudioPlayerModuleListeners {
275
335
  ["decoded frame"]: Readonly<DecodedSample>;
276
336
  }
@@ -291,12 +351,14 @@ declare class AudioPlayerModule {
291
351
  private _muted;
292
352
  private startTime;
293
353
  private samples;
354
+ private preInitSampleQueue;
294
355
  private sampleRate;
295
356
  private channels;
296
357
  private index;
297
358
  private clockSource;
298
359
  private clockDelta?;
299
360
  private startTimeIsInvalidated;
361
+ private lastSampleTimestamp;
300
362
  get volume(): number;
301
363
  set volume(volume: number);
302
364
  get seekTime(): number;
@@ -329,6 +391,8 @@ export declare const AUTHENTICATION_EXPIRED_CODE = "authentication_expired";
329
391
  export declare const CHANNEL_NOT_FOUND_CODE = "channel_not_found";
330
392
  export declare const NO_INCOMING_DATA = "no_incoming_data_error";
331
393
  export declare const INACTIVITY_CODE = "connection_inactivity";
394
+ export declare const MISSING_INIT_SEGMENT = "missing_init_segment";
395
+ export declare const NO_TRACK_CONTEXT = "no_track_context";
332
396
  export declare class VindralError extends Error {
333
397
  private props;
334
398
  private extra;
@@ -339,18 +403,22 @@ export declare class VindralError extends Error {
339
403
  toStringifiable: () => Record<string, unknown>;
340
404
  }
341
405
  export declare const mediaElementError: (isFatal: boolean, mediaError: MediaError) => VindralError;
406
+ export declare const missingInitSegmentError: (renditionId: number, channelId: string) => VindralError;
407
+ export declare const noTrackContextError: (type: "audio" | "video", renditionId: number, channelId: string) => VindralError;
342
408
  export declare const audioContextTimeoutError: () => VindralError;
343
409
  export declare const authenticationError: () => VindralError;
344
410
  export declare const authenticationExpiredError: () => VindralError;
345
411
  export declare const inactivityError: () => VindralError;
346
412
  export declare const channelNotFoundError: () => VindralError;
347
413
  export declare const noIncomingDataError: () => VindralError;
348
- export declare const unableToConnectError: () => VindralError;
414
+ export declare const unableToConnectError: (source?: Error | undefined) => VindralError;
349
415
  export declare const unableToConnectAfterRetriesError: () => VindralError;
350
416
  declare type State = "connected" | "disconnected" | "connecting";
417
+ declare type ContextSwitchState = "completed" | "started";
351
418
  interface ConnectionModuleListeners {
352
419
  ["send signal"]: Readonly<string>;
353
420
  ["disconnect"]: void;
421
+ ["reconnect"]: string;
354
422
  }
355
423
  interface ConnectionModuleEvents {
356
424
  ["received signal"]: Readonly<Signal>;
@@ -358,6 +426,8 @@ interface ConnectionModuleEvents {
358
426
  ["connection state"]: Readonly<State>;
359
427
  ["rtt"]: number;
360
428
  ["error"]: Readonly<VindralError>;
429
+ ["context switch complete"]: Readonly<void>;
430
+ ["context switch started"]: Readonly<void>;
361
431
  }
362
432
  interface ConnectOptions {
363
433
  connectHandler: () => Promise<string>;
@@ -371,6 +441,7 @@ interface ConnectionStatistics {
371
441
  }
372
442
  declare class ConnectionModule {
373
443
  private static PING_INTERVAL;
444
+ private static MAX_MISSED_PINGS;
374
445
  private static TLS_ROUNDTRIPS;
375
446
  private timers;
376
447
  private emitter;
@@ -383,6 +454,7 @@ declare class ConnectionModule {
383
454
  private connectCount;
384
455
  private _firstConnectionTime?;
385
456
  private _lastConnectionTime?;
457
+ private missedPings;
386
458
  private contextSwitchesInProgress;
387
459
  private contextSwitchesCompleted;
388
460
  private buffer;
@@ -479,6 +551,7 @@ declare class RenditionsModule {
479
551
  setRenditions: (channelId: ChannelId, renditions: Rendition[]) => void;
480
552
  getLanguages: () => ReadonlyArray<string>;
481
553
  getVideoRendition: (renditionId: number, channelId?: string) => Readonly<VideoRendition> | undefined;
554
+ getAudioRenditions: (channelId: ChannelId) => Readonly<AudioRendition[]> | undefined;
482
555
  getAudioRendition: (renditionId: number, channelId?: string) => Readonly<AudioRendition> | undefined;
483
556
  getRendition: (renditionId: number, channelId?: string) => Readonly<Rendition> | undefined;
484
557
  getStatistics: () => RenditionsModuleStatistics;
@@ -611,6 +684,10 @@ declare class DecoderModule {
611
684
  }
612
685
  type ConnectionType = "bluetooth" | "cellular" | "ethernet" | "mixed" | "none" | "other" | "unknown" | "wifi" | "wimax";
613
686
  type EffectiveConnectionType = "2g" | "3g" | "4g" | "slow-2g";
687
+ interface DocumentState {
688
+ readonly isVisible: boolean;
689
+ readonly isOnline: boolean;
690
+ }
614
691
  interface DocumentStateEvents {
615
692
  ["page active"]: boolean;
616
693
  ["pagehide"]: PageTransitionEvent;
@@ -628,7 +705,7 @@ interface DocumentStateModulesStatistics {
628
705
  navigatorSaveData?: boolean;
629
706
  navigatorDownlink?: number;
630
707
  }
631
- declare class DocumentStateModule {
708
+ declare class DocumentStateModule implements DocumentState {
632
709
  private emitter;
633
710
  private isVisibleCount;
634
711
  private isHiddenCount;
@@ -641,6 +718,8 @@ declare class DocumentStateModule {
641
718
  load: () => void;
642
719
  unsuspend: () => void;
643
720
  getStatistics: () => DocumentStateModulesStatistics;
721
+ get isOnline(): boolean;
722
+ get isVisible(): boolean;
644
723
  private onOnline;
645
724
  private onOffline;
646
725
  private onPageHide;
@@ -653,6 +732,7 @@ interface IncomingDataModuleListeners {
653
732
  }
654
733
  interface IncomingDataModuleEvents {
655
734
  ["no data timeout"]: number;
735
+ ["reconnect"]: string;
656
736
  ["error"]: Readonly<VindralError>;
657
737
  }
658
738
  interface IncomingDataModuleStatistics {
@@ -899,7 +979,7 @@ declare class SyncModule {
899
979
  readonly catchupRate: 1.05;
900
980
  readonly slowdownRate: 0.95;
901
981
  };
902
- readonly maxTimeSyncDifferenceTolerance = 150;
982
+ readonly maxTimeSyncDifferenceTolerance = 20;
903
983
  private timers;
904
984
  private rtt;
905
985
  private channelSyncInfo;
@@ -923,7 +1003,9 @@ declare class SyncModule {
923
1003
  getCurrentChannelId: () => string | undefined;
924
1004
  updateChannelSyncInfo(channelId: string, syncInfo: SyncInfo): void;
925
1005
  getLiveEdgeTime: (channelId: string) => number | undefined;
1006
+ getLiveEdgeTimeLatencyAdjusted: (channelId: string) => number | undefined;
926
1007
  getWallclockTime: (channelId: string) => number | undefined;
1008
+ getWallclockTimeLatencyAdjusted: (channelId: string) => number | undefined;
927
1009
  get serverCurrentTime(): number;
928
1010
  processSample: <T extends SyncSample>(sample: T) => T;
929
1011
  getStatistics: () => SyncModuleStatistics;
@@ -987,6 +1069,7 @@ export declare type Statistics = ModuleStatistics & UserAgentInformation & {
987
1069
  };
988
1070
  export declare class Vindral extends Emitter<PublicVindralEvents> {
989
1071
  private static INITIAL_MAX_BIT_RATE;
1072
+ private static PING_TIMEOUT;
990
1073
  readonly pictureInPicture: {
991
1074
  enter: () => Promise<void>;
992
1075
  exit: () => Promise<void>;
@@ -1006,6 +1089,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1006
1089
  private createdAt;
1007
1090
  private hasCalledConnect;
1008
1091
  private apiClient;
1092
+ private latestEmittedLanguages;
1009
1093
  private durationSessions;
1010
1094
  constructor(options: Options);
1011
1095
  attach: (container: HTMLElement) => void;
@@ -1019,6 +1103,8 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1019
1103
  get connectionState(): Readonly<State>;
1020
1104
  get playbackState(): Readonly<PlaybackState>;
1021
1105
  get bufferFullness(): number;
1106
+ get sizeBasedResolutionCapEnabled(): boolean;
1107
+ set sizeBasedResolutionCapEnabled(enabled: boolean);
1022
1108
  get abrEnabled(): boolean;
1023
1109
  set abrEnabled(enabled: boolean);
1024
1110
  get serverEdgeTime(): number | undefined;
@@ -1036,12 +1122,10 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1036
1122
  set channelId(channelId: string);
1037
1123
  get maxSize(): Size;
1038
1124
  set maxSize(size: Size);
1039
- get maxBitRate(): number;
1040
- set maxBitRate(bitRate: number);
1041
- get maxVideoBitrate(): number;
1042
- set maxVideoBitrate(bitRate: number);
1043
- get maxAudioBitrate(): number;
1044
- set maxAudioBitrate(bitRate: number);
1125
+ get maxVideoBitRate(): number;
1126
+ set maxVideoBitRate(bitRate: number);
1127
+ get maxAudioBitRate(): number;
1128
+ set maxAudioBitRate(bitRate: number);
1045
1129
  get renditionLevels(): ReadonlyArray<RenditionLevel>;
1046
1130
  get currentRenditionLevel(): Readonly<RenditionLevel> | undefined;
1047
1131
  get targetRenditionLevel(): Readonly<RenditionLevel> | undefined;
@@ -1058,7 +1142,9 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1058
1142
  connect: () => void;
1059
1143
  getCastOptions: () => Options;
1060
1144
  private connectionInfo;
1145
+ private estimateRTT;
1061
1146
  private connectHandler;
1147
+ private emitLanguagesIfChanged;
1062
1148
  private filterRenditions;
1063
1149
  private patchSubscription;
1064
1150
  private isSupportedVideoCodecProfile;
@@ -1133,6 +1219,16 @@ declare class TimerModule {
1133
1219
  setInterval: (callback: (...args: unknown[]) => void, interval: number, ...args: unknown[]) => number;
1134
1220
  unload: () => void;
1135
1221
  }
1222
+ declare class UnpauseModule {
1223
+ private logger;
1224
+ private element;
1225
+ private documentState;
1226
+ private timers;
1227
+ private constructor();
1228
+ static create: (logger: Logger, element: MediaElement, documentState: DocumentState) => UnpauseModule;
1229
+ unload: () => void;
1230
+ private unpause;
1231
+ }
1136
1232
  interface VideoPlayerModuleListeners {
1137
1233
  ["decoded frame"]: Readonly<DecodedSample>;
1138
1234
  }
@@ -1182,6 +1278,7 @@ export interface Modules {
1182
1278
  telemetry?: TelemetryModule;
1183
1279
  documentState: DocumentStateModule;
1184
1280
  incomingData: IncomingDataModule;
1281
+ unpause?: UnpauseModule;
1185
1282
  }
1186
1283
  export interface ReconnectState {
1187
1284
  reconnectRetries: number;
@@ -1218,15 +1315,6 @@ export interface Options {
1218
1315
  advanced?: AdvancedOptions;
1219
1316
  media?: Media;
1220
1317
  }
1221
- export interface PlaybackSource {
1222
- volume: number;
1223
- muted: boolean;
1224
- currentTime: number;
1225
- playbackRate?: number;
1226
- readonly seekTime: number;
1227
- readonly isSeeking: boolean;
1228
- play(): Promise<void>;
1229
- }
1230
1318
  export interface PublicVindralEvents {
1231
1319
  ["error"]: Readonly<VindralError>;
1232
1320
  ["needs user input"]: NeedsUserInputContext;
@@ -1237,6 +1325,7 @@ export interface PublicVindralEvents {
1237
1325
  ["rendition level"]: Readonly<RenditionLevel>;
1238
1326
  ["languages"]: ReadonlyArray<string>;
1239
1327
  ["channels"]: ReadonlyArray<Channel>;
1328
+ ["context switch"]: Readonly<ContextSwitchState>;
1240
1329
  ["server wallclock time"]: Readonly<number>;
1241
1330
  ["buffer state event"]: Readonly<BufferStateEvent>;
1242
1331
  ["initialized media"]: void;
@@ -1469,12 +1558,22 @@ export interface PlayerOptions {
1469
1558
  fullscreenButtonEnabled?: boolean;
1470
1559
  pipButtonEnabled?: boolean;
1471
1560
  channelSelectionEnabled?: boolean;
1561
+ channelSelectionOptions?: {
1562
+ barButton?: {
1563
+ enabled?: boolean;
1564
+ thumbnails?: boolean;
1565
+ };
1566
+ list?: {
1567
+ enabled?: boolean;
1568
+ };
1569
+ };
1472
1570
  renditionLevelsEnabled?: boolean;
1473
1571
  languagesButtonEnabled?: boolean;
1474
1572
  oneToOneButtonEnabled?: boolean;
1475
1573
  hideTimeout?: number;
1476
1574
  castBackground?: string;
1477
1575
  castReceiverApplicationId?: string;
1576
+ thumbnailUpdateInterval?: number;
1478
1577
  }
1479
1578
  export interface PlayerState {
1480
1579
  isBuffering: boolean;
@@ -1489,9 +1588,11 @@ export declare class Player {
1489
1588
  private playerElement;
1490
1589
  private bufferingOverlay;
1491
1590
  private playOverlay;
1591
+ private channelSelectionList?;
1492
1592
  private bar;
1493
1593
  private stateInterval?;
1494
1594
  private showBufferingTimeout?;
1595
+ private thumbnailModule?;
1495
1596
  constructor(optionsOrInstance: Options | Vindral, playerOptions?: PlayerOptions);
1496
1597
  unload: () => void;
1497
1598
  attach: (container: HTMLElement) => void;
@@ -1506,6 +1607,7 @@ export declare class Player {
1506
1607
  private lockOrientation;
1507
1608
  private unlockOrientation;
1508
1609
  private checkState;
1610
+ private needsThumbnails;
1509
1611
  private bumpInteractTime;
1510
1612
  }
1511
1613
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vindral/web-sdk",
3
- "version": "2.0.7",
3
+ "version": "2.0.11",
4
4
  "homepage": "https://vindral.com",
5
5
  "description": "Web SDK for viewing Vindral streams",
6
6
  "license": "SEE LICENSE IN https://www.vindral.com/terms-conditions",