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

Need a way to decide if the Skip Button should be focused in real time, not when building ImaAdsLoader. #8565

Closed
victorraft opened this issue Feb 8, 2021 · 4 comments
Assignees

Comments

@victorraft
Copy link

We have a TV application that has a video player that can transition between fullscreen and collapsed mode. We're using the IMA extension and we want the Ads Skip Button to be focused only when the player is in fullscreen mode, not when it's collapsed. The ImaAdsLoader.Builder().setFocusSkipButtonWhenAvailable()' cannot be used, because:

a) We need to be able to decide whether the button gets focused or not at the time that the ad becomes skippable, not when the ImaAdsLoader is being constructed.
b) setFocusSkipButtonWhenAvailable is buggy and causes weird issues, like the ad container getting focused when the ad is loaded, instead of when the skip button becomes available.

On previous Exoplayer versions (2.11.8 and lower) we used to be able to use the following workaround:

// When building the ImaAdsLoader we capture the adsManager reference
imaAdsLoader.adsLoader?.addAdsLoadedListener { adsManagerLoadedEvent ->
            adsManager = adsManagerLoadedEvent.adsManager
}

// Then when we receive SKIPPABLE_STATE_CHANGED use the adsManager to focus the skip button
override fun onAdEvent(adEvent: AdEvent) {  
    when (adEvent.type) {
        AdEvent.AdEventType.SKIPPABLE_STATE_CHANGED -> adsManager?.focus() 
        else -> Unit
    }
}

In the current versions it is not possible to do that, because imaAdsLoader.adsLoader returns null.
Is there a recommended way of doing what I want, or do you think you could include such functionality into the SDK?

@victorraft victorraft changed the title Need a way to decide is the Skip Button should be focused in real time, not when building ImaAdsLoader. Need a way to decide if the Skip Button should be focused in real time, not when building ImaAdsLoader. Feb 8, 2021
@andrewlewis
Copy link
Collaborator

Please could you give some more details about the bugs referred to in (b) so I can report this to the IMA SDK team to get the focusing behavior fixed?

Separately, I think we can add ImaAdsLoader.focusSkipButton (calling through to AdsManager in the AdTagLoader in 2.13) to address this. The app can add an ad event listener via ImaAdsLoader.Builder.setAdEventListener then call the new method. Does that sound sufficient to address this?

@victorraft
Copy link
Author

When I use setFocusSkipButtonWhenAvailable(true) the following happens:
1 - the Ads WebView gets focused and displays a yellow border as soon as the preroll starts playing
2 - when the skip button becomes available the button gets the focus and the yellow border

I would appreciate if #1 did not happen, as this messes with my app's focus (it's a TV app so stealing the focus when we don't want it has consequences in the app's UX). Ideally the WebView and its other children (e.g. time counter) wouldn't be focusable at all, just the skip button.

And yes, to me it sounds like if you added ImaAdsLoader.focusSkipButton that would solve our problem!

@andrewlewis
Copy link
Collaborator

Thanks. I will plan to submit that fix soon and it should be included in the next release.

I also filed [Internal: b/179801842] to ask the IMA SDK to look into the unexpected focus stealing behavior.

icbaker pushed a commit that referenced this issue Feb 11, 2021
Issue: #8565

#minor-release

PiperOrigin-RevId: 356691251
@ojw28
Copy link
Contributor

ojw28 commented Feb 12, 2021

The additional method has been added. Can this issue be closed now?

ojw28 pushed a commit that referenced this issue Feb 12, 2021
@google google locked and limited conversation to collaborators Apr 14, 2021
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