Class FreeWheelController

  • All Implemented Interfaces:
    Component

    @Emits(events={"didSetSource","play","registerPlugin","didLoadAdManager","freewheelDidSubmitAdRequest","freewheelLock","freewheelShowDisplayAd","freewheelUnlock","freewheelWillSubmitAdRequest"})
    @ListensFor(events={"adBreakCompleted","completed","didPause","didPlay","didSetSource","stop","videoDurationChanged","didLoadAdManager","freewheelLock","freewheelUnlock","freewheelWillSubmitAdRequest"})
    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.


    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, AdCuePointComponent, FreeWheelEventType, VideoDisplayComponent
    • Field Detail

      • AD_CONTEXT_KEY

        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
      • AD_REQUEST_CONFIGURATION_KEY

        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​(android.app.Activity activity,
                                   android.widget.FrameLayout frameLayout,
                                   EventEmitter emitter)
      • FreeWheelController

        public FreeWheelController​(android.app.Activity activity,
                                   android.widget.FrameLayout frameLayout,
                                   EventEmitter emitter,
                                   tv.freewheel.ad.interfaces.IAdManager manager)
      • FreeWheelController

        @Deprecated
        public FreeWheelController​(android.app.Activity activity,
                                   android.view.SurfaceView surfaceView,
                                   EventEmitter emitter)
        Deprecated.
      • FreeWheelController

        @Deprecated
        public FreeWheelController​(android.app.Activity activity,
                                   android.view.SurfaceView surfaceView,
                                   EventEmitter emitter,
                                   tv.freewheel.ad.interfaces.IAdManager manager)
        Deprecated.
    • Method Detail

      • setSubmissionTimeout

        public void setSubmissionTimeout​(double timeout)
      • setAdManager

        public void setAdManager​(tv.freewheel.ad.interfaces.IAdManager manager)
      • getAdManager

        public tv.freewheel.ad.interfaces.IAdManager getAdManager()
      • setAdManagerURL

        @Deprecated
        public void setAdManagerURL​(java.lang.String url)
        Deprecated.
      • 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.
        Returns:
        the current Video, null if none exists
        See Also:
        Video, IAdContext
      • getCurrentContext

        public tv.freewheel.ad.interfaces.IAdContext getCurrentContext()
        Returns:
        The current Ad Context in use, if any
        See Also:
        IAdContext
      • 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.
        Returns:
        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.