Class VpaidAdUnit

This class provides everything necessary to run a Vpaid ad.

Hierarchy

Constructors

Properties

creativeAd?: VpaidCreativeAdUnit

Reference to the Vpaid Creative ad unit. Will be null before the ad unit starts.

error?: AdUnitError

If an error occurs it will contain the reference to the error otherwise it will be bull

errorCode?: number

If an error occurs it will contain the Vast Error code of the error

type: string = 'VPAID'

Ad unit type. Will be VPAID for VpaidAdUnit

Methods

  • 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 number

    the current time of the ad unit.

  • 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 number

    the duration of the ad unit.

  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

    Parameters

    • eventName: string

      The name of the event.

    • Rest ...args: any[]

    Returns boolean

    Returns true if the event had listeners, false otherwise.

  • Gets the volume of the ad unit.

    Returns number

    the volume of the ad unit.

    Throws

    if ad unit is not started.

    Throws

    if ad unit is finished.

  • Register a callback function that will be called if there is an error while running the ad.

    Parameters

    • callback: Listener

      will be called on ad unit error passing the Error instance and an object with the adUnit and the VastChain.

    Returns void

    Throws

    if ad unit is finished.

  • Register a callback function that will be called whenever the ad finishes. No matter if it was finished because de ad ended, or cancelled or there was an error playing the ad.

    Parameters

    • callback: Listener

      will be called once the ad unit finished

    Returns void

    Throws

    if ad unit is finished.

  • Adds a one time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

    Parameters

    • eventName: string

      The name of the event.

    • listener: Listener

      Listener fn that handles the evt.

    Returns VpaidAdUnit

    The Emitter instance.

  • This method resizes the ad unit to fit the available space in the passed VideoAdContainer

    Parameters

    • width: number
    • height: number
    • viewmode: string

    Returns Promise<void>

    Promise that resolves once the unit was resized

    Throws

    if ad unit is not started.

    Throws

    if ad unit is finished.

  • Sets the volume of the ad unit.

    Parameters

    • volume: number

      must be a value between 0 and 1;

    Returns void

    Throws

    if ad unit is not started.

    Throws

    if ad unit is finished.

  • Starts the ad unit.

    Returns Promise<void>

    Throws

    if called twice.

    Throws

    if ad unit is finished.

Generated using TypeDoc