UNPKG

video-ad-sdk

Version:

VAST/VPAID SDK that allows video ads to be played on top of any player

110 lines (109 loc) 3.12 kB
import type { VastChain, Hooks } from '../types'; import { VideoAdContainer } from '../adContainer'; import { VideoAdUnit, type VideoAdUnitOptions } from './VideoAdUnit'; declare const _private: unique symbol; /** * Options map to create a {@link VastAdUnit} */ export interface VastAdUnitOptions extends VideoAdUnitOptions { /** * Optional map with hooks to configure the behaviour of the ad. */ hooks?: Hooks; } /** * This class provides everything necessary to run a Vast ad. */ export declare class VastAdUnit extends VideoAdUnit { private [_private]; assetUri?: string; /** Ad unit type. Will be `VAST` for VastAdUnit */ type: string; private hooks; /** * Creates a {@link VastAdUnit}. * * @param vastChain The {@link VastChain} with all the {@link VastResponse} * @param videoAdContainer - container instance to place the ad * @param options Options Map */ constructor(vastChain: VastChain, videoAdContainer: VideoAdContainer, options?: VastAdUnitOptions); /** * Starts the ad unit. * * @throws if called twice. * @throws if ad unit is finished. */ start(): Promise<void>; /** * Resumes a previously paused ad unit. * * @throws if ad unit is not started. * @throws if ad unit is finished. */ resume(): void; /** * Pauses the ad unit. * * @throws if ad unit is not started. * @throws if ad unit is finished. */ pause(): void; /** * Skips the ad unit. * * @throws if ad unit is not started. * @throws if ad unit is finished. */ skip(): void; /** * Returns true if the ad is paused and false otherwise */ paused(): boolean; /** * Sets the volume of the ad unit. * * @throws if ad unit is not started. * @throws if ad unit is finished. * * @param volume must be a value between 0 and 1; */ setVolume(volume: number): void; /** * Gets the volume of the ad unit. * * @throws if ad unit is not started. * @throws if ad unit is finished. * * @returns the volume of the ad unit. */ getVolume(): number; /** * Cancels the ad unit. * * @throws if ad unit is finished. */ cancel(): void; /** * Returns the duration of the ad Creative or 0 if there is no creative. * * @returns the duration of the ad unit. */ duration(): number; /** * Returns the current time of the ad Creative or 0 if there is no creative. * * @returns the current time of the ad unit. */ currentTime(): number; /** * This method resizes the ad unit to fit the available space in the passed {@link VideoAdContainer} * * @param width the new width of the ad container. * @param height the new height of the ad container. * @param viewmode fullscreen | normal | thumbnail * @returns Promise that resolves once the unit was resized */ resize(width: number, height: number, viewmode: string): Promise<void>; } export {};