Search in sources :

Example 1 with BrightcoveSeekBar

use of com.brightcove.player.mediacontroller.BrightcoveSeekBar in project android-player-samples by BrightcoveOS.

the class MainActivity method setupAdMarkers.

/*
      This methods show how to the the Google IMA AdsManager, get the cue points and add the markers
      to the Brightcove Seek Bar.
     */
private void setupAdMarkers(BaseVideoView videoView) {
    final BrightcoveMediaController mediaController = new BrightcoveMediaController(brightcoveVideoView);
    // Add "Ad Markers" where the Ads Manager says ads will appear.
    mediaController.addListener(GoogleIMAEventType.ADS_MANAGER_LOADED, new EventListener() {

        @Override
        public void processEvent(Event event) {
            AdsManager manager = (AdsManager) event.properties.get("adsManager");
            List<Float> cuepoints = manager.getAdCuePoints();
            for (int i = 0; i < cuepoints.size(); i++) {
                Float cuepoint = cuepoints.get(i);
                BrightcoveSeekBar brightcoveSeekBar = mediaController.getBrightcoveSeekBar();
                // If cuepoint is negative it means it is a POST ROLL.
                int markerTime = cuepoint < 0 ? brightcoveSeekBar.getMax() : (int) (cuepoint * DateUtils.SECOND_IN_MILLIS);
                mediaController.getBrightcoveSeekBar().addMarker(markerTime);
            }
        }
    });
    videoView.setMediaController(mediaController);
}
Also used : AdsManager(com.google.ads.interactivemedia.v3.api.AdsManager) BrightcoveSeekBar(com.brightcove.player.mediacontroller.BrightcoveSeekBar) Event(com.brightcove.player.event.Event) ArrayList(java.util.ArrayList) List(java.util.List) EventListener(com.brightcove.player.event.EventListener) BrightcoveMediaController(com.brightcove.player.mediacontroller.BrightcoveMediaController)

Aggregations

Event (com.brightcove.player.event.Event)1 EventListener (com.brightcove.player.event.EventListener)1 BrightcoveMediaController (com.brightcove.player.mediacontroller.BrightcoveMediaController)1 BrightcoveSeekBar (com.brightcove.player.mediacontroller.BrightcoveSeekBar)1 AdsManager (com.google.ads.interactivemedia.v3.api.AdsManager)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1