Class FreeWheelController

  • All Implemented Interfaces:

    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.


    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
    See Also:
    IAdContext, IAdManager, AdCuePointComponent, FreeWheelEventType, VideoDisplayComponent
    • Field Detail


        public static final java.lang.String AD_CONTEXT_KEY
        Key used for storing the current IAdContext in an Event
        See Also:
        Constant Field Values
      • AD_SLOTS_KEY

        public static final java.lang.String AD_SLOTS_KEY
        Key used for storing a List of ISlot instances for use by developers, e.g. with DISPLAY ad types
        See Also:
        Constant Field Values

        public static final java.lang.String AD_REQUEST_CONFIGURATION_KEY
        Key used for storing the current AdRequestConfiguration in an Event
        See Also:
        Constant Field Values
    • Constructor Detail

      • FreeWheelController

        public FreeWheelController​( activity,
                                   android.widget.FrameLayout frameLayout,
                                   EventEmitter emitter)
      • FreeWheelController

        public FreeWheelController​( activity,
                                   android.widget.FrameLayout frameLayout,
                                   EventEmitter emitter,
      • FreeWheelController

        public FreeWheelController​( activity,
                                   android.view.SurfaceView surfaceView,
                                   EventEmitter emitter)
      • FreeWheelController

        public FreeWheelController​( activity,
                                   android.view.SurfaceView surfaceView,
                                   EventEmitter emitter,
    • Method Detail

      • setSubmissionTimeout

        public void setSubmissionTimeout​(double timeout)
      • setAdManager

        public void setAdManager​( manager)
      • getAdManager

        public getAdManager()
      • setAdManagerURL

        public void setAdManagerURL​(java.lang.String url)
      • setAdURL

        public void setAdURL​(java.lang.String url)
      • setAdNetworkId

        public void setAdNetworkId​(int id)
      • setProfile

        public void setProfile​(java.lang.String profile)
      • setSiteSectionId

        public void setSiteSectionId​(java.lang.String sectionId)
      • getCurrentVideo

        public Video getCurrentVideo()
        Allows access to the current Video object attached to the Controller, if any. This video is the current focus for the 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 with custom values.
        the current Video, null if none exists
        See Also:
        Video, IAdContext
      • getCurrentContext

        public getCurrentContext()
        The current Ad Context in use, if any
        See Also:
      • enable

        public void enable()
        Enables the FreeWheel plugin. Should be called after FreeWheel Connection information is made, but before Any other Components are assigned their emitters
      • disable

        public 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 clear out any event listeners that may not have time to be garbage-collected before new events are fired
      • isActive

        public 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.
        boolean true if the controller is actively listening for Events, false if not
      • setAdRequestingEnabled

        public void setAdRequestingEnabled​(boolean value)
        Sets the flag which controls whether ads are requested for new videos. When a playlist contains segments of a single logical video, this flag can be used to turn off ad requests for subsequent segments.
      • isAdRequestingEnabled

        public boolean isAdRequestingEnabled()
        Returns whether ad requesting is enabled.
      • setupContext

        public void setupContext()
        Creates a new AdContext, which can be used to enable ad playback when replaying a video.