[GH-ISSUE #728] start_playback not working properly. What am I doing wrong? #436

Closed
opened 2026-02-27 23:22:38 +03:00 by kerem · 6 comments
Owner

Originally created by @KartsaJaKoppa on GitHub (Sep 12, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/728

Hey,

I've been trying to build a voice controlled home assistant that could play music via spotify API. I have tried to play a specific song using start_playback and also directly calling https://api.spotify.com/v1/me/player/play. However every time I try to do so the player starts playing a song that I currently have paused and not the one I'm trying to specify using "context_uri" parameter.

Any help is appreciated!
Below is an example where the result is the same no matter if I change the uri:

import spotipy
from spotipy.oauth2 import SpotifyOAuth
from pprint import pprint
from time import sleep

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

sp.start_playback(uris=['spotify:track:6rqhFgbbKwnb9MLmUQDhG6'])

Originally created by @KartsaJaKoppa on GitHub (Sep 12, 2021). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/728 Hey, I've been trying to build a voice controlled home assistant that could play music via spotify API. I have tried to play a specific song using start_playback and also directly calling https://api.spotify.com/v1/me/player/play. However every time I try to do so the player starts playing a song that I currently have paused and not the one I'm trying to specify using "context_uri" parameter. Any help is appreciated! Below is an example where the result is the same no matter if I change the uri: import spotipy from spotipy.oauth2 import SpotifyOAuth from pprint import pprint from time import sleep scope = "user-read-playback-state,user-modify-playback-state" sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(scope=scope)) sp.start_playback(uris=['spotify:track:6rqhFgbbKwnb9MLmUQDhG6'])
kerem 2026-02-27 23:22:38 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@olsonap commented on GitHub (Oct 28, 2021):

Assuming you're setting your client ID and client secret values in the environment, try using the line below instead of what you have.
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))

<!-- gh-comment-id:953408456 --> @olsonap commented on GitHub (Oct 28, 2021): Assuming you're setting your client ID and client secret values in the environment, try using the line below instead of what you have. sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
Author
Owner

@Peter-Schorn commented on GitHub (Oct 28, 2021):

You claim you're using the "context_uri" parameter, but the code you posted uses the "uris" parameter. The "context_uri" parameter is used to specify the context in which to start playback, not the track/episode to play. Hence the term context. See here.

<!-- gh-comment-id:953410987 --> @Peter-Schorn commented on GitHub (Oct 28, 2021): You claim you're using the "context_uri" parameter, but the code you posted uses the "uris" parameter. The "context_uri" parameter is used to specify the *context* in which to start playback, not the track/episode to play. Hence the term context. See [here](https://web.archive.org/web/20191026192215/https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/).
Author
Owner

@Peter-Schorn commented on GitHub (Oct 28, 2021):

@olsonap That won't make any difference. auth_manager is an alias for client_credentials_manager.

<!-- gh-comment-id:953412202 --> @Peter-Schorn commented on GitHub (Oct 28, 2021): @olsonap That won't make any difference. `auth_manager` is an alias for `client_credentials_manager`.
Author
Owner

@olsonap commented on GitHub (Oct 28, 2021):

You're right. It looks like this code functions the way they want though. Perhaps they don't have spotify Premium.
.

<!-- gh-comment-id:953417877 --> @olsonap commented on GitHub (Oct 28, 2021): You're right. It looks like this code functions the way they want though. Perhaps they don't have spotify Premium. .
Author
Owner

@Peter-Schorn commented on GitHub (Oct 28, 2021):

Not having premium would result in a specific error indicating Premium is required. That's not the issue either.

<!-- gh-comment-id:953516966 --> @Peter-Schorn commented on GitHub (Oct 28, 2021): Not having premium would result in a specific error indicating Premium is required. That's not the issue either.
Author
Owner

@KartsaJaKoppa commented on GitHub (Nov 5, 2021):

You claim you're using the "context_uri" parameter, but the code you posted uses the "uris" parameter. The "context_uri" parameter is used to specify the context in which to start playback, not the track/episode to play. Hence the term context. See here.

Ahh I see, I need to specify the context and the tracks I want to play in that context. I will test this and close it out if I manage to make it work. Thank you so much! @Peter-Schorn

<!-- gh-comment-id:961906946 --> @KartsaJaKoppa commented on GitHub (Nov 5, 2021): > You claim you're using the "context_uri" parameter, but the code you posted uses the "uris" parameter. The "context_uri" parameter is used to specify the _context_ in which to start playback, not the track/episode to play. Hence the term context. See [here](https://web.archive.org/web/20191026192215/https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/). Ahh I see, I need to specify the context and the tracks I want to play in that context. I will test this and close it out if I manage to make it work. Thank you so much! @Peter-Schorn
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#436
No description provided.