jroal / a2dpvolume

Automatically exported from code.google.com/p/a2dpvolume
http://jimroal.com/slist.htm
95 stars 33 forks source link

Wrong media is played after reading notification #265

Closed jook3d closed 5 years ago

jook3d commented 6 years ago

Hi, I am running AD2P Volume on a Samsung S9+. I have been encountering an issue where I have been listening to Spotify (usually via the Waze integration) whilst connected to my car bluetooth.

When a notification is read, Spotify is stopped, but afterwards my podcast application (BeyondPodcast) is started instead. I have to then hit play on Spotify again to resume the media.

jroal commented 6 years ago

I can't fix that. A2DP Volume just toggles the pause/play command. It does not select the active media app. It sounds like you have 2 active media apps going at the same time.

Here is where A2DP Volume toggles the pause (starting on nline 1528 in the current file https://github.com/jroal/a2dpvolume/blob/master/app/src/main/java/a2dp/Vol/service.java ):

if (musicWasPlaying) { // first pause the music Intent i = new Intent( "com.android.music.musicservicecommand"); i.putExtra("command", "pause"); sendBroadcast(i); } So it just broadcasts a pause command. It only does this when you set the message reader to "voice call stream". You can just use another stream and that should fix this.

It looks like this code could use some updating/cleanup but I doubt that will change the issue you are having.

jook3d commented 6 years ago

Thanks for the reply.

I do use the "Voice Stream" when connected to my car as it then reads out over the car hands free which is very convenient.

I don't have either BeyondPodcast or Spotify set as default apps (Android says "none set as default" under both. It is possible BeyondPodcast may have been running in the background but I am pretty sure it wasn't when I opened Spotify (I only listen to BeyondPodcast when connected to my bluetooth headpones).

I did see this thread here : https://stackoverflow.com/questions/18800198/control-the-default-music-player-of-android-or-any-other-music-player where this is mention of broadcasting KeyEvent could cause more than one player to pay. It also mentions Spotify needing to display KeyEvent.Action_UP.

Perhaps just lowering the media volume and raising it back up again might be less troublesome?

Regardless of it you can or will fix this issue, I just want to say thank you for a great app.