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);
}
Aggregations