interface Channel { /** * Channel ID for the channel */ channelId: string; /** * Display name */ name: string; /** * Indicates whether there is an incoming source feed for the channel */ isLive: boolean; /** * URLs to fetch thumbnail from */ thumbnailUrls: string[]; /** * Urls for timeshift if available */ timeshiftUrls?: string[]; } interface MinMaxAverage { last: number; /** * Average value over a given interval. */ average: number; /** * Maximum value over a given interval. */ max: number; /** * Minimum value over a given interval. */ min: number; } type MatchingKeys = K extends (TRecord[K] extends TMatch ? K : never) ? K : never; type VoidKeys = MatchingKeys; type EventListenerReturnType = (() => void) | void; declare class Emitter = VoidKeys, ArgEvents extends Exclude = Exclude, ArgLessEmits extends VoidKeys = VoidKeys, ArgEmits extends Exclude = Exclude> { private listeners; emit(eventName: T): void; emit(eventName: T, args: TEmits[T]): void; /** * Remove an event listener from `eventName` */ off(eventName: T, fn: () => EventListenerReturnType): void; off(eventName: T, fn: (args: TEvents[T]) => EventListenerReturnType): void; /** * Add an event listener to `eventName` * * Event listeners may optionally return a "defer function" that will be called once all other listeners have been called. * This is useful when one listener may want everone to have reacted to an event before calling something. */ on(eventName: T, fn: () => void): void; on(eventName: T, fn: (args: TEvents[T]) => void): void; /** * Add an event listener to `eventName` that will be called once only * * Event listeners may optionally return a "defer function" that will be called once all other listeners have been called. * This is useful when one listener may want everone to have reacted to an event before calling something. */ once(eventName: T, fn: () => void): void; once(eventName: T, fn: (args: TEvents[T]) => void): void; /** * Check whether there are any listeners registered for the given event. */ hasListeners(eventName: T): boolean; /** * Reset the event emitter */ reset(): void; private add; } declare const LogLevels: readonly [ "off", "error", "warn", "info", "debug", "trace" ]; type LogLevel = (typeof LogLevels)[number]; declare const LogLevel: { ERROR: "error"; WARN: "warn"; INFO: "info"; DEBUG: "debug"; TRACE: "trace"; OFF: "off"; }; declare const tags: unique symbol; type Tagged = BaseType & { [tags]: { [K in Tag]: void; }; }; declare class UserAgentInformation { private highEntropyValues?; constructor(); getUserAgentInformation(): { locationOrigin: string; locationPath: string; ancestorOrigins: string[] | undefined; hardwareConcurrency: number; deviceMemory: number | undefined; userAgentLegacy: string; ua: { browser: { brands: string[]; fullVersionBrands: string[]; majorVersions: string[]; }; device: string; os: { family: string; version: string; major_version: number; }; }; } | { locationOrigin: string; locationPath: string; ancestorOrigins: string[] | undefined; hardwareConcurrency: number; deviceMemory: number | undefined; userAgent: string; }; } export type AudioCodec = "aac" | "opus" | "mp3"; export type VideoCodec = "h264" | "av1"; /** * The current reconnect state to use to decide whether to kep reconnecting or not */ export interface ReconnectState { /** * The number or retry attempts so far. * This gets reset on every successful connect, so it will start from zero every * time the client instance gets disconnected and will increment until the * client instance makes a connection attempt is successful. */ reconnectRetries: number; } /** * Represents a size with a width and height. */ export interface Size { /** */ width: number; /** */ height: number; } /** * Advanced options to override default behaviour. */ export interface AdvancedOptions { } /** * DRM options to provide to the Vindral instance */ export interface DrmOptions { /** * Headers to be added to requests to license servers */ headers?: Record; /** * Query parameters to be added to requests to license servers */ queryParams?: Record; /** * Widevine options to override default behaviour */ widevine?: { videoRobustness?: string[]; audioRobustness?: string[]; }; /** * Playready options to override default behaviour */ playready?: { videoRobustness?: string[]; audioRobustness?: string[]; }; } /** * Type of media. */ export type Media = "audio" | "video" | "audio+video"; type WebCodecsHardwareAccelerationPreference = "no-preference" | "prefer-hardware" | "prefer-software"; type DecoderType = "mse" | "webcodecs" | "wasm"; /** * Options for the Vindral instance * */ export interface Options { /** * URL to use when connecting to the stream */ url: string; /** * Channel ID to connect to initially - can be changed later mid-stream when connected to a channel group. */ channelId: string; /** * Channel group to connect to * Note: Only needed for fast channel switching */ channelGroupId?: string; /** * A container to attach the video view in - can be provided later with .attach() on the vindral core instance */ container?: HTMLElement; /** * An authentication token to provide to the server when connecting - only needed for channels with authentication enabled * Note: If not supplied when needed, an "Authentication Failed" error will be raised. */ authenticationToken?: string; /** * Language to use initially - can be changed during during runtime on the vindral instance * Note: Only needed when multiple languages are provided - if no language is specified, one will be automatically selected. */ language?: string; /** * TextTrack to use initially - can be changed during during runtime on the vindral instance */ textTrack?: string; /** * Sets the log level - defaults to info */ logLevel?: LogLevel; /** * Sets the minimum and initial buffer time */ minBufferTime?: number; /** * Sets the maximum buffer time allowed. The vindral instance will automatically slowly increase * the buffer time if the use experiences to much buffering with the initial buffer time. */ maxBufferTime?: number; /** * Enables or disables user bandwidth savings by capping the video resolution to the size of the video element. * * Is enabled by default. * * Note: This is automatically set to false when abrEnabled is set to false. */ sizeBasedResolutionCapEnabled?: boolean; /** * Enables or disables picture in picture support. */ pictureInPictureEnabled?: boolean; /** * Enable bursting for initial connection and channel switches. This makes time to first frame faster at the * cost of stability (more demanding due to the sudden burst of live content) * * Is disabled by default. * */ burstEnabled?: boolean; /** * @deprecated Use `decoders` instead. * Setting `mseEnabled: false` is equivalent to `decoders: ["wasm"]`. * When both `mseEnabled` and `decoders` are provided, `decoders` takes precedence. */ mseEnabled?: boolean; /** * Enable Opus with the MediaSource API on supported browsers. * * Is enabled by default. * */ mseOpusEnabled?: boolean; /** * Enable or disable support for playing audio in the background for iOS devices. * * Is false (disabled) by default. * * Note: This may be enabled by default in a future (major) release */ iosBackgroundPlayEnabled?: boolean; /** * Enable or disable Adaptive Bit Rate. This allows for automatically adapting the incoming bit rate based on * the viewers bandwidth and thus avoiding buffering events. This also disables the * sizeBasedResolutionCapEnabled option. * * Is enabled by default. * * Note: It is strongly recommended to keep this enabled as user experience can greatly suffer without ABR. */ abrEnabled?: boolean; /** * Enable or disable telemetry. This allows for telemetry and errors being collected. * * Is enabled by default. * * We appreciate you turning it off during development/staging to not bloat real telemetry data. * * Note: It is strongly recommended to keep this enabled in production as it is required for insights and KPIs. */ telemetryEnabled?: boolean; /** * Set a cap on the maximum video size. * This can be used to provide user options to limit the video bandwidth usage. * * Note: This takes presedence over any size based resolution caps. */ maxSize?: Size; /** * Maximum audio bit rate allowed. * This can be used to provide user options to limit the audio bandwidth usage. */ maxAudioBitRate?: number; /** * Maximum video bit rate allowed. * This can be used to provide user options to limit the video bandwidth usage. */ maxVideoBitRate?: number; /** * Initial maximum bit rate cap applied when first connecting to a channel. * This helps prevent buffering on initial connection by starting at a conservative bitrate. * The client will adapt to higher bitrates as bandwidth allows if ABR is enabled. * * Default is 2.5 Mbps (2500000 bits per second). */ maxInitialBitRate?: number; /** * Controls video element background behaviour while loading. * - If `false`, a black background will be shown. * - If undefined or `true`, a live thumbnail will be shown. * - If set to a string containing a URL (https://urltoimage), use that. * Default `true` - meaning a live thumbnail is shown */ poster?: boolean | string; /** * Whether to start the player muted or to try to start playing audio automatically. */ muted?: boolean; /** * Initial volume level for the player. A floating point value between 0-1. * Default is 1 (100% volume). * * Note: Volume cannot be set on iOS devices due to system restrictions. * The volume property is not settable in JavaScript on iOS, and reading it always returns 1. */ volume?: number; /** * Provide a custom reconnect handler to control when the instance should stop trying to * reconnect. The reconnect handler should either return true to allow the reconnect or * false to stop reconnecting. It can also return a promise with true or false if it needs * to make any async calls before determining wether to reconnect. * * The default reconnect handler allows 30 reconnects before stopping. * * Note: the ReconnectState gets reset every time the client instance makes a successful connection. * This means the default reconnect handler will only stop reconnecting after 30 _consecutive_ failed connections. * * ```typescript * // An example reconnect handler that will reconnect forever * const reconnectHandler = (state: ReconnectState) => true * * // An example reconnect handler that will fetch an url and determine whether to reconnect * const reconnectHandler = async (state: ReconnectState) => { * const result = await fetch("https://should-i-reconnect-now.com") * return result.ok * }, * ``` */ reconnectHandler?: (state: ReconnectState) => Promise | boolean; tags?: string[]; ownerSessionId?: string; edgeUrl?: string; logShippingEnabled?: boolean; statsShippingEnabled?: boolean; webtransportEnabled?: boolean; /** * Enable wake lock for iOS devices. * The wake lock requires that the audio has been activated at least once for the instance, othwerwise it will not work. * Other devices already provide wake lock by default. * * This option is redundant and has no effect if streamToMediaElementEnabled is enabled since that automatically enables wake lock. * * Disabled by default. */ iosWakeLockEnabled?: boolean; /** * Disabling this will revert to legacy behaviour where Vindral will try to always keep the video element playing. */ pauseSupportEnabled?: boolean; /** * Stream canvas-rendered video/audio to a media element via captureStream. * * This enables platform media features such as fullscreen and picture-in-picture * for non-MSE playback by routing the canvas output through a `