[GH-ISSUE #754] How to start playback on a device that was used by another spotify user before #458

Open
opened 2026-02-27 23:22:44 +03:00 by kerem · 1 comment
Owner

Originally created by @tikeyknax on GitHub (Dec 10, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/754

I have several spotify users in the house that all want to play music on the same Yamaha MusicCast boxes. From the spotify Android and Desktop Apps, this works fine. So if user A was playing on a device, user B can select the same device and start playing there. This automatically stops the music from user A if it is still playing.

However, this doesn't seem to work with spotipy. If user A was playing something on a device and user B wants to use that device via spotipy, there is an error "Device not found". This even happens when user A has already stopped playing music on the device.

I'm using the following code:

import spotipy
from spotipy.oauth2 import SpotifyOAuth

scope = "user-read-playback-state,user-modify-playback-state"
sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(scope=scope))
print(sp.me())


def show_devices():
    # Shows playing devices
    res = sp.devices()
    for d in res["devices"]:
        print(f"{d['name']}: {d['id']}")


if __name__ == '__main__':
    show_devices()
    sp.start_playback(
        device_id="055a55a152a33ae1fec9bc657e83091d2ab31c28",
        uris=["spotify:track:2R6UrJ8uWbSIiHWmvRQvN8"])

So with that code, if user B was previously playing something on the device, that device is listed with show_devices() and the playback works. However, if user A was previously playing something on the device, the same code doesn't work. The device is not listed with show_devices() and start_playback() gives the error: ERROR:spotipy.client:HTTP Error for PUT to https://api.spotify.com/v1/me/player/play?device_id=055a55a152a33ae1fec9bc657e83091d2ab31c28 with Params: {} returned 404 due to Device not found

Any idea what the problem is and how I could solve this?

Originally created by @tikeyknax on GitHub (Dec 10, 2021). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/754 I have several spotify users in the house that all want to play music on the same Yamaha MusicCast boxes. From the spotify Android and Desktop Apps, this works fine. So if user A was playing on a device, user B can select the same device and start playing there. This automatically stops the music from user A if it is still playing. However, this doesn't seem to work with spotipy. If user A was playing something on a device and user B wants to use that device via spotipy, there is an error "Device not found". This even happens when user A has already stopped playing music on the device. I'm using the following code: ``` import spotipy from spotipy.oauth2 import SpotifyOAuth scope = "user-read-playback-state,user-modify-playback-state" sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(scope=scope)) print(sp.me()) def show_devices(): # Shows playing devices res = sp.devices() for d in res["devices"]: print(f"{d['name']}: {d['id']}") if __name__ == '__main__': show_devices() sp.start_playback( device_id="055a55a152a33ae1fec9bc657e83091d2ab31c28", uris=["spotify:track:2R6UrJ8uWbSIiHWmvRQvN8"]) ``` So with that code, if user B was previously playing something on the device, that device is listed with show_devices() and the playback works. However, if user A was previously playing something on the device, the same code doesn't work. The device is not listed with show_devices() and start_playback() gives the error: ERROR:spotipy.client:HTTP Error for PUT to https://api.spotify.com/v1/me/player/play?device_id=055a55a152a33ae1fec9bc657e83091d2ab31c28 with Params: {} returned 404 due to Device not found Any idea what the problem is and how I could solve this?
Author
Owner

@tikeyknax commented on GitHub (Dec 16, 2021):

I assume that the issue is due to the restriction mentioned here: https://developer.spotify.com/documentation/web-api/guides/using-connect-web-api/#devices-not-appearing-on-device-list

Are there any ideas how to work around that restriction?

<!-- gh-comment-id:996156917 --> @tikeyknax commented on GitHub (Dec 16, 2021): I assume that the issue is due to the restriction mentioned here: https://developer.spotify.com/documentation/web-api/guides/using-connect-web-api/#devices-not-appearing-on-device-list Are there any ideas how to work around that restriction?
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/spotipy#458
No description provided.