android-sdk icon indicating copy to clipboard operation
android-sdk copied to clipboard

Same Player State is emitted multiple times on subscription

Open sinan-kalkan opened this issue 4 years ago • 2 comments

Player state subscription always emits same events multiple times to my app. Please see the logs:

2020-04-19 22:23:30.361 14515-14515/com.app.sini.sinify D/SPOTIFY_APP_REMOTE: Message from Spotify: [36,10,43,{},[],{"context_uri":"spotify:playlist:37i9dQZF1DX2sUQwD7tbmL","track":{"artist":{"name":"Still Woozy","type":"artist","uri":"spotify:artist:4iMO20EPodreIaEl8qW66y"},"artists":[{"name":"Still Woozy","type":"artist","uri":"spotify:artist:4iMO20EPodreIaEl8qW66y"}],"album":{"name":"Goodie Bag","type":"album","uri":"spotify:album:31u58iuxrUOJeKJj4SKqOl"},"saved":false,"duration_ms":146390,"name":"Goodie Bag","uri":"spotify:track:297rZsBEjFw9d0Gl3iBLnd","image_id":"spotify:image:ab67616d0000b2735ddbd61ea4a6dab213cc97af","is_episode":false,"is_podcast":false},"is_paused":false,"playback_speed":1.0,"playback_position":53,"playback_options":{"shuffle":false,"repeat":0},"playback_restrictions":{"can_skip_next":true,"can_skip_prev":true,"can_repeat_track":true,"can_repeat_context":true,"can_toggle_shuffle":true,"can_seek":true}}] 2020-04-19 22:23:30.362 14515-14515/com.app.sini.sinify D/SPOTIFY_APP_REMOTE: Message from Spotify: [36,10,44,{},[],{"context_uri":"spotify:playlist:37i9dQZF1DX2sUQwD7tbmL","track":{"artist":{"name":"Still Woozy","type":"artist","uri":"spotify:artist:4iMO20EPodreIaEl8qW66y"},"artists":[{"name":"Still Woozy","type":"artist","uri":"spotify:artist:4iMO20EPodreIaEl8qW66y"}],"album":{"name":"Goodie Bag","type":"album","uri":"spotify:album:31u58iuxrUOJeKJj4SKqOl"},"saved":false,"duration_ms":146390,"name":"Goodie Bag","uri":"spotify:track:297rZsBEjFw9d0Gl3iBLnd","image_id":"spotify:image:ab67616d0000b2735ddbd61ea4a6dab213cc97af","is_episode":false,"is_podcast":false},"is_paused":false,"playback_speed":1.0,"playback_position":53,"playback_options":{"shuffle":false,"repeat":0},"playback_restrictions":{"can_skip_next":true,"can_skip_prev":true,"can_repeat_track":true,"can_repeat_context":true,"can_toggle_shuffle":true,"can_seek":true}}] 2020-04-19 22:23:30.371 14515-14515/com.app.sini.sinify D/SPOTIFY_APP_REMOTE: Message from Spotify: [36,10,45,{},[],{"context_uri":"spotify:playlist:37i9dQZF1DX2sUQwD7tbmL","track":{"artist":{"name":"Still Woozy","type":"artist","uri":"spotify:artist:4iMO20EPodreIaEl8qW66y"},"artists":[{"name":"Still Woozy","type":"artist","uri":"spotify:artist:4iMO20EPodreIaEl8qW66y"}],"album":{"name":"Goodie Bag","type":"album","uri":"spotify:album:31u58iuxrUOJeKJj4SKqOl"},"saved":false,"duration_ms":146390,"name":"Goodie Bag","uri":"spotify:track:297rZsBEjFw9d0Gl3iBLnd","image_id":"spotify:image:ab67616d0000b2735ddbd61ea4a6dab213cc97af","is_episode":false,"is_podcast":false},"is_paused":false,"playback_speed":1.0,"playback_position":71,"playback_options":{"shuffle":false,"repeat":0},"playback_restrictions":{"can_skip_next":true,"can_skip_prev":true,"can_repeat_track":true,"can_repeat_context":true,"can_toggle_shuffle":true,"can_seek":true}}] 2020-04-19 22:23:30.459 14515-14515/com.app.sini.sinify D/SPOTIFY_APP_REMOTE: Message from Spotify: [36,10,46,{},[],{"context_uri":"spotify:playlist:37i9dQZF1DX2sUQwD7tbmL","track":{"artist":{"name":"Still Woozy","type":"artist","uri":"spotify:artist:4iMO20EPodreIaEl8qW66y"},"artists":[{"name":"Still Woozy","type":"artist","uri":"spotify:artist:4iMO20EPodreIaEl8qW66y"}],"album":{"name":"Goodie Bag","type":"album","uri":"spotify:album:31u58iuxrUOJeKJj4SKqOl"},"saved":false,"duration_ms":146390,"name":"Goodie Bag","uri":"spotify:track:297rZsBEjFw9d0Gl3iBLnd","image_id":"spotify:image:ab67616d0000b2735ddbd61ea4a6dab213cc97af","is_episode":false,"is_podcast":false},"is_paused":false,"playback_speed":1.0,"playback_position":159,"playback_options":{"shuffle":false,"repeat":0},"playback_restrictions":{"can_skip_next":true,"can_skip_prev":true,"can_repeat_track":true,"can_repeat_context":true,"can_toggle_shuffle":true,"can_seek":true}}]

Issue found on 04/19/20.

SDK Version: 0.7.0

OS Version: 10

Scope(s): app-remote-control

Steps to reproduce:

  1. Subscribe to player state with subscribeToPlayerState()
  2. Open Spotify app and click next track

Expected behaviour:

Player state is emitted once on next clicked in Spotify app

Actual behaviour:

Player state event is emitted multiple times for the same player state / track (pls see logs)

sinan-kalkan avatar Apr 19 '20 20:04 sinan-kalkan

I can confirm I also have this issue. More specifically, when changing songs, a new PlayerState is emitted exactly 4 times, every time in my case. As the behaviour is this preditable, one can work around it with a simple counter in combination with Thread.sleep(long). When pausing and resuming songs, the PlayerState is emitted once (as expected).

EDIT: I was wrong, as I assumed that the events are processed in parallel, although they are in fact processed consecutively. This does make it harder to find a workaround, I haven't been able to find one that is adequate for my app.

aleksandar-vuckovic avatar Apr 30 '20 00:04 aleksandar-vuckovic

I have the same problem any solutions ?

uptotec avatar Aug 09 '20 12:08 uptotec