How to play/pause ads with ExoPlayer controller?

1,553 views
Skip to first unread message

Nishant Patel

unread,
Mar 19, 2021, 3:19:58 PM3/19/21
to Interactive Media Ads SDK
Hello, 

I am using IMA for DAI.

To bring the ExoPlayer controller on top during ad playback, I am using the following.

    @Override
    public void onAdEvent(@NonNull AdEvent adEvent) {
        ....
        switch (adEvent.getType()) {
            case TAPPED:
                log("Tapped on an Ad.");
                if (playerView.isControllerVisible()) {
                    playerView.hideController();
                } else {
                    playerView.showController();
                }
                break;
        ....
        }
    }

But once the controller is visible and I click on the play/pause icon, it's not pausing/playing an Ad. It triggers TAP events, even though I am clicking on the visible control rack.

I am using the same kind of logic with VAST AdTag, and it is working as expected. I can pause and resume the ad playback.

Can you give me any suggestions for achieving desired behavior?

IMA SDK

unread,
Mar 22, 2021, 12:03:27 AM3/22/21
to nishant....@gmail.com, ima...@googlegroups.com

Hi Nishant,

Thank you for reaching out to us. As per our sample implementation, it is advisable to disable video player controls during an ad break, even seeking must be disabled (more information here). Thus, can you share with us your use case here?

Also, it will  be helpful if you could share with us the following information via our testing alias: imate...@gmail.com so we can test further.

  • VAST ad tag
  • Sample project file (if possible)



Regards,


Google Logo
Sherwin Diesta
IMA SDK Team
 

 

ref:_00D1U1174p._5004Q2DxEZr:ref

Nishant Patel

unread,
Mar 22, 2021, 10:33:17 AM3/22/21
to Interactive Media Ads SDK
Hi Sherwin,

We just want a user to have the flexibility of playing/pausing an Ad (no seeking).  I have sent an email with project files.  

Thanks
Nishant

IMA SDK

unread,
Mar 22, 2021, 12:50:20 PM3/22/21
to nishant....@gmail.com, ima...@googlegroups.com
Hi Nishant,

I work with Sherwin and will assist you. While pausing ads is an unsupported feature I was able to force this ability in the following way in the 'Tapped' event:
PlayerView videoView = ((Activity)context).findViewById(R.id.videoView);
videoView.bringToFront();
  videoPlayer.enableControls(true);

Note that there is no guarantee that this will not affect viewability metrics or that this fulfills policy requirements. 

Regards,

Google Logo
Aryeh Baker
IMA SDK Team
 


ref:_00D1U1174p._5004Q2DxEZr:ref

Nishant Patel

unread,
Mar 25, 2021, 1:54:57 PM3/25/21
to Interactive Media Ads SDK
Hey Aryeh,

It works with  videoPlayer.enableControls(true).
Now I am able to play/pause ads.

Thanks,
Nishant

IMA SDK

unread,
Mar 25, 2021, 2:41:42 PM3/25/21
to nishant....@gmail.com, ima...@googlegroups.com
Hi Nishant,

Thank you for reporting back. When testing further with my solution with bringToFront the ad overlays wouldn't show any more and there's no way to get to the landing page of the ad. Is fine with you?

Nishant Patel

unread,
Apr 8, 2021, 4:19:36 PM4/8/21
to Interactive Media Ads SDK
Hi Aryeh, 

What do you mean by the landing page of an Ad? 
I noticed that the Ad counter is missing and also Learn More on the top right corner is also not visible.

IMA SDK

unread,
Apr 9, 2021, 9:10:22 AM4/9/21
to nishant....@gmail.com, ima...@googlegroups.com
Hi Nishant,

I used different words to say the same thing you are saying. Please get back to us if this solution doesn't suit your needs.

Nishant Patel

unread,
Apr 9, 2021, 10:49:20 AM4/9/21
to Interactive Media Ads SDK
Hi Aryeh,

One another way I am able to achieve this is by rearranging the order of adUIContainer by putting ExoPlayer PlayerView on top of adUIContainer (but AdCounter and learn more is not visible as well).
 
So layout looks something like this,

<FrameLayout
  android:id="@+id/adUiContainer"
  android:layout_width="match_parent"
  android:layout_height="match_parent" />

<com.google.android.exoplayer2.ui.PlayerView
  android:id="@+id/playerView"
  android:layout_width="match_parent"
  android:layout_height="match_parent"/>

And onAdEvent() callback will look something like this,

case TAPPED:
     log("Tapped on an Ad event fired.");

     if (playerView.isControllerVisible()) {
       playerView.hideController();
     } else {
       playerView.showController();
     }

With this approach, I do not have to use playerView.bringToFront().

Apart from that, I am also using registerFriendlyObstruction()on all player controls. 

I found one issue ExoPlayer, which is somewhat similar to this.


Thanks
Nishant

IMA SDK

unread,
Apr 9, 2021, 1:32:47 PM4/9/21
to nishant....@gmail.com, ima...@googlegroups.com
Hi Nishant,

thank you for reporting this, I was able to replicate what you are saying that just placing the PlayerView later allowed the ad to pause while causing "Learn more" or countdown to not work. Please let us know if you need anything else in this matter.
Reply all
Reply to author
Forward
0 new messages