Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ads] Make AdsLoader.AdViewProvider optional in AdsMediaSource and access to SkipAd field #7689

Closed
RadioFranceAndroidDev opened this issue Jul 28, 2020 · 2 comments
Assignees

Comments

@RadioFranceAndroidDev
Copy link

I work on an audio application (no videos), and we use ExoPlayer with Ads and a VAST server. We work in a library, used by many applications. We don't have access to the player view - or any android view - when we create the AdsMediaSource. We use a trick like this for the moment :

final AdsMediaSource adsMediaSource = new AdsMediaSource(mediaSource, dataSourceFactory, adsLoader, new AdsLoader.AdViewProvider() {
                                        @Override
                                        public ViewGroup getAdViewGroup() {
                                            return new FrameLayout(context.getApplicationContext());
                                        }

                                        @Override
                                        public View[] getAdOverlayViews() {
                                            return new ArrayList<View>().toArray(new View[0]);
                                        }
                                    });
 

It works like a charm, but it's not very clean. Can you make the AdsLoader.AdViewProvider optional ? We just need the SkipAd information in this case, to display manually the Skip button and also the skip value to knon when display it. Can we have a getter to retrieve this two fields ?

Thanks in advance,

RadioFranceTeam

@tonihei
Copy link
Collaborator

tonihei commented Jul 31, 2020

@andrewlewis Could you have a look and say if that's possible/allowed?

@andrewlewis
Copy link
Collaborator

Thanks for the feature request. We should use ImaSdkFactory.createAudioAdDisplayContainer for this use case. I have a change in review that allows returning null from getAdViewGroup as a signal to create an audio ad display container.

Regarding detecting skippability, you can attach an AdEventListener via ImaAdsLoader.Builder.setAdEventListener then in onAdEvent check for AdEvent.getType() == SKIPPABLE_STATE_CHANGED and update your UI accordingly.

To actually skip the ad I plan to add ImaAdsLoader.skipAd (this is only for audio-only ads though, as the IMA SDK takes care of rendering the skipping UI for video ads).

kim-vde pushed a commit that referenced this issue Aug 17, 2020
Issue: #7689
PiperOrigin-RevId: 325752377
@ojw28 ojw28 closed this as completed Sep 12, 2020
@google google locked and limited conversation to collaborators Nov 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants