Skip to content
Anirudh Ramanan edited this page Jan 22, 2020 · 1 revision

This is the entry point of the library where the client (plugin in our case) can use the builder pattern to create the instance of madman and request ads.

Components:

  • NetworkLayer

  • XmlParser

  • AdErrorListener: It is an interface for sending error events to the client. It has AdError object as the parameter which contains the AdErrorType and the error message.

  • AdLoadListener: It gets triggered after AdManager is initialised. The client then uses AdManager instance to interact with the library.

  • AdEventListener: It is an interface for sending ad events to the client. It has AdEvent object as the parameter which contains the AdEventType and the AdElement. The AdElement represents the ad which is being played or about to be played and contains information such as ad-id, if ad is skippable or not, pod information etc

  • AdRenderer: Handles the ui rendering logic for ads.

    • Houses the player interface which is implemented by the client to interact with the exo player.
    • Provides view to attach the ad
    • Provides rendering settings such as preload enabled or not, show skip etc
  • Logger: A logger interface to log messages. Default implementation logs at the debug level.

  • Handler: The main thread handler.

Note:

  1. The library provides default implementation for all the above components.
  2. If any of the listeners are not set, the library throws an IllegalStateException.

API's:

  • requestAds(request: StringAdRequest): Use this if you already have a vmap/vast string response.

  • requestAds(request: NetworkAdRequest): Use this if the vmap/vast has to be fetched from the given url over the network.

Flow:

  • The client uses the MadmanBuilder to create the madman instance by registering all the required listeners (such as error listener, event listener and load listener) and other components.

  • The created madman instance is then used to call requestAds with the request object. This internally then talks to the AdLoader to request the ad.

  • Once the ad is fetched (from the network or local) and parsed, AdManager is initialised and the client is notified via adLoadEvent.

  • The AdLoadListener has AdManager as a parameter, and the client uses the manager to perform interactions on the ad (eg stop, pause, resume etc)

  • If any of the above step fails (for eg network error, parsing error), the client is notified with the actual error type and message via the ad error event.

Clone this wiki locally