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();