Access to Ad media Url using IMA SDK owned Ad Playback

691 views
Skip to first unread message

sandhya chotrani

unread,
Nov 23, 2017, 7:26:03 AM11/23/17
to Interactive Media Ads SDK
Hi Team,

Request you to help me with accessibility of Ad media Url if I'm using IMA SDK owned Ad playback mode. Is there any function/method to access VAST media url for the particular Ad tag request?
Also I tried this function to get Ad response in Basic example shared on your site. It returns null for sample Ad tag.

private void requestAds(String adTagUrl) {
AdDisplayContainer adDisplayContainer = mSdkFactory.createAdDisplayContainer();
adDisplayContainer.setAdContainer(mAdUiContainer);

// Create the ads request.
request = mSdkFactory.createAdsRequest();
request.setAdTagUrl(adTagUrl);

request.setAdDisplayContainer(adDisplayContainer);
request.setContentProgressProvider(new ContentProgressProvider() {
@Override
public VideoProgressUpdate getContentProgress() {
if (mIsAdDisplayed || mVideoPlayer == null || mVideoPlayer.getDuration() <= 0) {
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
}
return new VideoProgressUpdate(mVideoPlayer.getCurrentPosition(),
mVideoPlayer.getDuration());
}
});
mAdsLoader.addAdsLoadedListener(new AdsLoadedListener() {
@Override
public void onAdsManagerLoaded(AdsManagerLoadedEvent adsManagerLoadedEvent) {
Log.d("barc","onAdsManagerLoaded: "+adsManagerLoadedEvent.getUserRequestContext());

}
});

// Request the ad. After the ad is loaded, onAdsManagerLoaded() will be called.
mAdsLoader.requestAds(request);
Log.d("IMA","ad Response: "+request.getAdsResponse()); // returns null. Tried this function Ad load event too and still returns Null.

}

Please help me understand how can I extract response of Ad tag played by IMA SDK.

Joshua Lagonera (IMA SDK Team)

unread,
Nov 24, 2017, 12:35:35 AM11/24/17
to Interactive Media Ads SDK
Hi there,

I'm afraid there are currently no methods in the IMA Android SDK to obtain the Media URL from a successful Ad Request. The only information about the ad you are able to fetch using the SDK are the ones that are outlined in this document.

As for the AdsRequest.getAdsResponse() method returning null, it is because it is only populated when you are using a canned VAST XML response as an Ad Request via AdsRequest.setAdsResponse(). This means that it is also not populated when your Ad Request is successful.

Hope this clears up any confusion on your end.

Regards,
Joshua Lagonera
IMA SDK Team

sandhya chotrani

unread,
Nov 26, 2017, 6:31:11 AM11/26/17
to Interactive Media Ads SDK
Hi Joshua,

Thanks for clarification. It helped me.
So to access Ad media url and take control of Ad playing I can go for IMA SDK in custom mode playback. Correct me if I'm wrong?

Regards
Sandhya C

Joshua Lagonera (IMA SDK Team)

unread,
Nov 27, 2017, 4:45:53 AM11/27/17
to Interactive Media Ads SDK
Hi Sandhya,

I'm afraid accessing the URL of the Media of the Ad is not supported for both SDK-owned playback and Custom playback. However, you would have more control over Ad playback if you choose to implement Custom Playback.

Let me know if you have any more questions.

Regards,
Joshua Lagonera
IMA SDK Team

sandhya chotrani

unread,
Nov 27, 2017, 5:28:28 AM11/27/17
to Interactive Media Ads SDK
Hey Joshua, 

When I use custom playback, and also in Advanced sample Google IMA app, I could see below code snippet which is actually exposing Ad media url of the Ad to the app. Though not directly via function but indirectly I'm able to access Ad medai Url. Will this method always returns valid media Url of Ad being played?

mVideoAdPlayer = new VideoAdPlayer() {
        @Override
        public void playAd() {
            mIsAdDisplayed = true;
            mVideoPlayer.play();
        }
        @Override
        public void loadAd(String url) {
            mIsAdDisplayed = true;
            mVideoPlayer.setVideoPath(url);  // Ad media url
        }
        @Override
        public void stopAd() {
            mVideoPlayer.stopPlayback();
        }
        @Override
        public void pauseAd() {
            mVideoPlayer.pause();
        }
        @Override
        public void resumeAd() {
            playAd();
        }
};

Please let me know, my use case is to fetch media Ad Urls for creative identification.

Joshua Lagonera (IMA SDK Team)

unread,
Nov 27, 2017, 11:28:59 PM11/27/17
to Interactive Media Ads SDK
Hi Sandhya,

Apologies for the confusion. Yes, you are correct that you are able to use that callback method in order to obtain the Ad Media URL. 

Regards,
Joshua Lagonera
IMA SDK Team

sandhya chotrani

unread,
Nov 28, 2017, 5:33:53 AM11/28/17
to Interactive Media Ads SDK
Thanks Joshua for confirmation. It was a great help from your end. I will implement custom mode of SDK for my use case.

sandhya chotrani

unread,
Dec 1, 2017, 3:36:01 AM12/1/17
to Interactive Media Ads SDK
Hi Joshua,
Is this applicable across all platforms android, ios and web? I mean accessibility of Ad media Urls in IMA custom mode playback. 

Please let me know.

Joshua Lagonera (IMA SDK Team)

unread,
Dec 1, 2017, 5:40:45 AM12/1/17
to Interactive Media Ads SDK
Hi Sandhya,

For the HTML5 SDK, you can use Ad.getMediaUrl(). For iOS, it would depend on the player you are using. If you are using AVPlayer, you may try and fetch the AVURLAsset.url when you successfully fetch an ad and start playing it.

Regards,
Joshua Lagonera
IMA SDK Team

siva ramakrishna kv

unread,
Jan 28, 2020, 8:04:01 AM1/28/20
to Interactive Media Ads SDK
Hi

Is this supported for Android and ios now? i don't see any such API available.

Thanks
Siva
Reply all
Reply to author
Forward
0 new messages