use of com.google.ads.interactivemedia.v3.api.CuePoint in project android-player-samples by BrightcoveOS.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
// When extending the BrightcovePlayer, we must assign the BrightcoveExoPlayerVideoView before
// entering the superclass. This allows for some stock video player lifecycle
// management.
setContentView(R.layout.ima_activity_main);
brightcoveVideoView = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view);
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);
mediaController.getBrightcoveSeekBar().addMarker((int) (cuepoint * DateUtils.SECOND_IN_MILLIS));
}
}
});
brightcoveVideoView.setMediaController(mediaController);
super.onCreate(savedInstanceState);
eventEmitter = brightcoveVideoView.getEventEmitter();
// Use a procedural abstraction to setup the Google IMA SDK via the plugin.
setupGoogleIMA();
Map<String, String> options = new HashMap<String, String>();
List<String> values = new ArrayList<String>(Arrays.asList(VideoFields.DEFAULT_FIELDS));
values.remove(VideoFields.HLS_URL);
options.put("video_fields", StringUtil.join(values, ","));
Catalog catalog = new Catalog("ErQk9zUeDVLIp8Dc7aiHKq8hDMgkv5BFU7WGshTc-hpziB3BuYh28A..");
catalog.findVideoByReferenceID("shark", new VideoListener() {
public void onVideo(Video video) {
brightcoveVideoView.add(video);
// Auto play: the GoogleIMAComponent will postpone
// playback until the Ad Rules are loaded.
brightcoveVideoView.start();
}
public void onError(String error) {
Log.e(TAG, error);
}
});
}
use of com.google.ads.interactivemedia.v3.api.CuePoint in project ExoPlayer by google.
the class ImaServerSideAdInsertionMediaSource method setVodAdGroupPlaceholders.
// Static methods.
private static AdPlaybackState setVodAdGroupPlaceholders(List<CuePoint> cuePoints, AdPlaybackState adPlaybackState) {
for (int i = 0; i < cuePoints.size(); i++) {
CuePoint cuePoint = cuePoints.get(i);
adPlaybackState = addAdGroupToAdPlaybackState(adPlaybackState, /* fromPositionUs= */
secToUs(cuePoint.getStartTime()), /* contentResumeOffsetUs= */
0, /* adDurationsUs...= */
secToUs(cuePoint.getEndTime() - cuePoint.getStartTime()));
}
return adPlaybackState;
}
use of com.google.ads.interactivemedia.v3.api.CuePoint 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, event -> {
AdsManager manager = (AdsManager) event.properties.get("adsManager");
if (manager != null) {
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