Mach5 / supersonic

Open-source web-based media streamer and jukebox fork of Subsonic. Supports MP3, OGG, AAC and other streamable audio and video formats. Runs on Windows, GNU/Linux and Mac using Java.
226 stars 61 forks source link

switch to Audio Focus breaks playback pausing when ringtone is disabled #50

Open timoreimann opened 12 years ago

timoreimann commented 12 years ago

With issue #8, the Android app switched to Audio Focus management. Unfortunately, the switch broke a piece of functionality which was brought to Subsonic as a patch by myself. It's all described on the Subsonic Sourceforge tracker; in a nutshell, it goes like this:

Prior to integration of the patch, when listening to Subsonic music via headphones with the ringtone disabled, the user would not be notified of an incoming call as the music would simply continue playing. The only way to get around the problem was to turn vibration on. However, in a busy situation or one where the phone wasn't available haptically it was easy to miss calls. (Happened to me several times.) That's why the patch was introduced to change behavior such that music would pause and allow the user to become aware of the incoming call.

Due to the modifications made in Supersonic along issue #8 there is no change of audio focus anymore, simply because a disabled ringtone doesn't constitute a change in audio focus. I made a couple of tests on my phone which confirm my findings.

One approach to fix this problem is to continue listening for a change of phone state in case where the ringtone is disabled and act accordingly. It's a shame that this will introduce some kind of multi-state listening to the application but I think it's still better than reverting back to the old code that lacked Audio Focus. (After all, using Audio Focus is a benefit.)