spotify / android-sdk

Spotify SDK for Android
https://developer.spotify.com/documentation/android/
Apache License 2.0
454 stars 117 forks source link

Starting playback with screen off will sometimes cause Spotify to ignore audio focus #291

Open matejdro opened 3 years ago

matejdro commented 3 years ago

SDK Version: 0.4.0

OS Version: 10

Spotify Version: 8.6.4.971

Steps to reproduce:

  1. Spotify should be in stopped/paused state
  2. Connect to the Spotify via SpotifyAppRemote.CONNECTOR.connect() and play playlist URI with SpotifyAppRemote.play() while screen is off and locked
  3. Turn the screen back on
  4. Open another media app (such as a podcast player) and start playback

Expected behaviour:

Spotify should pause itself when podcast player starts playing.

Actual behaviour:

Sometimes, when playback is started from SpotifyAppRemote, Spotify will ignore all audio focus changes and will keep playing over other audio sources This happens even after manually playing/pausing via UI.

Only way I found to get Spotify out of that weird state is to force stop it and restart it again manually.

Issue is similar, but less severe than https://github.com/spotify/android-sdk/issues/19