FreeWheelController

The FreeWheelController is responsible for managing the lifecycle of a Freewheel Ad sequence and fitting it within the context of the Brightcove Android SDK, by hooking into the BC Event system. It instantiates and controls a default instance of FreeWheel's AdManager, AdContext, each populated with default values. In addition, the FreeWheelController manages an instance of AdCuePointComponent (responsible for generating CuePoints from the AdContext and executing ad playback)

When we mention 'default values', we refer the developer to the FreeWheel documentation for their various classes. As described below, one of the design goals for this class is to provide a developer with access to the FreeWheel components. One can supply their own AdManager instance, or set the values on an AdContext before an AdRequest is made.

Lifecycle

The general usage of the FWC goes thusly:
  • An AdManager is instantiated or created outside of this class and passed to it via setAdManager()
  • An AdContext is generated from the AdManager
  • The FreeWheelController emits an event containing the current AdContext and an AdRequestConfiguration before the ads are requested, allowing end users to edit the current context
  • An ad request is submitted to the FreeWheel servers
  • Once received, CuePoints are created, when relevant, for each ad

The FreeWheelController listens for several key events in the video playback lifecycle of the Brightcove Android sdk. End developers that wish to edit the AdContext before it is emitted should listen for the FreeWheelEventType.WILL_SUBMIT_AD_REQUEST event, and access the current context (or set it) via the AD_CONTEXT_KEY.

Implementation Details &Requirements

A few important details to note when using the FreeWheelController:

  • When laying out the SurfaceView / BrightcoveVideoView, note that the Surface must be contained within a FrameLayout. This is a requirement of Freewheel in the way that they take control of the SurfaceView during Ad Rendering

Sample Setup

 freeWheelController = new FreeWheelController(this, bcVideoView, eventEmitter);
 //configure your own IAdManager or supply connection information
 freeWheelController.setAdURL("http://demo.v.fwmrm.net/");
 freeWheelController.setAdNetworkId(90750);
 freeWheelController.setProfile("fw_tutorial_android");
 freeWheelController.setSiteSectionId("fw_tutorial_android");
 freeWheelController.enable();
 

See also

IAdContext
IAdManager
com.brightcove.player.display.VideoDisplayComponent

Constructors

Link copied to clipboard
constructor(activity: Activity, frameLayout: FrameLayout, emitter: EventEmitter)
constructor(activity: Activity, frameLayout: FrameLayout, emitter: EventEmitter, manager: IAdManager)
constructor(activity: Activity, surfaceView: SurfaceView, emitter: EventEmitter)
constructor(activity: Activity, surfaceView: SurfaceView, emitter: EventEmitter, manager: IAdManager)

Properties

Link copied to clipboard
val AD_CONTEXT_KEY: String = "adContextKey"
Key used for storing the current IAdContext in an Event
Link copied to clipboard
val AD_REQUEST_CONFIGURATION_KEY: String = "adRequestConfigurationKey"
Key used for storing the current AdRequestConfiguration in an Event
Link copied to clipboard
val AD_SLOTS_KEY: String = "adSlotsKey"
Key used for storing a List of ISlot instances for use by developers, e.g.
Link copied to clipboard
Link copied to clipboard
open var adManager: IAdManager
Link copied to clipboard
open val currentVideo: Video

Functions

Link copied to clipboard
open fun disable()
Disables the plugin; prevents further event listening.
Link copied to clipboard
open fun enable()
Enables the FreeWheel plugin.
Link copied to clipboard
open fun getCurrentContext(): IAdContext
Link copied to clipboard
open fun isActive(): Boolean
In order to listen in on the event system, the Controller needs to be enabled, after various settings (AdURL, AdManagerURL, NetworkId, ProfileId, SiteSectionId) have been set.
Link copied to clipboard
Returns whether ad requesting is enabled.
Link copied to clipboard
open fun setAdManagerURL(url: String)
Link copied to clipboard
open fun setAdNetworkId(id: Int)
Link copied to clipboard
Sets the flag which controls whether ads are requested for new videos.
Link copied to clipboard
open fun setAdURL(url: String)
Link copied to clipboard
open fun setProfile(profile: String)
Link copied to clipboard
open fun setSiteSectionId(sectionId: String)
Link copied to clipboard
open fun setSubmissionTimeout(timeout: Double)
Link copied to clipboard
open fun setupContext()
Creates a new AdContext, which can be used to enable ad playback when replaying a video.