import { AudioRenditionListLike, AudioTrackListLike, ErrorLike, MediaResolution, MediaStreamType, VideoRenditionListLike, VideoTrackListLike } from "../../core/types.js"; import { DrmSystemsConfig } from "../../core/drm.js"; import { MediaError } from "../../core/media-error.js"; import { HTMLVideoElementHost } from "../video-host/video-host.js"; import { NativeHlsConfig } from "../native-hls/media.js"; import Hls$1, { HlsConfig } from "hls.js"; //#region src/dom/hls-js/media.d.ts type PreloadType = '' | 'none' | 'metadata' | 'auto'; type PlaybackType = (typeof PlaybackTypes)[keyof typeof PlaybackTypes]; type SourceType = (typeof ContentTypes)[keyof typeof ContentTypes]; type StreamType = MediaStreamType; declare const PlaybackTypes: { MSE: string; NATIVE: string; }; declare const ContentTypes: { M3U8: string; MP4: string; }; declare const StreamTypes: { readonly ON_DEMAND: 'on-demand'; readonly LIVE: 'live'; readonly UNKNOWN: 'unknown'; }; interface HlsMediaProps { src: string; source: HlsSource | null; preload: PreloadType; streamType: StreamType; } /** * Structured HLS source: which source to play, plus how to play it. * * Playback options are namespaced by engine. There are two paths here — hls.js * and the browser's own HLS support — and only one of them runs, so a source * describes both without either engine reading the other's options. * * `preferPlayback` and the engine options are all read when the engine is * constructed, so changing any of them recreates it. */ interface HlsSource { /** Manifest URL. Mirrors the host's `src` property. */ src?: string | undefined; /** MIME type of the source. Takes precedence over inference from `src`. */ type?: SourceType | undefined; /** * Preferred playback path: `'mse'` for hls.js, `'native'` for the browser's * own HLS support. Ignored when the preferred path cannot play the source. */ preferPlayback?: PlaybackType | undefined; /** * License servers for protected content, keyed by EME key system id. * * Engine neutral, because which engine plays is decided later: hls.js is * handed every system named here (with EME switched on), and native playback * negotiates the `com.apple.fps` entry itself. Name every system you hold a * license server for — which one is used is the browser's choice. */ drm?: DrmSystemsConfig | undefined; /** * Highest resolution adaptive bitrate selection may choose on its own. * * A ceiling on automatic selection, not a filter on what is available: * renditions above it stay in `videoRenditions` and can still be selected by * hand. Matching is by pixel area, so a `'720p'` cap admits any rendition at * or below 1280×720 worth of pixels. When every rendition sits above the cap, * the smallest one is used. * * Applied live — changing it never rebuilds the playback engine. Requires the * hls.js (MSE) engine; native HLS playback ignores it. * * For Mux sources this is distinct from `playback.maxResolution`, which asks * Mux to leave higher renditions out of the manifest altogether. */ maxAutoResolution?: MediaResolution | undefined; /** * Whether the element's rendered size caps automatic selection. Defaults to * `true`. * * A 400px-wide player has no use for a 4K rendition, so selection is held to * the smallest rendition that still covers the element, measured in device * pixels — a `2` device pixel ratio asks for twice what a CSS measurement * would. The cap follows the element as it resizes, and `minAutoResolution` * bounds how far down it can go. Set it to `false` for a player whose layout * size understates what it needs, such as one that goes fullscreen without a * resize. * * Which rendition covers the element is hls.js's own judgement, weighed on * the largest dimension rather than pixel area, so it can land elsewhere than * `maxAutoResolution` would for the same ladder. * * Applied live — changing it never rebuilds the playback engine. Requires the * hls.js (MSE) engine; native HLS playback ignores it. Setting hls.js's own * `capLevelToPlayerSize` through `source.engine.hlsJs` is a different thing: * it stops the loop *every* cap here is evaluated on, and takes a rebuild. */ capRenditionToPlayerSize?: boolean | undefined; /** * Lowest resolution `capRenditionToPlayerSize` may cap down to. Defaults to * `'720p'`. * * Not a quality floor. It bounds the size-derived cap and nothing else: when * bandwidth is poor, adaptive selection still drops below it, because the cap * is a ceiling and selection stays free underneath. Nor does it raise an * explicit `maxAutoResolution` — asking for at most `'360p'` alongside a * `'720p'` floor yields `'360p'`. * * The default exists because the low rungs of a ladder are there for poor * network conditions, and capping a small player to them looks worse than its * size suggests. Name a lower rung to weaken the floor, or `'270p'` to lift it * for any real ladder. * * Applied live — changing it never rebuilds the playback engine. Requires the * hls.js (MSE) engine; native HLS playback ignores it. */ minAutoResolution?: MediaResolution | undefined; /** * Playback options, keyed by the engine that reads them. Only one of the two * engines below ends up playing, and each reads only its own key. */ engine?: HlsEngineConfig | undefined; } /** The engines an HLS source can configure. */ interface HlsEngineConfig { /** * hls.js's own configuration, passed through untouched. A `drmSystems` of its * own replaces `source.drm` for hls.js — an escape hatch for licensing MSE * playback differently, or for the parts of hls.js's DRM configuration * `source.drm` does not cover. */ hlsJs?: Partial | undefined; /** * Options for the browser's own HLS playback, used whenever the native path * is the one taken. Its `drmSystems` replaces `source.drm` for that path in * the same way. */ nativeHls?: NativeHlsConfig | undefined; } declare const hlsMediaDefaultProps: HlsMediaProps; /** * @fires sourcechange - Fired when `source` changes, either directly or by resolving a new `src`. Read `source` for the new value. * @fires streamtypechange - Fired when the detected stream type changes. Read `streamType` for the new value. * @fires targetlivewindowchange - Fired when the target live window changes. Read `targetLiveWindow` for the new value. */ declare class HlsJsMedia extends HTMLVideoElementHost implements HlsMediaProps { #private; constructor(); attach(target: HTMLVideoElement): void; detach(): void; destroy(): void; /** * Underlying playback engine — the hls.js `Hls` instance when playing via * MSE, otherwise `null`. An advanced escape hatch for direct engine access; * normal playback is driven through this element's own properties and methods. */ get engine(): Hls$1 | null; get error(): (ErrorLike & MediaError) | null; /** Populated only while the hls.js (MSE) engine is active; otherwise `undefined`. */ get videoTracks(): VideoTrackListLike | undefined; /** Populated only while the hls.js (MSE) engine is active; otherwise `undefined`. */ get audioTracks(): AudioTrackListLike | undefined; /** Selectable quality levels, populated only while the hls.js (MSE) engine is active; otherwise `undefined`. */ get videoRenditions(): VideoRenditionListLike | undefined; /** Selectable audio variants, populated only while the hls.js (MSE) engine is active; otherwise `undefined`. */ get audioRenditions(): AudioRenditionListLike | undefined; /** * Media source URL. Assigning it replaces the identity half of `source` and * leaves `type` and the engine options intact, so changing the URL never * disturbs engine configuration. */ get src(): string; set src(src: string); /** * Structured source: what to play (`src`, an optional `type`) plus how to play * it (`preferPlayback`, `engine`). Assigning it derives `src`. * * Sources are compared structurally, so reassigning an equivalent object — an * inline React prop, for instance — is a no-op. Only a change to the engine * options (or to the resolved content type) recreates the playback engine. */ get source(): HlsSource | null; set source(value: HlsSource | null); /** Preload type (`'none'` / `'metadata'` / `'auto'`). */ get preload(): PreloadType; set preload(value: PreloadType); /** Current stream type (`'on-demand'` / `'live'` / `'unknown'`). */ get streamType(): StreamType; set streamType(value: StreamType); /** * Presentation time marking the start of the Live Edge Window. * * Derived from the delegate on every read; `NaN` when no delegate is * attached or the stream is not live. */ get liveEdgeStart(): number; /** * Seekable range size for live content. `0` for standard live, `Infinity` * for DVR, `NaN` for on-demand or unknown. Fires `targetlivewindowchange` * when the value changes (bridged from the delegate). */ get targetLiveWindow(): number; load(): Promise; } //#endregion export { ContentTypes, Hls$1 as Hls, HlsEngineConfig, HlsJsMedia, HlsMediaProps, HlsSource, PlaybackType, PlaybackTypes, PreloadType, SourceType, StreamType, StreamTypes, hlsMediaDefaultProps }; //# sourceMappingURL=media.d.ts.map