Class PlayerApi

java.lang.Object
de.sonallux.spotify.api.apis.PlayerApi

public class PlayerApi extends Object
Player
  • Constructor Details

    • PlayerApi

      public PlayerApi()
  • Method Details

    • addToQueue

      public AddToQueueRequest addToQueue(String uri)

      Add Item to Playback Queue

      Add an item to the end of the user's current playback queue. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      Parameters:
      uri -

      The uri of the item to add to the queue. Must be a track or an episode uri.

      Returns:
      a AddToQueueRequest object to build and execute the request
    • getInformationAboutUsersCurrentPlayback

      public GetInformationAboutUsersCurrentPlaybackRequest getInformationAboutUsersCurrentPlayback()

      Get Playback State

      Get information about the user’s current playback state, including track or episode, progress, and active device.

      Returns:
      a GetInformationAboutUsersCurrentPlaybackRequest object to build and execute the request
    • getQueue

      public GetQueueRequest getQueue()

      Get the User's Queue

      Get the list of objects that make up the user's queue.

      Returns:
      a GetQueueRequest object to build and execute the request
    • getRecentlyPlayed

      public GetRecentlyPlayedRequest getRecentlyPlayed()

      Get Recently Played Tracks

      Get tracks from the current user's recently played tracks. Note: Currently doesn't support podcast episodes.

      Returns:
      a GetRecentlyPlayedRequest object to build and execute the request
    • getUsersAvailableDevices

      public GetUsersAvailableDevicesRequest getUsersAvailableDevices()

      Get Available Devices

      Get information about a user’s available Spotify Connect devices. Some device models are not supported and will not be listed in the API response.

      Returns:
      a GetUsersAvailableDevicesRequest object to build and execute the request
    • getUsersCurrentlyPlayingTrack

      public GetUsersCurrentlyPlayingTrackRequest getUsersCurrentlyPlayingTrack()

      Get Currently Playing Track

      Get the object currently being played on the user's Spotify account.

      Returns:
      a GetUsersCurrentlyPlayingTrackRequest object to build and execute the request
    • pauseUsersPlayback

      public PauseUsersPlaybackRequest pauseUsersPlayback()

      Pause Playback

      Pause playback on the user's account. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      Returns:
      a PauseUsersPlaybackRequest object 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. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      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 SeekToPositionInCurrentlyPlayingTrackRequest object to build and execute the request
    • setRepeatModeOnUsersPlayback

      public SetRepeatModeOnUsersPlaybackRequest setRepeatModeOnUsersPlayback(String state)

      Set Repeat Mode

      Set the repeat mode for the user's playback. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      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 SetRepeatModeOnUsersPlaybackRequest object to build and execute the request
    • setVolumeForUsersPlayback

      public SetVolumeForUsersPlaybackRequest setVolumeForUsersPlayback(int volumePercent)

      Set Playback Volume

      Set the volume for the user’s current playback device. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      Parameters:
      volumePercent -

      The volume to set. Must be a value from 0 to 100 inclusive.

      Returns:
      a SetVolumeForUsersPlaybackRequest object to build and execute the request
    • skipUsersPlaybackToNextTrack

      public SkipUsersPlaybackToNextTrackRequest skipUsersPlaybackToNextTrack()

      Skip To Next

      Skips to next track in the user’s queue. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      Returns:
      a SkipUsersPlaybackToNextTrackRequest object to build and execute the request
    • skipUsersPlaybackToPreviousTrack

      public SkipUsersPlaybackToPreviousTrackRequest skipUsersPlaybackToPreviousTrack()

      Skip To Previous

      Skips to previous track in the user’s queue. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      Returns:
      a SkipUsersPlaybackToPreviousTrackRequest object to build and execute the request
    • startUsersPlayback

      public StartUsersPlaybackRequest startUsersPlayback()

      Start/Resume Playback

      Start a new context or resume current playback on the user's active device. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      Returns:
      a StartUsersPlaybackRequest object to build and execute the request
    • toggleShuffleForUsersPlayback

      public ToggleShuffleForUsersPlaybackRequest toggleShuffleForUsersPlayback(boolean state)

      Toggle Playback Shuffle

      Toggle shuffle on or off for user’s playback. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      Parameters:
      state -

      true : Shuffle user's playback.
      false : Do not shuffle user's playback.

      Returns:
      a ToggleShuffleForUsersPlaybackRequest object to build and execute the request
    • transferUsersPlayback

      public TransferUsersPlaybackRequest transferUsersPlayback(List<String> deviceIds)

      Transfer Playback

      Transfer playback to a new device and optionally begin playback. This API only works for users who have Spotify Premium. The order of execution is not guaranteed when you use this API with other Player API endpoints.

      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 return 400 Bad Request

      Returns:
      a TransferUsersPlaybackRequest object to build and execute the request