UNPKG

video-ad-sdk

Version:

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

109 lines (108 loc) 3.26 kB
import type { VastChain, VpaidCreativeAdUnit } from '../types'; import { VideoAdContainer } from '../adContainer'; import { VideoAdUnit, type VideoAdUnitOptions } from './VideoAdUnit'; declare const _private: unique symbol; /** * Options map to create a {@link VpaidAdUnit} */ export type VpaidAdUnitOptions = VideoAdUnitOptions; /** * This class provides everything necessary to run a Vpaid ad. */ export declare class VpaidAdUnit extends VideoAdUnit { private [_private]; /** Ad unit type. Will be `VPAID` for VpaidAdUnit */ type: string; /** Reference to the Vpaid Creative ad unit. Will be null before the ad unit starts. */ creativeAd?: VpaidCreativeAdUnit; /** * Creates a {@link VpaidAdUnit}. * * @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?: VpaidAdUnitOptions); /** * 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; /** * Skip 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(): Promise<void>; /** * Returns the duration of the ad Creative or 0 if there is no creative. * * Note: if the user has engaged with the ad, the duration becomes unknown and it will return 0; * * @returns the duration of the ad unit. */ duration(): number; /** * Returns the current time of the ad Creative or 0 if there is no creative. * * Note: if the user has engaged with the ad, the currentTime becomes unknown and it will return 0; * * @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} * * @throws if ad unit is not started. * @throws if ad unit is finished. * * @returns Promise that resolves once the unit was resized */ resize(width: number, height: number, viewmode: string): Promise<void>; } export {};