Class PlayerApi

    • Constructor Detail

      • PlayerApi

        public PlayerApi()
    • Method Detail

      • addToQueue

        public AddToQueueRequest addToQueue​(String uri)

        Add an item to 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 AddToQueueRequest object to build and execute the request
      • getRecentlyPlayed

        public GetRecentlyPlayedRequest getRecentlyPlayed()

        Get Current User's 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
      • seekToPositionInCurrentlyPlayingTrack

        public SeekToPositionInCurrentlyPlayingTrackRequest seekToPositionInCurrentlyPlayingTrack​(int positionMs)

        Seek To Position In Currently Playing Track

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

        public SetRepeatModeOnUsersPlaybackRequest setRepeatModeOnUsersPlayback​(String state)

        Set Repeat Mode On User’s Playback

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

        public SetVolumeForUsersPlaybackRequest setVolumeForUsersPlayback​(int volumePercent)

        Set Volume For User's Playback

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

        public StartUsersPlaybackRequest startUsersPlayback()

        Start/Resume a User's Playback

        Start a new context or resume current playback on the user's active device.

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

        public ToggleShuffleForUsersPlaybackRequest toggleShuffleForUsersPlayback​(boolean state)

        Toggle Shuffle For User’s Playback

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

        public TransferUsersPlaybackRequest transferUsersPlayback​(List<String> deviceIds)

        Transfer a User's 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 return 400 Bad Request

        Returns:
        a TransferUsersPlaybackRequest object to build and execute the request