@vindral/web-sdk 4.5.0 → 4.5.1-10-g5556eb794

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/legacy.d.ts CHANGED
@@ -275,11 +275,20 @@ export interface Options {
275
275
  */
276
276
  mseOpusEnabled?: boolean;
277
277
  /**
278
- * Enable or disable support for playing audio in the background for iOS devices.
278
+ * Keep playback running while the page is in the background. Enabled by default.
279
+ * When disabled, the session disconnects while hidden and reconnects when visible.
279
280
  *
280
- * Is false (disabled) by default.
281
+ * Browser media policies still apply; iOS Safari pauses hidden video regardless.
282
+ * Call `play()` again from a user gesture or media-control action to resume.
281
283
  *
282
- * Note: This may be enabled by default in a future (major) release
284
+ * When enabled, hidden sessions that are muted outside Picture-in-Picture or browser-paused
285
+ * are disconnected after the inactivity timeout; an explicit `pause()` disconnects at once.
286
+ */
287
+ backgroundPlayEnabled?: boolean;
288
+ /**
289
+ * @deprecated Use `backgroundPlayEnabled` instead.
290
+ *
291
+ * Legacy alias kept for backwards compatibility.
283
292
  */
284
293
  iosBackgroundPlayEnabled?: boolean;
285
294
  /**
@@ -656,6 +665,7 @@ export declare const CONNECTION_FAILED_AFTER_RETRIES_CODE = "connection_failed_w
656
665
  export declare const AUTHENTICATION_FAILED_CODE = "authentication_error";
657
666
  export declare const AUTHENTICATION_EXPIRED_CODE = "authentication_expired";
658
667
  export declare const CHANNEL_NOT_FOUND_CODE = "channel_not_found";
668
+ export declare const CHANNEL_NOT_LIVE_CODE = "channel_not_live";
659
669
  export declare const NO_INCOMING_DATA = "no_incoming_data_error";
660
670
  export declare const INACTIVITY_CODE = "connection_inactivity";
661
671
  export declare const DISCONNECTED_BY_EDGE = "disconnected_by_edge";
@@ -1111,11 +1121,47 @@ export type Statistics = ModuleStatistics & ReturnType<UserAgentInformation["get
1111
1121
  */
1112
1122
  timeshiftAdjustmentsPerMinute: number;
1113
1123
  };
1124
+ /**
1125
+ * Represents a Vindral client instance
1126
+ *
1127
+ * The most most essential methods when using the Vindral class are:
1128
+ *
1129
+ * - connect() - this has to be called to actually start connecting
1130
+ * - attach() - to attach the Vindral video view to the DOM so that users can see it
1131
+ * - userInput() - to activate audio on browsers that require a user gesture to play audio
1132
+ * - unload() - unloads the instance, its very important that this is called when cleaning up the Vindral instance, otherwise background timers may leak.
1133
+ *
1134
+ * The Vindral instance will emit a variety of events during its lifetime. Use .on("event-name", callback) to listen to these events.
1135
+ * See [[PublicVindralEvents]] for the events types that can be emitted.
1136
+ *
1137
+ * ```typescript
1138
+ * // minimal configuration of a Vindral client instance
1139
+ * const instance = new Vindral({
1140
+ * url: "https://lb.cdn.vindral.com",
1141
+ * channelId: "vindral_demo1_ci_099ee1fa-80f3-455e-aa23-3d184e93e04f",
1142
+ * })
1143
+ *
1144
+ * // Will be called when timed metadata is received
1145
+ * instance.on("metadata", console.log)
1146
+ *
1147
+ * // Will be called when a user interaction is needed to activate audio
1148
+ * instance.on("needs user input", console.log)
1149
+ *
1150
+ * // Start connecting to the cdn
1151
+ * instance.connect()
1152
+ *
1153
+ * // Attach the video view to the DOM
1154
+ * instance.attach(document.getElementById("root"))
1155
+ *
1156
+ * // When done with the instance
1157
+ * instance.unload()
1158
+ * ```
1159
+ */
1114
1160
  export declare class Vindral extends Emitter<PublicVindralEvents> {
1115
1161
  #private;
1116
1162
  private static MAX_POOL_SIZE;
1117
- private static DISCONNECT_TIMEOUT;
1118
1163
  private static REMOVE_CUE_THRESHOLD;
1164
+ private static BACKGROUND_INACTIVITY_DISCONNECT_TIMEOUT;
1119
1165
  /**
1120
1166
  * Picture in picture
1121
1167
  */
@@ -1158,6 +1204,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1158
1204
  private offscreenCanvasElement?;
1159
1205
  private webCodecsRenditionSupport;
1160
1206
  private hasCalledConnect;
1207
+ private isUserPaused;
1161
1208
  private latestEmittedLanguages;
1162
1209
  private wakeLock;
1163
1210
  private pool;
@@ -1172,7 +1219,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1172
1219
  private readonly unextractableSamplesWarned;
1173
1220
  private sizes;
1174
1221
  private isSuspended;
1175
- private disconnectTimeout;
1222
+ private inactivityDisconnectInterval;
1176
1223
  private offscreenSubtitleInterval?;
1177
1224
  constructor(options: Options);
1178
1225
  /**
@@ -1535,8 +1582,14 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1535
1582
  */
1536
1583
  getStatistics: () => Statistics;
1537
1584
  private resetModules;
1585
+ private disconnectForInactivePage;
1586
+ private scheduleInactivityDisconnect;
1587
+ private clearInactivityDisconnect;
1588
+ private isHiddenWithBackgroundPlayback;
1589
+ private isHiddenWithBackgroundPlayDisabled;
1538
1590
  private suspend;
1539
1591
  private unsuspend;
1592
+ private resumeModules;
1540
1593
  private getRuntimeInfo;
1541
1594
  private getPlaybackBufferState;
1542
1595
  private onMediaElementBufferState;
@@ -1560,6 +1613,8 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1560
1613
  * is the optimal rendering path for WebCodecs (worker renders VideoFrames directly).
1561
1614
  */
1562
1615
  private shouldUseOffscreenCanvas;
1616
+ private isBackgroundPlayEnabled;
1617
+ private shouldAllowBackgroundPlayback;
1563
1618
  }
1564
1619
  interface TelemetryModuleStatistics {
1565
1620
  /**
@@ -1731,7 +1786,8 @@ export interface PublicVindralEvents {
1731
1786
  * Is emitted during connection whether the channel is live or not.
1732
1787
  *
1733
1788
  * If the channel is not live, the Vindral instance will try to reconnect until the `reconnectHandler`
1734
- * determines that no more retries should be made.
1789
+ * determines that no more retries should be made. Each attempt also emits a non-fatal `error` with
1790
+ * the code `channel_not_live`.
1735
1791
  *
1736
1792
  * Note: If the web-sdk is instantiated at the same time as you are starting the stream it is possible
1737
1793
  * that this emits false until the started state has propagated through the system.
@@ -1800,6 +1856,10 @@ export interface CastSenderEvents {
1800
1856
  * When the remote connection receives a server wallclock time event
1801
1857
  */
1802
1858
  "server wallclock time": number;
1859
+ /**
1860
+ * When receiver availability changes. True when at least one receiver is reachable.
1861
+ */
1862
+ "devices available": boolean;
1803
1863
  }
1804
1864
  /**
1805
1865
  * Used for initializing the CastSender
@@ -1826,6 +1886,9 @@ export declare class CastSender extends Emitter<CastSenderEvents> {
1826
1886
  private state;
1827
1887
  private config;
1828
1888
  private unloaded;
1889
+ private logger;
1890
+ /** Last reported availability, undefined until the Cast API tells us */
1891
+ private devicesAvailable;
1829
1892
  constructor(config: CastConfig);
1830
1893
  /**
1831
1894
  * True if the instance is casting right now
@@ -1885,6 +1948,9 @@ export declare class CastSender extends Emitter<CastSenderEvents> {
1885
1948
  private send;
1886
1949
  private onMessage;
1887
1950
  private onSessionStarted;
1951
+ private onCastStateChanged;
1952
+ /** Emits on change only, since connecting and connected are all "available" */
1953
+ private updateDevicesAvailable;
1888
1954
  private onSessionStateChanged;
1889
1955
  private getInstance;
1890
1956
  private getSession;