THEOplayer Web SDK
    Preparing search index...

    Interface LinearAdPlayerExperimental

    The built-in linear ad player shared by client-side ad integrations for one player.

    It can be used during or outside a linear ad break. Its playback state is reported through the player's API only when it is used directly, or through a forwarding wrapper, as the break's StartLinearAdBreakOptions.playback.

    interface LinearAdPlayer {
        currentTime: number;
        duration: number;
        element: HTMLElement;
        ended: boolean;
        error: THEOplayerError | undefined;
        muted: boolean;
        paused: boolean;
        readyState: number;
        usesContentVideoElement?: boolean;
        videoHeight: number;
        videoWidth: number;
        volume: number;
        addEventListener<TType extends keyof ReadonlyLinearAdPlayerEventMap>(
            type: TType | readonly TType[],
            listener: EventListener<ReadonlyLinearAdPlayerEventMap[TType]>,
        ): void;
        load(source: string | TypedSource, ad?: Ad): Promise<void>;
        pause(): void;
        play(): void;
        preload(source: string | TypedSource): Promise<void>;
        removeEventListener<TType extends keyof ReadonlyLinearAdPlayerEventMap>(
            type: TType | readonly TType[],
            listener: EventListener<ReadonlyLinearAdPlayerEventMap[TType]>,
        ): void;
        stop(): void;
    }

    Hierarchy (View Summary)

    Index
    currentTime: number

    The current linear-ad playback position, in seconds.

    duration: number

    The duration of the loaded linear-ad source, in seconds.

    element: HTMLElement

    The shared DOM element used to play linear ads.

    This element is a sibling of ClientSideAdIntegrationController.contentElement. During a linear ad break that does not use LinearAdPlayback.usesContentVideoElement, it replaces the hidden content element in the normal flow, or is shown over the content when StartLinearAdBreakOptions.keepContentPlaying is set.

    The integration may style this element freely during a break, for example to show the ad next to the content.

    • The integration must not add, remove or replace child elements.
    • The player restores the element's styles when the break ends, when a new source is set during an active break, or when the player is destroyed.
    • This element is not used by a playback that sets LinearAdPlayback.usesContentVideoElement.
    ended: boolean

    Whether the loaded linear-ad source has ended.

    error: THEOplayerError | undefined

    The current linear-ad playback error, or undefined if there is no error.

    muted: boolean

    Whether the linear ad is muted.

    paused: boolean

    Whether the linear ad player is paused.

    readyState: number

    The ready state of the linear ad, using the same values as ChromelessPlayer.readyState.

    usesContentVideoElement?: boolean

    Whether this playback really renders the linear ad in ClientSideAdIntegrationController.contentVideoElement instead of ClientSideAdIntegrationController.adContainer.

    Set this to true only when this playback plays the ad in the content video element, so the player can hand over the element before the ad starts and restore the content afterwards. The player reads this property once, when ClientSideAdIntegrationController.startLinearAdBreak is called.

    false

    videoHeight: number

    The height of the linear-ad video, or 0 if unknown.

    videoWidth: number

    The width of the linear-ad video, or 0 if unknown.

    volume: number

    The linear-ad volume, between 0 and 1.

    • Experimental

      Preload a linear ad source through the built-in player.

      The built-in player starts loading the source in the background, while the content keeps playing. A later call to load with exactly the same source starts faster.

      Parameters

      • source: string | TypedSource

        The media to preload, e.g. an MP4 or HLS file.

      Returns Promise<void>

      A promise that resolves when enough of the source is loaded to start playback, or rejects if the source could not be preloaded. In the latter case, no aderror event is fired.

      • This works during or outside a linear ad break.
      • Only one source is preloaded at a time. Preloading a different source discards the previous preload.
      • The built-in player has a single video element, so preloading is not possible while it is playing a linear ad. The returned promise then rejects.
      • The preload is discarded when a different source is played, when the preloaded source has been played, or when a new source is set on the player.
      • Preloading is best effort. If it fails, load still loads the source normally.
    • Experimental

      Stop the source currently playing through the built-in player.

      The built-in player stops and unloads the source started with load, and the promise returned by that call resolves. A linear ad break stays active, so the integration can load another source or end the break.

      Use this to skip an ad in ClientSideAdIntegrationHandler.skipAd, or to exit an ad early.

      Returns void

      • This works during or outside a linear ad break.
      • If ad was given to load, the player ends that ad. Otherwise, the integration must end the ads it reported itself.
      • This has no effect if no source is currently playing through the built-in player.