import { Ad, AdPod, OmapBinderEvent } from '@ygoto3/omap-core'; import type { IOmapClient, IOmapBinder, TOmapBinderState, AdBreak, AdMediaFile, BinderConfig } from '@ygoto3/omap-core'; import type dashjs from 'dashjs'; /** * Dash.js binder for OMAP clients. * ```ts * const player = dashjs.MediaPlayer().create(); * const adDisplayContainer = document.getElementById('ad-display-container') as HTMLDivElement; * const adVideoElement = document.getElementById('ad-video') as HTMLVideoElement; * const adTagUrl = 'https://example.com/vmap.xml'; * const omapClient = new OmapIABClient(adTagUrl); * const omapBinder = new OmapDashjsBinder(player, adDisplayContainer); * omapBinder.bind(omapClient); * omapBinder.play() * .then(() => { * player.initialize(videoElement, 'https://example.com/manifest.mpd', true); * }) * .catch(() => { * console.error('adBinder failed to get ready'); * }); * ``` */ export default class OmapDashjsBinder implements IOmapBinder { /** * @param player the dash.js player instance * @param adDisplayContainer the HTMLElement to contain ad video and UI * @param adVideoElement the HTMLVideoElement to playback ad video */ constructor(player: dashjs.MediaPlayerClass, adDisplayContainer: HTMLElement, adVideoElement?: HTMLVideoElement); get state(): TOmapBinderState; destroy(): void; bind(omapClient: IOmapClient): void; play(startTime?: number): Promise; skip(): void; updateConfig(config: Partial): void; on(type: typeof OmapBinderEvent.AD_POD_STARTED, listener: () => void): void; on(type: typeof OmapBinderEvent.AD_POD_ENDED, listener: () => void): void; on(type: typeof OmapBinderEvent.AD_STARTED, listener: (ad: Ad) => void): void; on(type: typeof OmapBinderEvent.AD_ENDED, listener: (ad: Ad) => void): void; on(type: typeof OmapBinderEvent.AD_INFO_UPDATED, listener: (sequence: number, numOfAds: number, remainingTime: number, duration: number) => void): void; on(type: typeof OmapBinderEvent.AD_SKIPPABLE_STATE_CHANGED, listener: (skippable: boolean) => void): void; off(type: typeof OmapBinderEvent.AD_POD_STARTED, listener: () => void): void; off(type: typeof OmapBinderEvent.AD_POD_ENDED, listener: () => void): void; off(type: typeof OmapBinderEvent.AD_STARTED, listener: (ad: Ad) => void): void; off(type: typeof OmapBinderEvent.AD_ENDED, listener: (ad: Ad) => void): void; off(type: typeof OmapBinderEvent.AD_INFO_UPDATED, listener: (sequence: number, numOfAds: number, remainingTime: number, duration: number) => void): void; off(type: typeof OmapBinderEvent.AD_SKIPPABLE_STATE_CHANGED, listener: () => void): void; protected dashjs: dashjs.MediaPlayerClass; protected omapClient?: IOmapClient; protected adDisplayContainer: HTMLElement; protected adVideoElement?: HTMLVideoElement; protected adBreaks: AdBreak[]; protected config: Partial; protected emit(type: typeof OmapBinderEvent.AD_POD_STARTED): void; protected emit(type: typeof OmapBinderEvent.AD_POD_ENDED): void; protected emit(type: typeof OmapBinderEvent.AD_STARTED, ad: Ad): void; protected emit(type: typeof OmapBinderEvent.AD_ENDED, ad: Ad): void; protected emit(type: typeof OmapBinderEvent.AD_INFO_UPDATED, sequence: number, numOfAds: number, remainingTime: number, duration: number): void; protected emit(type: typeof OmapBinderEvent.AD_SKIPPABLE_STATE_CHANGED): void; protected onTimeUpdate(e: dashjs.PlaybackTimeUpdatedEvent): void; protected onContentCanPlay(): void; protected _onAllAdsCompleted(): void; protected onContentPauseRequested(): void; protected onContentResumeRequested(): void; protected onAdPodStarted(adPod: AdPod, adDisplayContainer: HTMLElement): void; protected onAdPodEnded(adPod: AdPod, adDisplayContainer: HTMLElement): void; protected onAdStarted(ad: Ad, adDisplayContainer: HTMLElement): void; protected onAdEnded(ad: Ad, adDisplayContainer: HTMLElement): void; protected onAdProgress(ad: Ad, adDisplayContainer: HTMLElement, adCurrentTime: number, numOfAds: number): void; protected onAdSkippable(ad: Ad, adDisplayContainer: HTMLElement, adCurrentTime: number, numOfAds: number): void; private _playReady; private _playReadyResolve?; private _adManifestReady; private _adManifestReadyResolve?; private _adManifestReadyReject?; private _eventListeners; private _currentAdPod?; private _keepsAdVideoElement; private _state; private _lastAdInfo; private _prefetchable; private _onAdPreparationRequested; private _onAdInsertionRequested; private _onContentCanPlay; private _onOmapClientLoaded; private _onOmapClientLoadError; private _onOmapClientStarted; private _onOmapClientComplete; private _onPlaybackStarted; private _unbind; private _prefetchNextAd; private _playNextAd; private _endAdPod; private _destroyAdVideoElement; private _resetMediaElement; private _adVideoEventAbortController?; private _adVideoEventArguments; } export declare function selectAdMediaFile(adMediaFiles: AdMediaFile[], targetHeight: number, config?: Partial): AdMediaFile;