Closed luc-vocab closed 8 years ago
I'm not an android developer so apologies in advance if this is completely irrelevant. I noticed that here, AnkiDroid is requesting audio focus: https://github.com/ankidroid/Anki-Android/blob/026ae9dd0cfb1d7b6bc00910d5d22b53be5be828/AnkiDroid/src/main/java/com/ichi2/libanki/Sound.java#L329
I notice in these examples, that the sample code checks for the return value of requestAudioFocus(): https://developer.android.com/training/managing-audio/audio-focus.html
would it be a good idea for AnkiDroid to do the same, and could this explain the lag that i'm seeing ?
Thank you.
I can't reproduce this behaviour on my device. However, I did discover that audio focus is not returned at all if the sound is triggered manually by tapping the media playback icon. That needs to be fixed.
So is it possible, in fact, it's the music apps that i'm using which are not well behaved with respect to audio focus ? Would you be open to introducing a setting which doesn't request audio focus, allowing audio to keep playing in the background at normal level for those who like listening to music while reviewing ?
I doubt that both of those applications have the same issue. There is some detail about your set up that is missing (custom rom? bluetooth hardware? etc...) that must be responsible for the odd behaviour. Try to test it with other applications that perform audio ducking (like a navigator). It sounds to me like the audio manager on your device is misbehaving for whatever reason.
We're not really keen on adding more settings and I would imagine removing audio ducking is somewhat counter-productive for most users.
Did a few more tests and it looks clear that both Soundcloud and Digitally imported are not well behaved with regards to audio focus. Soundcloud has a very clear lag. I was getting that lag on my previous phone as well so I blamed AnkiDroid but it clearly looks like soundcloud is the culprit. Digitally Imported has a slighly more weird behavior with a little bit less lag, but sometimes the sound cuts off.
Other confirmed reports that soundcloud doesn't work well with ducking:
Did another test with google music and AnkiDroid audio, and the ducking behavior is exactly as expected.
Your desire to not have a setting related to this stems from wanting to keep the settings clean, or due to lack of time ? If I submit a pull request implementing this, how would it be received ?
To be honest I feel like maybe I have to give up on that idea, turns out that even with a fully audio focus compliant music app, the mismatched volume between my anki audio and the music player's audio makes it kind of hard to listen to music and review audio flashcards at the same time. Going to close this then. Thanks for your help.
Looks like soundcloud fixed the audio focus ducking delay.
Research
Enter an [ x ] character to confirm the points below:
[x] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
[x] I have checked the manual and the FAQ and could not find a solution to my issue
[x] I have searched for similar existing issues here and on the user forum
Reproduction Steps
Expected Result
I expect the background music app's audio volume to be lowered immediately before Anki's audio starts playing, and go back to full volume after Anki's audio has finished playing.
Actual Result
My understanding is that this behavior is related to Android's "Audio Focus" feature. Would it be possible to ignore the audio focus and play sounds no matter whether a background app is playing music or not ? I'm pretty fond of reviewing my flashcards while listening to music.
Thank you for reading !
Debug info
AnkiDroid Version = 2.6.1
Android Version = 6.0.1
ACRA UUID = 54fb24b5-ea12-4beb-84ee-6e1b66f48af8