Custom UI with the IMA SDK for Android

1,238 views
Skip to first unread message

Ramprakash Bhat

unread,
Feb 4, 2021, 8:32:41 AM2/4/21
to Interactive Media Ads SDK
Hi,
I followed the step as mentioned here, but it is not working as expected. I found the reason why it is not working.

ImaAdsLoader#

@Override
public void onTimelineChanged(Timeline timeline, @Player.TimelineChangeReason int reason) {
  if (timeline.isEmpty()) {
    // The player is being reset or contains no media.
    return;
  }
  Assertions.checkArgument(timeline.getPeriodCount() == 1);
  this.timeline = timeline;
  long contentDurationUs = timeline.getPeriod(/* periodIndex= */ 0, period).durationUs;
  contentDurationMs = C.usToMs(contentDurationUs);
  if (contentDurationUs != C.TIME_UNSET) {
    adPlaybackState = adPlaybackState.withContentDurationUs(contentDurationUs);
  }
  @Nullable AdsManager adsManager = this.adsManager;
  if (!isAdsManagerInitialized && adsManager != null) {
    isAdsManagerInitialized = true;
    @Nullable AdsRenderingSettings adsRenderingSettings = setupAdsRendering();
    if (adsRenderingSettings == null) {
      // There are no ads to play.
      destroyAdsManager();
    } else {
      adsManager.init(adsRenderingSettings);
      adsManager.start();
      if (DEBUG) {
        Log.d(TAG, "Initialized with ads rendering settings: " + adsRenderingSettings);
      }
    }
    updateAdPlaybackState();
  }
  handleTimelineOrPositionChanged();
}

in above code as i highlighted (in red color)  adsRenderingSettings  is recreating as new object and initialised to adManager and  it will do resetting the adRenderSettings  of adManager that we set earlier :- 

@Override
public void onAdsManagerLoaded(AdsManagerLoadedEvent adsManagerLoadedEvent) {
    mAdsManager = adsManagerLoadedEvent.getAdsManager();

    ...
    AdsRenderingSettings settings = mSdkFactory.createAdsRenderingSettings();
    settings.setDisableUi(true);
    mAdsManager.init(settings);
}

So settings.disableUi  become false as default  and Ad.isUiDisabled() always returns false.
Can you please look into this issue ASAP

Thanks,
Ram Prakash

IMA SDK

unread,
Feb 4, 2021, 11:09:33 AM2/4/21
to prakash...@gmail.com, ima...@googlegroups.com
Hi Ram Prakash,

Thank you for bringing up your issue with Ad.isUiDisabled always returning false. When implementing custom - UI in our Advanced Example with the changes in the attachments below, the ads showed with custom rendering when the sample custom rendering ad tag was used. If this doesn't address your use case feel free to clarify what your requirements are.

Regards,

Google Logo
Aryeh Baker
IMA SDK Team
 


ref:_00D1U1174p._5004Q2BdnCG:ref
fragment_video.txt
VideoFragment.txt
VideoPlayerController.txt

Ramprakash Bhat

unread,
Feb 4, 2021, 12:22:49 PM2/4/21
to Interactive Media Ads SDK
Thank you for your kind response.

I am using IMA extension for ad implementation, everything works perfect expect custom UI
What am doing is as below.

The below code block is added at client side:   
=======================================================================================================
imaAdsLoader?.adsLoader?.addAdsLoadedListener { loadEvent ->
adsManager = loadEvent?.adsManager
val settings: AdsRenderingSettings = ImaSdkFactory.getInstance().createAdsRenderingSettings()
settings.disableUi = true
adsManager?.init(settings)
}

As per my understanding above code block do not have any impact since it is overriding in   ImaAdsLoader#onTimelineChanged
==========================================================================================================

AdEvent observer:
========================================================================================================
imaAdsBuilder.setAdEventListener { adEvent ->
Here am getting:-    adEvent.ad?.isUiDisabled  as false only
}

=================================================================================================================================

Is there anything needs to be done at backend (GoogleAdManager/Vast provider)? 
Am able to see my custom UI but the default Ad UI (Skip Ad,Ad counter etc) also visible.

IMA SDK

unread,
Feb 4, 2021, 1:02:59 PM2/4/21
to prakash...@gmail.com, ima...@googlegroups.com
Hi Ram Prakash,

The only change in the VAST necessary for this to work is documented as adding to the VAST:
<Extension type="uiSettings">
<UiHideable>1</UiHideable>
</Extension>
This forum doesn't support the IMA plugin, you can get support from the Exoplayer Github Issue Tracker. The implementation in the Advanced Example sent below works. The standard UI elements don't show. Ad.isUiDisabled() comes back true every half a second when UiDisabled ads are playing. 

Note that adsRenderingSettings.setDisableUi() is currently a no-op. Custom UI with the IMA SDK for Android is unlisted and will probably not work for you.

Ramprakash Bhat

unread,
Feb 4, 2021, 11:56:17 PM2/4/21
to Interactive Media Ads SDK
Ok got it, Thanks a lot

IMA SDK

unread,
Feb 5, 2021, 2:47:07 AM2/5/21
to prakash...@gmail.com, ima...@googlegroups.com

Hi Ramprakash,

Thank you for your message. Feel free to contact us if you have further questions regarding the IMA SDK implementation and our team will be happy to assist you.


Regards,


Google Logo
Sherwin Diesta
IMA SDK Team
 


ref:_00D1U1174p._5004Q2BdnCG:ref
Reply all
Reply to author
Forward
0 new messages