Package 

Class FreeWheelController

  • All Implemented Interfaces:
    com.brightcove.player.event.Component

    @Emits(events = {EventType.DID_SET_SOURCE, EventType.PLAY, EventType.REGISTER_PLUGIN, FreeWheelEventType.DID_LOAD_AD_MANAGER, FreeWheelEventType.DID_SUBMIT_AD_REQUEST, FreeWheelEventType.LOCK, FreeWheelEventType.SHOW_DISPLAY_ADS, FreeWheelEventType.UNLOCK, FreeWheelEventType.WILL_SUBMIT_AD_REQUEST})@ListensFor(events = {EventType.AD_BREAK_COMPLETED, EventType.COMPLETED, EventType.DID_PAUSE, EventType.DID_PLAY, EventType.DID_SET_SOURCE, EventType.STOP, EventType.VIDEO_DURATION_CHANGED, FreeWheelEventType.DID_LOAD_AD_MANAGER, FreeWheelEventType.LOCK, FreeWheelEventType.UNLOCK, FreeWheelEventType.WILL_SUBMIT_AD_REQUEST}) 
    public class FreeWheelController
    extends AbstractComponent
                        

    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.

    LifecycleThe 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();
     
    • Constructor Detail

      • FreeWheelController

        FreeWheelController(Activity activity, FrameLayout frameLayout, EventEmitter emitter)
      • FreeWheelController

        FreeWheelController(Activity activity, FrameLayout frameLayout, EventEmitter emitter, IAdManager manager)
      • FreeWheelController

        FreeWheelController(Activity activity, SurfaceView surfaceView, EventEmitter emitter)
      • FreeWheelController

        FreeWheelController(Activity activity, SurfaceView surfaceView, EventEmitter emitter, IAdManager manager)
    • Method Detail

      • getCurrentVideo

         Video getCurrentVideo()

        Allows access to the current Video object attached to the Controller, if any. This video is the current focus forthe advertisements. The developer will find this method useful if they're listening to the 'will submit ad'request; having access to the current Video can allow one to call 'setVideoAsset' on the current Context withcustom values.

      • setAdRequestingEnabled

         void setAdRequestingEnabled(boolean value)

        Sets the flag which controls whether ads are requested for newvideos. When a playlist contains segments of a single logicalvideo, this flag can be used to turn off ad requests forsubsequent segments.

      • enable

         void enable()

        Enables the FreeWheel plugin. Should be called after FreeWheel Connection information is made, but beforeAny other Components are assigned their emitters

      • disable

         void disable()

        Disables the plugin; prevents further event listening.NOTE: one should call this before replacing an instance of FreeWheelController (e.g. if you call'freeWheelController = new FreeWheelController()' and freeWheelController was already assigned). This will clearout any event listeners that may not have time to be garbage-collected before new events are fired

      • isActive

         boolean isActive()

        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.

      • setupContext

         void setupContext()

        Creates a new AdContext, which can be used to enable adplayback when replaying a video.