Class PlayerApi
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddToQueue(String uri) Add Item to Playback QueueGet Playback StategetQueue()Get the User's QueueGet Recently Played TracksGet Available DevicesGet Currently Playing TrackPause PlaybackseekToPositionInCurrentlyPlayingTrack(int positionMs) Seek To PositionSet Repeat ModesetVolumeForUsersPlayback(int volumePercent) Set Playback VolumeSkip To NextSkip To PreviousStart/Resume PlaybacktoggleShuffleForUsersPlayback(boolean state) Toggle Playback ShuffletransferUsersPlayback(List<String> deviceIds) Transfer Playback
-
Constructor Details
-
PlayerApi
public PlayerApi()
-
-
Method Details
-
addToQueue
Add Item to Playback Queue
Add an item to the end of the user's current playback queue.
- Parameters:
uri-The uri of the item to add to the queue. Must be a track or an episode uri.
- Returns:
- a
AddToQueueRequestobject to build and execute the request
-
getInformationAboutUsersCurrentPlayback
Get Playback State
Get information about the user’s current playback state, including track or episode, progress, and active device.
- Returns:
- a
GetInformationAboutUsersCurrentPlaybackRequestobject to build and execute the request
-
getQueue
Get the User's Queue
Get the list of objects that make up the user's queue.
- Returns:
- a
GetQueueRequestobject to build and execute the request
-
getRecentlyPlayed
Get Recently Played Tracks
Get tracks from the current user's recently played tracks. Note: Currently doesn't support podcast episodes.
- Returns:
- a
GetRecentlyPlayedRequestobject to build and execute the request
-
getUsersAvailableDevices
Get Available Devices
Get information about a user’s available devices.
- Returns:
- a
GetUsersAvailableDevicesRequestobject to build and execute the request
-
getUsersCurrentlyPlayingTrack
Get Currently Playing Track
Get the object currently being played on the user's Spotify account.
- Returns:
- a
GetUsersCurrentlyPlayingTrackRequestobject to build and execute the request
-
pauseUsersPlayback
Pause Playback
Pause playback on the user's account.
- Returns:
- a
PauseUsersPlaybackRequestobject to build and execute the request
-
seekToPositionInCurrentlyPlayingTrack
public SeekToPositionInCurrentlyPlayingTrackRequest seekToPositionInCurrentlyPlayingTrack(int positionMs) Seek To Position
Seeks to the given position in the user’s currently playing track.
- Parameters:
positionMs-The position in milliseconds to seek to. Must be a positive number. Passing in a position that is greater than the length of the track will cause the player to start playing the next song.
- Returns:
- a
SeekToPositionInCurrentlyPlayingTrackRequestobject to build and execute the request
-
setRepeatModeOnUsersPlayback
Set Repeat Mode
Set the repeat mode for the user's playback. Options are repeat-track, repeat-context, and off.
- Parameters:
state-track, context or off.
track will repeat the current track.
context will repeat the current context.
off will turn repeat off.- Returns:
- a
SetRepeatModeOnUsersPlaybackRequestobject to build and execute the request
-
setVolumeForUsersPlayback
Set Playback Volume
Set the volume for the user’s current playback device.
- Parameters:
volumePercent-The volume to set. Must be a value from 0 to 100 inclusive.
- Returns:
- a
SetVolumeForUsersPlaybackRequestobject to build and execute the request
-
skipUsersPlaybackToNextTrack
Skip To Next
Skips to next track in the user’s queue.
- Returns:
- a
SkipUsersPlaybackToNextTrackRequestobject to build and execute the request
-
skipUsersPlaybackToPreviousTrack
Skip To Previous
Skips to previous track in the user’s queue.
- Returns:
- a
SkipUsersPlaybackToPreviousTrackRequestobject to build and execute the request
-
startUsersPlayback
Start/Resume Playback
Start a new context or resume current playback on the user's active device.
- Returns:
- a
StartUsersPlaybackRequestobject to build and execute the request
-
toggleShuffleForUsersPlayback
Toggle Playback Shuffle
Toggle shuffle on or off for user’s playback.
- Parameters:
state-true : Shuffle user's playback.
false : Do not shuffle user's playback.- Returns:
- a
ToggleShuffleForUsersPlaybackRequestobject to build and execute the request
-
transferUsersPlayback
Transfer Playback
Transfer playback to a new device and determine if it should start playing.
- Parameters:
deviceIds-A JSON array containing the ID of the device on which playback should be started/transferred.
For example:{device_ids:["74ASZWbe4lXaubB36ztrGX"]}
Note: Although an array is accepted, only a single device_id is currently supported. Supplying more than one will return400 Bad Request- Returns:
- a
TransferUsersPlaybackRequestobject to build and execute the request
-