-
Notifications
You must be signed in to change notification settings - Fork 87
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
[Bug] When requesting audio focus to the application, the focus is immediately lost #615
Comments
Hello, When you call On a different topic, can you confirm that the TTS doesn't stop when an interruption happens with no custom focus listener meddling in? That sounds like a bug and would deserve opening a separate issue. |
I looked better at the code, my suggestion can't work right now: the |
I tried this and then implemented the custom listener, but nothing changed :(
I started playing the TTS, and then sent a notification to my device, the TTS kept playing as if no interruption happened. I tested this in Android 13 and 14.
Yes, I tried setting it to false, but no change happened. To test this, I also tried requesting the focus with a delay, to see if there was a racing condition, or if requesting the audio focus after the Readium request would change something, but it didn't. After the TTS started playing, I set a 5-second delay to request the focus. Yet the same thing happened, after requesting the focus 5 seconds later, the app regained focus yet lost it immediately. I believe this is a bug, right? Do you have any other suggestions as to what I could do to make this work? If you need any more information, let me know! |
Thanks for the detailed report! There definitely could be a bunch of Readium-related issues. Unfortunately, this requires a lot of investigation so I can't help you more right now. |
@qnga Thank you for the help. |
Yes, but at some entirely indefinite time, unfortunately. The code should be quite straightforward if you're familiar with ExoPlayer and Media APIs, so feel free to open a PR. The goals are as follows:
|
Describe the bug
I have a class which sets a TtsNavigator through
When I play it, I request the audio focus because I want to control what happens when there's a gain/loss of audio focus (with incoming messages, calls etc).
However, whenever I run
ttsNavigator.play()
and request the focus, it's immediately lost. This is the code related to audio focusing:As mentioned, when I start playing the TTS, I get
AUDIOFOCUS_LOSS
here:Once I lose the audio focus, I can't do anything with the listener anymore.
One thing that I noticed in the logs is that it seems that Readium "steals" the focus when I hit play. I find this a bit weird, because Readium is being executed in my application, and so it should not steal the focus.
I saw in the Readium code that there is audio focus management.
Here are some logs that I found:
You can see that after my class requests the audio focus, Readium gets it soon after, I don't know why. Once that happens my app never gets the focus back.
It's curious that
callingPack
for both is my app's package, so I don't understand why my app loses the focus.I don't know if I'm missing something, or if this is a bug, but please let me know what's the right way to manage audio focus so that I have full control over it while I'm using TTS.
How to reproduce?
Readium version
3.0.0
Android API version
12 (API 32), 13 (API 33), 14 (API 34)
Additional context
The text was updated successfully, but these errors were encountered: