Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Adease

The adease class essentially provides a wrapper around a configuration object. The configuration object contains all of the information regarding where in a stream the ads have been inserted.

This class has methods both to query what ads have been inserted where, as well as triggering analytics based on time updates and user initiated actions.

Internal state is kept to track what beacons have been sent, and what the last time update was. Whenever configuration is provided this internal state is reset. If this internal state needs to be preserved, then a new instance should be created instead.

NOTE: All methods except configureFromURL and configureFromObject will throw an exception if the class has not been provided configuration. Your code should ensure that the class has been setup before calling any methods; a proxy pattern can work well here. This design choice has been made to avoid silently failing, to increase development/debugging speed.

Hierarchy

  • Adease

Index

Constructors

constructor

  • Parameters

    • Optional serverURL: undefined | string
    • Optional liveQueryParams: TQueryParams

    Returns Adease

Methods

configureFromObject

  • configureFromObject(object: any): void
  • Configures the class from an object.

    Parameters

    • object: any

    Returns void

    Promise

configureFromURL

  • configureFromURL(url: string): Promise<undefined>
  • Downloads adease configuration from a URL, returning a promise that resolves with undefined when done.

    Parameters

    • url: string

      string

    Returns Promise<undefined>

    Promise

getAds

  • getAds(): IAd[]
  • Returns the ads.

    Returns IAd[]

getAdsAtTime

  • getAdsAtTime(timeMs: number): IAd[]
  • Returns the ads that are present at a given moment. In practice this will only ever return either an empty list, or a list with one element. It is theoretically possible for more than one ad to be returned, however this makes no practical sense.

    Parameters

    • timeMs: number

      Time in milliseconds.

    Returns IAd[]

getAssetTime

  • getAssetTime(streamTimeMs: number): number
  • This is the inverse of getStreamTime. It returns the time in an asset that the loaded stream time corresponds to. For example, if the time 35 seconds is given, then 5 seconds will be returned if a 30 second pre roll has been inserted.

    Parameters

    • streamTimeMs: number

      number Time in milliseconds.

    Returns number

    number Time in milliseconds.

getStreamTime

  • getStreamTime(assetTimeMs: number): number
  • Since inserting ads into a stream changes the duration, it can be useful to translate between the original time of the asset and the corresponding time in the loaded stream. This method returns the time in the stream that a position in the original asset corresponds to.

    For example, 5 seconds into the original asset would be 35 seconds in the loaded stream if a 30 second pre roll has been inserted.

    Parameters

    • assetTimeMs: number

      Returns the real stream time.

    Returns number

getStreams

  • Returns IStream[]

notifyID3Event

  • notifyID3Event(tag: string, timeMs: number): Promise<void>
  • For live only.

    Call when an ID3 tag is detected in the metadata track.

    Parameters

    • tag: string

      The string tag of the event;

    • timeMs: number

      The time in milliseconds that the event appears in the stream.

    Returns Promise<void>

    A promise that resolves once all undelying actions have completed.

notifyTimeUpdate

  • notifyTimeUpdate(timeMs: number): Promise<undefined>
  • Notify that a time update (position in the stream) has occured. This may fire off beacons. Returns a promise that resolves once all underlying network requests have completed.

    Parameters

    • timeMs: number

      number Time in milliseconds.

    Returns Promise<undefined>

Generated using TypeDoc