Search in sources :

Example 1 with VideoProgressUpdate

use of com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate in project zype-android by zype.

the class PlayerFragment method requestAds.

// 
// IMA SDK
// 
private void requestAds(String adTagUrl) {
    AdDisplayContainer adDisplayContainer = sdkFactory.createAdDisplayContainer();
    adDisplayContainer.setAdContainer(videoFrame);
    // Create the ads request.
    AdsRequest request = sdkFactory.createAdsRequest();
    request.setAdTagUrl(adTagUrl);
    request.setAdDisplayContainer(adDisplayContainer);
    request.setContentProgressProvider(new ContentProgressProvider() {

        @Override
        public VideoProgressUpdate getContentProgress() {
            if (isAdDisplayed || player == null || player.getDuration() <= 0) {
                return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
            }
            return new VideoProgressUpdate(player.getCurrentPosition(), player.getDuration());
        }
    });
    // Request the ad. After the ad is loaded, onAdsManagerLoaded() will be called.
    adsLoader.requestAds(request);
}
Also used : AdsRequest(com.google.ads.interactivemedia.v3.api.AdsRequest) ContentProgressProvider(com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider) AdDisplayContainer(com.google.ads.interactivemedia.v3.api.AdDisplayContainer) VideoProgressUpdate(com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate)

Aggregations

AdDisplayContainer (com.google.ads.interactivemedia.v3.api.AdDisplayContainer)1 AdsRequest (com.google.ads.interactivemedia.v3.api.AdsRequest)1 ContentProgressProvider (com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider)1 VideoProgressUpdate (com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate)1