Player

class spotify.player.Player(session)[source]

Playback controller.

You’ll never need to create an instance of this class yourself. You’ll find it ready to use as the player attribute on the Session instance.

state = u'unloaded'

The player state.

  • The state is initially PlayerState.UNLOADED.
  • When a track is loaded, the state changes to PlayerState.LOADED.
  • When playback is started the state changes to PlayerState.PLAYING.
  • When playback is paused the state changes to PlayerState.PAUSED.
  • When the track is unloaded the state changes to PlayerState.UNLOADED again.
load(track)[source]

Load Track for playback.

seek(offset)[source]

Seek to the offset in ms in the currently loaded track.

play(play=True)[source]

Play the currently loaded track.

This will cause audio data to be passed to the music_delivery callback.

If play is set to False, playback will be paused.

pause()[source]

Pause the currently loaded track.

This is the same as calling play() with False.

unload()[source]

Stops the currently playing track.

prefetch(track)[source]

Prefetch a Track for playback.

This can be used to make libspotify download and cache a track before playing it.

class spotify.player.PlayerState[source]
UNLOADED = u'unloaded'
LOADED = u'loaded'
PLAYING = u'playing'
PAUSED = u'paused'