1

Hi everyone just wondering if anyone knew what we need to do to play IMA ads on chrome cast from a sender app, From what I understand reading the docs the only way to play it is to send a message to the chromecast receiver with the pubads URL:

private void loadMedia(MediaInfo mediaInfo, Boolean autoplay) {
    try {
        Log.d(TAG, "loading media");
        mRemoteMediaPlayer.load(sApiClient, mediaInfo, autoplay)
                .setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {
                    @Override
                    public void onResult(RemoteMediaPlayer.MediaChannelResult result) {
                        if (result.getStatus().isSuccess()) {
                            boolean adStarted = mVideoPlayerController.hasAdStarted();
                            if (mVideoFragment.isVmap() || !adStarted) {
                                sendMessage("requestAd," + mAdTagUrl + ","
                                        + mVideoPlayerController.getCurrentContentTime());
                            } else {
                                sendMessage("seek,"
                                    + mVideoPlayerController.getCurrentContentTime());
                            }
                        } else {
                            Log.e(TAG, "Error loading Media : "
                                    + result.getStatus().getStatusCode());
                        }

FYI : the mAdTagUrl is the 'pubads' link

Ex pubs link :

https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator=

1 Answers1

1

Incase anyone was looking for the answer :

it's actually in the AdBreak Clip Info Builder -> setVastAdsRequest() Method.

Pass in the 'pubads' link to this method , and you're good to go.

  • Hi @Manendra De Mel , thanks for the info. I wonder how you can present Ads loaded via setVastAdsRequest() on multiple places in my video (lets say at 10000 ms and then at 30000 ms of the video for example). Also I wonder do you have any idea of why my Ads are not playing when the time comes. I can see the the Ad marker in the video timeline, but it does not play when the progress reaches that moment, the video just continues without the Ad, thanks – Stoycho Andreev May 16 '22 at 16:00
  • @StoychoAndreev Apologies for the long overdue Answer, I've missed this one. You need to create separate AdBreakClipInfo objects `val breakClip1 = AdBreakClipInfo.Builder(“ad1”) .setTitle(“Ad Clip 1”) .setContentUrl("https://multiplatform-f.akamaihd.net/ads/geronimo.mp4") .build()` and then create an AdbreakInfo object passing in the 'clip ids' as a list and then pass these objects into your `MediaInfo.Builder` using the `.setAdBreaks(listOf(breakinfo)) .setAdBreakClips(listOf(breakClip1, breakClip2))` methods. I have a medium article – Manendra De Mel Mar 06 '23 at 22:15
  • You can read more about it here : https://medium.com/@mdemel.dev/lets-do-chromecast-videos-with-android-part-5-f66c8755918a – Manendra De Mel Mar 06 '23 at 22:16