spotify / web-api

This issue tracker is no longer used. Join us in the Spotify for Developers forum for support with the Spotify Web API ➡️ https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer
981 stars 79 forks source link

GET /v1/me/player/currently-playing returns incorrect information #821

Open artechventure opened 6 years ago

artechventure commented 6 years ago

Issue found on 3/16 2018.

Endpoint(s):

Scope(s):

Steps to reproduce:

  1. Start playing a track in the Spotify client.
  2. Make an authenticated call with the correct scopes to one of the above endpoints (for example, using the API Console)
  3. Check the response to see if it matches the song currently playing in the Spotify client.

Expected behaviour:

The response contains accurate information about what is currently playing in the Spotify client.

Actual behaviour:

The response contains incorrect information. -> The respones is correct when just started streaming -> When I change song A to B, the response is still song A -> When I pause song A, the response is still song A with is_playing status true.( when paused, response should be none ), -> Is_playing value is often false when playing

=> It works again when log out, and log in again the spotify client, but often happens again

artechventure commented 6 years ago

this is very critical for my app, and our users:( I have no idea why and when this happens.

artechventure commented 6 years ago

@hughrawlinson any help here plz? :(

artechventure commented 6 years ago

@hughrawlinson Today, I figured out(not sure) that It was not a spotify account's problem. I tried another account on my device, but same issue happened. What I figured out was, this issue depends on device and Spotify app version installed on a device, rather than a account's problem. When I deleted Spotify on my iphone and installed again, the issue was solved completely!

JoaaoVerona commented 6 years ago

+1. This started happening recently to me, too.

artechventure commented 6 years ago

@hughrawlinson Any comments here? I think it is a critical issue for 3rd party apps. Reinstalling spotify app can be a solution, but I can't tell every users in my app to do it. I don't understand why you guys ignoring this issue.

ydrolet commented 6 years ago

In my prototype app, I have a similar issue. After receiving a success response of a next track request (/v1/me/player/next), I make immediately a user's currently playing track request (/v1/me/player/currently-playing). 90% of the time, the received track is wrong. It stays the previous track that was played. Here's a simple snippet that shows the idea :

const headers = {
  Accept: 'application/json',
  'Content-Type': 'application/json',
  Authorization: `Bearer ${accessToken}`,
};

axios.post('https://api.spotify.com/v1/me/player/next', {}, { headers })
  .then((response) => {
    if (response.status === 204) {
      axios.get('https://api.spotify.com/v1/me/player/currently-playing', { headers })
        .then((playingTrackRes) => {
          if (playingTrackRes.status === 200) {
            // playingTrackRes.data returns an incorrect currently playing track
          }
        });
    }
  });

I noticed that putting a 1 second delay before requesting the currently playing track (/v1/me/player/currently-playing) returns the correct currently playing track.

hughrawlinson commented 6 years ago

Hi @artechventure, sorry for the delay. Can you confirm what version of the Spotify App you were using, and on what platform?

JoaaoVerona commented 6 years ago

@hughrawlinson Since it's been happening to me too, I'll also try to provide feedback...

I haven't noticed this happening on Android Spotify 8.4.52.812, but on Linux Spotify 1.0.79.223, it does happens.

Also, sometimes, I start playing songs on my Linux Spotify client and the /me/player/currently-playing simply won't ever give me my currently playing track (204 response code) until I restart the client.

Edit: If this bug happens again (which is not that rare), I'll try asking some of my friends if my currently playing track correctly shows on their friend feed (so that we can differentiate if the bug is probably on the desktop client or within the Web API).

ydrolet commented 6 years ago

@hughrawlinson In my case, the Spotify player playing the track is the player of the Web Playback SDK, used in Chrome on Linux. The version of the Web Playback SDK was the version available via CDN on April 15.

scottlow commented 6 years ago

@hughrawlinson I can consistently reproduce this as well on several clients (I implemented a device picker into my application to test):

The issue reproduces less often (~50% of the time) on the latest version of the Web Player for Chrome.

For now, I'm using @ydrolet's suggestion of adding a setTimeout before making the call to /v1/me/player/currently-playing, but it'd be great to get this fixed to avoid arbitrary delays in third party code.

michaelherger commented 5 years ago

Just to add my observation: I got the 204 status for me/player, too. Then I fired up Spotify on my Mac (1.0.75.483.g7ff4a0dc), and instantly the API would return the correct response again.

I've been testing the API using the curl command from the API documentation:

curl -X "GET" "https://api.spotify.com/v1/me/player" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer -------"

GranPC commented 5 years ago

I'm seeing the same issue. Some observations:

I signed into my other user's other account via my web browser and started playing a song remotely on her Linux PC. Suddenly, her computer appears as active in the devices endpoint and everything works great. Let's see if it continues to work tomorrow!

GranPC commented 5 years ago

Update! As expected, it broke again today after restarting the machine. The API was serving up stale data.

Interestingly enough, when I signed into the Web Player, it was showing the same stale data in the playback status. I suspect this isn't an issue with the API per se, but with Spotify Connect. Once again, initiating playback from the web player and then passing control to the Linux client made the API start working.

GranPC commented 5 years ago

Update 2! Today the application started working randomly. After I did some research, I learnt that my user had opened up Spotify on her Android phone. The Linux client started showing that device under Spotify Connect, and upon playback of the next track, it started sending out information about what's playing.

After a while, Spotify on the Android device was killed and the Linux client stopped sending out information about which track was playing - so the API started serving up stale data. I signed into the account from my phone and the playback information shown there was stale, as well. As soon as the next track started playing, everything started syncing seamlessly.

So I'm pretty sure that the bug here is that some clients don't ever update their Spotify Connect status unless there's another device.

michaelherger commented 5 years ago

@GranPC would you know whether this user is running an outdated Spotify client on his computer? Or some unofficial client?

JoaaoVerona commented 5 years ago

@michaelherger This problem also happens with me, and I'm using an updated version (1.0.92.390).

I'm using a re-packaged version of Spotify (since, for Linux-based distros, there's only an "official" .deb package only), provided by negativo17 as a .rpm package.

But, this problem also happens with other users that run Spotify on Windows, for example (updated versions too). So I doubt this bug happens because of outdated version or unofficial client usage.

michaelherger commented 5 years ago

Thanks @BloodShura. Good to know!

GranPC commented 5 years ago

In my user's case they're using the official Spotify deb. Not sure what version, but I know the system is up to date so probably the latest one.

GranPC commented 5 years ago

Possibly my final update. My user's computer died and they replaced it with a new Linux box, with a fresh Spotify install. The API seems to work flawlessly now - no need to login with another device to get it working. :woman_shrugging: