UNPKG

@aidenlx/player

Version:

Headless web components that make integrating media on the a web a breeze.

148 lines 6.52 kB
import type Hls from 'hls.js'; import type { ErrorData, Events as HlsEvent, HlsConfig, LevelLoadedData } from 'hls.js'; import { type PropertyValues } from 'lit'; import { CanPlay, MediaType } from '../../media'; import { VideoElement } from '../video'; import type { DynamicHlsConstructorImport, HlsConstructor } from './types'; export declare const HLS_EXTENSIONS: RegExp; export declare const HLS_TYPES: Set<string>; /** * Embeds video content into documents via the native `<video>` element. It may contain * one or more video sources, represented using the `src` attribute or the `<source>` element: the * browser will choose the most suitable one. * * In addition, this element introduces support for HLS streaming via the popular `hls.js` library. * HLS streaming is either [supported natively](https://caniuse.com/?search=hls) (generally * on iOS), or in environments that [support the Media Stream API](https://caniuse.com/?search=mediastream). * * 💡 This element contains the exact same interface as the `<video>` element. It re-dispatches * all the native events if needed, but prefer the `vds-*` variants (eg: `vds-play`) as they * iron out any browser issues. It also dispatches all the `hls.js` events. * * 💡 This element re-dispatches all `hls.js` events so you can listen for them through the * native DOM interface (eg: `addEventListener('vds-hls-media-attaching', ...)`). * * @tagname vds-hls * @slot - Used to pass in `<source>` and `<track>` elements to the underlying HTML5 media player. * @csspart media - The video element (`<video>`). * @csspart video - Alias for `media` part. * @events ./events.ts * @example * ```html * <vds-hls src="/media/index.m3u8" poster="/media/poster.png"> * <!-- Additional media resources here. --> * </vds-hls> * ``` * @example * ```html * <vds-hls src="/media/index.m3u8" poster="/media/poster.png"> * <track default kind="subtitles" src="/media/subs/en.vtt" srclang="en" label="English" /> * </vds-hls> * ``` */ export declare class HlsElement extends VideoElement { protected _hlsEngine: Hls | undefined; protected _isHlsEngineAttached: boolean; constructor(); /** * The `hls.js` configuration object. * * @link https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning */ hlsConfig: Partial<HlsConfig | undefined>; /** * The `hls.js` constructor (supports dynamic imports) or a URL of where it can be found. * * @default DEV: 'https://cdn.jsdelivr.net/npm/hls.js@^1.0.0/dist/hls.js' * @default PROD: 'https://cdn.jsdelivr.net/npm/hls.js@^1.0.0/dist/hls.min.js' */ hlsLibrary: HlsConstructor | DynamicHlsConstructorImport | string | undefined; protected _Hls: HlsConstructor | undefined; /** * The `hls.js` constructor. */ get Hls(): typeof Hls | undefined; /** * The current `hls.js` instance. */ get hlsEngine(): Hls | undefined; /** * Whether the `hls.js` instance has mounted the `HtmlMediaElement`. * * @default false */ get isHlsEngineAttached(): boolean; get currentSrc(): string; connectedCallback(): void; protected update(changedProperties: PropertyValues): Promise<void>; disconnectedCallback(): void; handleMediaCanLoad(): Promise<void>; canPlayType(type: string): CanPlay; /** * Whether HLS streaming is supported in this environment. */ get isHlsSupported(): boolean; /** * Whether the current src is using HLS. * * @default false */ get isHlsStream(): boolean; /** * Whether the browser natively supports HLS, mostly only true in Safari. Only call this method * after the provider has connected to the DOM (wait for `MediaProviderConnectEvent`). */ get hasNativeHlsSupport(): boolean; /** * Whether native HLS support is available and whether it should be used. Generally defaults * to `false` as long as `window.MediaSource` is defined to enforce consistency by * using `hls.js` where ever possible. * * @default false */ get shouldUseNativeHlsSupport(): boolean; /** * Notifies the `VideoElement` whether the `src` attribute should be set on the rendered * `<video>` element. If we're using `hls.js` we don't want to override the `blob`. */ protected _shouldSetVideoSrcAttr(): boolean; /** * Attempts to preconnect to the `hls.js` remote source given via `hlsLibrary`. This is * assuming `hls.js` is not bundled and `hlsLibrary` is a URL string pointing to where it * can be found. */ protected _preconnectToHlsLibDownload(): void; protected _buildHlsEngine(forceRebuild?: boolean): Promise<void>; protected _destroyHlsEngine(): void; protected _prevHlsEngineSrc: string; protected _willAnotherEngineAttach(): boolean; protected _attachHlsEngine(): void; protected _detachHlsEngine(): void; protected _loadSrcOnHlsEngine(): void; protected _getMediaType(): MediaType; protected get _mediaReadyOnMetadataLoad(): boolean; protected _handleMediaSrcChange(): Promise<void>; protected _listenToHlsEngine(): void; protected _handleHlsError(eventType: string, data: ErrorData): void; protected _handleHlsNetworkError(): void; protected _handleHlsMediaError(): void; protected _handleHlsIrrecoverableError(): void; protected _handleHlsLevelLoaded(eventType: string, data: LevelLoadedData): void; protected _handleHlsMediaReady(eventType: string, data: LevelLoadedData): void; protected _hlsEventListeners: { listener: () => void; type: HlsEvent; options?: AddEventListenerOptions & { context: any; }; }[]; addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | (AddEventListenerOptions & { context: any; })): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | (AddEventListenerOptions & { context: any; })): void; removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } //# sourceMappingURL=HlsElement.d.ts.map