[GH-ISSUE #497] Can't play songs from Android app #313

Closed
opened 2026-02-27 19:29:58 +03:00 by kerem · 8 comments
Owner

Originally created by @Johannesd3 on GitHub (Jun 18, 2020).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/497

Playing a song with librespot from my Android Spotify app doesn't work. After playing a song in the app and switching to the librespot client, the Android app and the web client still show the song as playing, but librespot produces no sound. When I press pause (or do any other action like increasing volume) on my phone, the playback appears as stopped. In the Web Client everything works fine.

Here's the log of librespot. The command=stop in the second last line seems quite suspicious to me and might be the cause:

[2020-06-18T14:43:47Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206045774 1592491428201
[2020-06-18T14:43:52Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206051183 1592491433610
[2020-06-18T14:43:57Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206055368 1592491437795
[2020-06-18T14:44:00Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206058649 1592491441076
[2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] kMessageTypeLoad "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206063633 1592491441076
[2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] State: context_uri: "spotify:album:7fYlJ1HNLfs6JIvJCJ2rqq" index: 0 position_ms: 86485 status: kPlayStatusPlay position_measured_at: 1592491446088 context_description: "" shuffle: false repeat: false playing_from_fallback: true row: 0 playing_track_index: 0 track {gid: "|A!\026\321\222O\252\222\245\240\371\211\327\343\020"} track {gid: "n\227`\315x\352K\335\216\016\000\302L_1$"} track {gid: "\337UY\305Q\306L\236\252\367\022\347\353\244T\360"} track {gid: "\373\210rq\213\271@G\274\340\276\216\270\005\333\311"} track {gid: "\205K\253\235#XK\305\211\205\223H\221\241e\243"} track {gid: "\020\225\2458\001\264BC\250\203\315g\247{\177\002"} track {gid: "\316\361yC\343\366H\335\277\177\007\241\375\327[u"} track {gid: ":U+J\326\004I\320\250H\361O\310\343\310\257"} track {gid: "\000\231)\n\3232BB\275\356 7\271Ooj"} track {gid: "\017\245ir\370\315C\317\245\315\371~\374,#\250"} track {gid: "\361\031\223\006x\302J\200\230tc\231\266b;\320"} track {gid: "Z\227w@\031:L$\224\025\\\3749]\033s"} track {gid: "\033\303?x\232LC\265\217j\213\231\236\367\207\370"}
[2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] Frame has 13 tracks
[2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] Loading context: <spotify:album:7fYlJ1HNLfs6JIvJCJ2rqq> index: [0] of 13
[2020-06-18T14:44:05Z DEBUG librespot_playback::player] command=Load(SpotifyId { id: 165162441900530074290656498603318043408, audio_type: Track }, true, 86485)
[2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206063683 1592491446110
[2020-06-18T14:44:05Z INFO  librespot_playback::player] Loading <The Color Purple: Main Title> with Spotify URI <spotify:track:3MsOo0SIZYib9mfalJvKSc>
[2020-06-18T14:44:05Z DEBUG librespot_core::audio_key] new AudioKeyManager
[2020-06-18T14:44:05Z DEBUG librespot_audio::fetch] Downloading file b44263f5a17f01e81fe73c8651e73d78590286cc
[2020-06-18T14:44:05Z DEBUG librespot_core::channel] new ChannelManager
[2020-06-18T14:44:05Z WARN  librespot_playback::player] Reducing normalisation factor to prevent clipping. Please add negative pregain to avoid.
[2020-06-18T14:44:05Z DEBUG librespot_playback::player] Normalisation Data: NormalisationData { track_gain_db: 1.9099998, track_peak: 0.96435523, album_gain_db: 2.579998, album_peak: 1.0188758 }
[2020-06-18T14:44:05Z DEBUG librespot_playback::player] Applied normalisation factor: 1.0369623
[2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206063914 1592491446341
[2020-06-18T14:44:06Z INFO  librespot_playback::player] <The Color Purple: Main Title> loaded
[2020-06-18T14:44:06Z DEBUG librespot_playback::player] command=Stop
[2020-06-18T14:44:25Z DEBUG librespot_connect::spirc] kMessageTypePause "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206083669 1592491446341
Originally created by @Johannesd3 on GitHub (Jun 18, 2020). Original GitHub issue: https://github.com/librespot-org/librespot/issues/497 Playing a song with librespot from my Android Spotify app doesn't work. After playing a song in the app and switching to the librespot client, the Android app and the web client still show the song as playing, but librespot produces no sound. When I press pause (or do any other action like increasing volume) on my phone, the playback appears as stopped. In the Web Client everything works fine. Here's the log of librespot. The command=stop in the second last line seems quite suspicious to me and might be the cause: ```[2020-06-18T14:43:29Z DEBUG librespot_connect::spirc] kMessageTypeNotify "Some other Device" e86f6fdd51b4a33cec684106f659a165ab03ff80 1206027380 1592491409807 [2020-06-18T14:43:47Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206045774 1592491428201 [2020-06-18T14:43:52Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206051183 1592491433610 [2020-06-18T14:43:57Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206055368 1592491437795 [2020-06-18T14:44:00Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206058649 1592491441076 [2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] kMessageTypeLoad "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206063633 1592491441076 [2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] State: context_uri: "spotify:album:7fYlJ1HNLfs6JIvJCJ2rqq" index: 0 position_ms: 86485 status: kPlayStatusPlay position_measured_at: 1592491446088 context_description: "" shuffle: false repeat: false playing_from_fallback: true row: 0 playing_track_index: 0 track {gid: "|A!\026\321\222O\252\222\245\240\371\211\327\343\020"} track {gid: "n\227`\315x\352K\335\216\016\000\302L_1$"} track {gid: "\337UY\305Q\306L\236\252\367\022\347\353\244T\360"} track {gid: "\373\210rq\213\271@G\274\340\276\216\270\005\333\311"} track {gid: "\205K\253\235#XK\305\211\205\223H\221\241e\243"} track {gid: "\020\225\2458\001\264BC\250\203\315g\247{\177\002"} track {gid: "\316\361yC\343\366H\335\277\177\007\241\375\327[u"} track {gid: ":U+J\326\004I\320\250H\361O\310\343\310\257"} track {gid: "\000\231)\n\3232BB\275\356 7\271Ooj"} track {gid: "\017\245ir\370\315C\317\245\315\371~\374,#\250"} track {gid: "\361\031\223\006x\302J\200\230tc\231\266b;\320"} track {gid: "Z\227w@\031:L$\224\025\\\3749]\033s"} track {gid: "\033\303?x\232LC\265\217j\213\231\236\367\207\370"} [2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] Frame has 13 tracks [2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] Loading context: <spotify:album:7fYlJ1HNLfs6JIvJCJ2rqq> index: [0] of 13 [2020-06-18T14:44:05Z DEBUG librespot_playback::player] command=Load(SpotifyId { id: 165162441900530074290656498603318043408, audio_type: Track }, true, 86485) [2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206063683 1592491446110 [2020-06-18T14:44:05Z INFO librespot_playback::player] Loading <The Color Purple: Main Title> with Spotify URI <spotify:track:3MsOo0SIZYib9mfalJvKSc> [2020-06-18T14:44:05Z DEBUG librespot_core::audio_key] new AudioKeyManager [2020-06-18T14:44:05Z DEBUG librespot_audio::fetch] Downloading file b44263f5a17f01e81fe73c8651e73d78590286cc [2020-06-18T14:44:05Z DEBUG librespot_core::channel] new ChannelManager [2020-06-18T14:44:05Z WARN librespot_playback::player] Reducing normalisation factor to prevent clipping. Please add negative pregain to avoid. [2020-06-18T14:44:05Z DEBUG librespot_playback::player] Normalisation Data: NormalisationData { track_gain_db: 1.9099998, track_peak: 0.96435523, album_gain_db: 2.579998, album_peak: 1.0188758 } [2020-06-18T14:44:05Z DEBUG librespot_playback::player] Applied normalisation factor: 1.0369623 [2020-06-18T14:44:05Z DEBUG librespot_connect::spirc] kMessageTypeNotify "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206063914 1592491446341 [2020-06-18T14:44:06Z INFO librespot_playback::player] <The Color Purple: Main Title> loaded [2020-06-18T14:44:06Z DEBUG librespot_playback::player] command=Stop [2020-06-18T14:44:25Z DEBUG librespot_connect::spirc] kMessageTypePause "My Android phone" 02aebb2e36129b4fb125042cb4746ee29f3085b2 1206083669 1592491446341 ```
kerem closed this issue 2026-02-27 19:29:58 +03:00
Author
Owner

@malaakso commented on GitHub (Jun 22, 2020):

Same here, except by skipping to next track I get sound from both phone and librespot at the same time. Web client seems to work for me as well.

<!-- gh-comment-id:647494154 --> @malaakso commented on GitHub (Jun 22, 2020): Same here, except by skipping to next track I get sound from _both_ phone and librespot at the same time. Web client seems to work for me as well.
Author
Owner

@pejobo commented on GitHub (Jun 28, 2020):

Same for me
Was working with Android App v8.5.40.195, not working with App version v8.5.42.812 (same behavior as described above).
Installed old version from here as temporary fix: https://spotify.de.uptodown.com/android/download/2168218

<!-- gh-comment-id:650718143 --> @pejobo commented on GitHub (Jun 28, 2020): Same for me Was working with Android App v8.5.40.195, not working with App version v8.5.42.812 (same behavior as described above). Installed old version from here as temporary fix: https://spotify.de.uptodown.com/android/download/2168218
Author
Owner

@Johannesd3 commented on GitHub (Jul 3, 2020):

I did a little further research and think I figured it out:
When selecting librespot in the Android App, the app sends a command to librespot to load the track. However, shortly after this command, the app sends some kind of status update (kMessageTypeNotify), claiming still to be active. But when Librespot receives this status update it immediately stops playing, believing the Android app is currently playing. This happens in spirc.rs, line 793.

I also found a possible fix/workaround. The device state contains the information of when it became active. One could compare them in line 793 to check which client became most recently active:
if self.device.get_is_active() && frame.get_device_state().get_is_active() && self.device.get_became_active_at() <= frame.get_device_state().get_became_active_at() {
At least for me it works. But since I do not know much about Spotify and this project, someone else should also take a look.

<!-- gh-comment-id:653270238 --> @Johannesd3 commented on GitHub (Jul 3, 2020): I did a little further research and think I figured it out: When selecting librespot in the Android App, the app sends a command to librespot to load the track. However, shortly after this command, the app sends some kind of status update (kMessageTypeNotify), claiming still to be active. But when Librespot receives this status update it immediately stops playing, believing the Android app is currently playing. This happens in [spirc.rs, line 793](https://github.com/librespot-org/librespot/blob/e8ec5feb2260e9d2e3b8bfc927cc5211d626e015/connect/src/spirc.rs#L793). I also found a possible fix/workaround. The device state contains the information of when it became active. One could compare them in line 793 to check which client became most recently active: `if self.device.get_is_active() && frame.get_device_state().get_is_active() && self.device.get_became_active_at() <= frame.get_device_state().get_became_active_at() { ` At least for me it works. But since I do not know much about Spotify and this project, someone else should also take a look.
Author
Owner

@jaisor commented on GitHub (Jul 12, 2020):

Same here as well

<!-- gh-comment-id:657292529 --> @jaisor commented on GitHub (Jul 12, 2020): Same here as well
Author
Owner

@Mitschmaster commented on GitHub (Jul 17, 2020):

https://github.com/librespot-org/librespot/issues/497#issuecomment-653270238 fix solves the problem for me

<!-- gh-comment-id:660161299 --> @Mitschmaster commented on GitHub (Jul 17, 2020): https://github.com/librespot-org/librespot/issues/497#issuecomment-653270238 fix solves the problem for me
Author
Owner

@sashahilton00 commented on GitHub (Jul 22, 2020):

Feel free to create a PR for the fix

<!-- gh-comment-id:662475038 --> @sashahilton00 commented on GitHub (Jul 22, 2020): Feel free to create a PR for the fix
Author
Owner

@sashahilton00 commented on GitHub (Jul 22, 2020):

Closed by #501

<!-- gh-comment-id:662495383 --> @sashahilton00 commented on GitHub (Jul 22, 2020): Closed by #501
Author
Owner

@ah- commented on GitHub (Aug 31, 2020):

Thanks everyone for fixing this, finally the Android app just works!

<!-- gh-comment-id:684044983 --> @ah- commented on GitHub (Aug 31, 2020): Thanks everyone for fixing this, finally the Android app just works!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#313
No description provided.