librespot-org / librespot-java

The most up-to-date open source Spotify client
Apache License 2.0
380 stars 93 forks source link

IllegalStateException with Spotify DJ #883

Open lasley opened 6 months ago

lasley commented 6 months ago

Describe the bug

An IllegalStateException is thrown if you try to stream DJ to librespot-java

To Reproduce

  1. Run librespot-java with trace logging enabled
  2. Attempt to stream DJ to the device

Expected behavior

DJ should play

Screenshots/Stracktraces/Logs

DJ does not play, but a stacktrace is shown:

2024-03-25 14:22:03,855 TRACE DealerClient:113 - Received request. {mid: hm://connect-state/v1/player/command, key: b7802cca-0fd1-4151-882b-6b2b70b4fa10, pid: 2004740688, sender: 0127bace10a2bb72573378ec2ee75048bc309ac0, command: {"endpoint":"play","context":{"uri":"spotify:playlist:37i9dQZF1EYkqdzj48dyYq","url":"hm://lexicon-session-provider/context-resolve/v2/session?contextUri=spotify:playlist:37i9dQZF1EYkqdzj48dyYq","metadata":{"add_context_load_reason":"true","context_description":"DJ","context_owner":"spotify","format_list_type":"unknown","home.card.background_color":"#FF0A59B8","home.card.jellyfish_bottom_color":"#7F1E95D7","home.card.jellyfish_mid_color":"#CB1ED7BC","home.card.jellyfish_top_color":"#FF19E68C","home.card.tag_color":"#FF0D72EA","image_url":"","lexicon_context_url":"hm://lexicon-session-provider/context-resolve/v2/session?contextUri=spotify:playlist:37i9dQZF1EYkqdzj48dyYq","lexicon_set_type":"your_dj","playlist_number_of_episodes":"0","playlist_number_of_tracks":"0","zelda.context_uri":"spotify:playlist:37i9dQZF1EYkqdzj48dyYq"},"pages":[{"tracks":[]}],"restrictions":{}},"play_origin":{"feature_identifier":"home","feature_version":"xpui_2024-03-08_1709865429512_8ddb591","referrer_identifier":"home","device_identifier":"0127bace10a2bb72573378ec2ee75048bc309ac0"},"options":{"always_play_something":false,"skip_to":{},"initially_paused":false,"system_initiated":false,"player_options_override":{"shuffling_context":false},"suppressions":{},"prefetch_level":"none","audio_stream":"default","session_id":"1BxbnGrpIXx7av1LTkNjUF","license":"premium"},"play_options":{"override_restrictions":false,"only_for_local_device":false,"system_initiated":false,"reason":"interactive","operation":"replace","trigger":"immediately"},"logging_params":{"command_initiated_time":1711401723479,"page_instance_ids":["e7581547-6d4f-4546-8267-e90cf76fc39a"],"interaction_ids":["7db6a6a7-d397-4fe7-9609-4c04f44541d6"],"device_identifier":"0127bace10a2bb72573378ec2ee75048bc309ac0","command_id":"d46ccabb87f858c619bcbd4c877e0767"}}}
2024-03-25 14:22:03,856 DEBUG Player:107 - Received command: Play
2024-03-25 14:22:03,856 DEBUG Player:516 - Loading context (play), uri: spotify:playlist:37i9dQZF1EYkqdzj48dyYq
2024-03-25 14:22:03,863 WARN  StateWrapper:566 - Failed initializing tracks, falling back to start. {uri: null, uid: null, index: null}
2024-03-25 14:22:03,863 ERROR DealerClient:128 - Failed handling request. {key: b7802cca-0fd1-4151-882b-6b2b70b4fa10}
java.lang.IllegalStateException: null
    at xyz.gianlu.librespot.player.StateWrapper$TracksKeeper.initializeStart(StateWrapper.java:1096) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at xyz.gianlu.librespot.player.StateWrapper.load(StateWrapper.java:567) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at xyz.gianlu.librespot.player.Player.handlePlay(Player.java:519) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at xyz.gianlu.librespot.player.Player.access$400(Player.java:63) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at xyz.gianlu.librespot.player.Player$1.command(Player.java:111) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at xyz.gianlu.librespot.player.state.DeviceStateHandler.notifyCommand(DeviceStateHandler.java:130) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at xyz.gianlu.librespot.player.state.DeviceStateHandler.onRequest(DeviceStateHandler.java:188) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at xyz.gianlu.librespot.dealer.DealerClient.lambda$handleRequest$1(DealerClient.java:123) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at xyz.gianlu.librespot.common.AsyncWorker.lambda$new$0(AsyncWorker.java:36) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at xyz.gianlu.librespot.common.AsyncProcessor.lambda$submit$1(AsyncProcessor.java:56) ~[librespot-api-1.6.4-20240211.155940-84.jar:1.6.4-SNAPSHOT]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
    at java.base/java.lang.Thread.run(Thread.java:829) [?:?]

Version/Commit

Both 1.6.3 as released, and the 1.6.4 from the dev branch (commit d0ff31b4f476590c9c17401aac01a6762e4ba908)