Skip to content

Player

Module with the player endpoint

Player (Endpoint)

Player endpoint

Source code in async_spotify/api/_endpoints/player.py
class Player(Endpoint):
    """
    Player endpoint
    """

    async def get_devices(self, auth_token: SpotifyAuthorisationToken = None) -> dict:
        """
        Get information about a user’s available devices.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/get-a-users-available-devices/](https://developer.spotify.com/documentation/web-api/reference/player/get-a-users-available-devices/)

        Args:
            auth_token: The auth token if you set the api class not to keep the token in memory

        Returns:
            The available devices
        """

        return await self.api_request_handler.make_request('GET', URLS.PLAYER.DEVICES, {}, auth_token)

    async def get_queue(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> dict:
        """
        Get information about the user’s current playback state, including track or episode, progress,
        and active device.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/get-information-about-the-users-current-playback/](https://developer.spotify.com/documentation/web-api/reference/player/get-information-about-the-users-current-playback/)

        Args:
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args

        Returns:
            The top tracks and artists
        """

        return await self.api_request_handler.make_request('GET', URLS.PLAYER.PLAYER, kwargs, auth_token)

    async def add_to_queue(self, spotify_id: str, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Add an item to the end of the user’s current playback queue

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/](https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/)

        Args:
            spotify_id: A spotify id of an item
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        args: dict = {
            'uri': spotify_id,
            **kwargs
        }

        await self.api_request_handler.make_request('POST', URLS.PLAYER.QUEUE, args, auth_token)

    async def add_multiple_tracks_to_queue(self, spotify_id_list: List[str],
                                           auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Add items to the end of the user’s current playback queue

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/](https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/)

        Args:
            spotify_id_list: A spotify id list of an item
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        for spotify_id in spotify_id_list:
            args: dict = {
                'uri': spotify_id,
                **kwargs
            }

            await self.api_request_handler.make_request('POST', URLS.PLAYER.QUEUE, args, auth_token)

    async def get_recent_tracks(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> dict:
        """
        Get the Current User's Recently Played Tracks

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/get-recently-played/](https://developer.spotify.com/documentation/web-api/reference/player/get-recently-played/)

        Args:
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args

        Returns:
            The recent tracks
        """

        return await self.api_request_handler.make_request('GET', URLS.PLAYER.RECENTLY, kwargs, auth_token)

    async def get_current_track(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> dict:
        """
        Get the User's Currently Playing Track

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/get-the-users-currently-playing-track/](https://developer.spotify.com/documentation/web-api/reference/player/get-the-users-currently-playing-track/)

        Args:
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args

        Returns:
            The current track
        """

        return await self.api_request_handler.make_request('GET', URLS.PLAYER.PLAYING, kwargs, auth_token)

    async def pause(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Pause playback on the user’s account

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/pause-a-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/pause-a-users-playback/)

        Args:
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        await self.api_request_handler.make_request('PUT', URLS.PLAYER.PAUSE, kwargs, auth_token)

    async def seek(self, position_ms: int, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Pause playback on the user’s account

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/seek-to-position-in-currently-playing-track/](https://developer.spotify.com/documentation/web-api/reference/player/seek-to-position-in-currently-playing-track/)

        Args:
            position_ms: 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.
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        args = {**{'position_ms': position_ms}, **kwargs}
        await self.api_request_handler.make_request('PUT', URLS.PLAYER.SEEK, args, auth_token)

    async def repeat(self, state: str, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Set the repeat mode for the user’s playback. Options are repeat-track, repeat-context, and off.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/set-repeat-mode-on-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/set-repeat-mode-on-users-playback/)

        Args:
            state: track, context or off.
                track will repeat the current track.
                context will repeat the current context.
                off will turn repeat off.
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        args = {**{'state': state}, **kwargs}
        await self.api_request_handler.make_request('PUT', URLS.PLAYER.REPEAT, args, auth_token)

    async def volume(self, volume_percent: int, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Set the volume for the user’s current playback device.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/set-volume-for-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/set-volume-for-users-playback/)

        Args:
            volume_percent: Integer. The volume to set. Must be a value from 0 to 100 inclusive.
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        args = {**{'volume_percent': volume_percent}, **kwargs}
        await self.api_request_handler.make_request('PUT', URLS.PLAYER.VOLUME, args, auth_token)

    async def next(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Set the volume for the user’s current playback device.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/skip-users-playback-to-next-track/](https://developer.spotify.com/documentation/web-api/reference/player/skip-users-playback-to-next-track/)

        Args:
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        await self.api_request_handler.make_request('POST', URLS.PLAYER.NEXT, kwargs, auth_token)

    async def previous(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Skips to previous track in the user’s queue.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/skip-users-playback-to-previous-track/](https://developer.spotify.com/documentation/web-api/reference/player/skip-users-playback-to-previous-track/)

        Args:
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        await self.api_request_handler.make_request('POST', URLS.PLAYER.PREVIOUS, kwargs, auth_token)

    async def play(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Start a new context or resume current playback on the user’s active device.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/)

        Args:
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        query_params = {}
        if "device_id" in kwargs:
            query_params = {'device_id': kwargs["device_id"]}

        await self.api_request_handler.make_request('PUT', URLS.PLAYER.PLAY, query_params, auth_token,
                                                    kwargs)

    async def shuffle(self, shuffle_on: bool, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
        """
        Toggle shuffle on or off for user’s playback.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/toggle-shuffle-for-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/toggle-shuffle-for-users-playback/)

        Args:
            shuffle_on: The state of the shuffle
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args
        """

        args = {**{'state': shuffle_on}, **kwargs}

        await self.api_request_handler.make_request('PUT', URLS.PLAYER.SHUFFLE, args, auth_token)

    async def transfer(self, device_id: List[str], play: bool = False,
                       auth_token: SpotifyAuthorisationToken = None) -> None:
        """
        Transfer playback to a new device and determine if it should start playing.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/player/transfer-a-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/transfer-a-users-playback/)

        Args:
            play: ensure playback happens on new device
            device_id: A SINGLE device ID
            auth_token: The auth token if you set the api class not to keep the token in memory
        """

        body = {
            "device_ids": device_id,
            "state": play
        }

        await self.api_request_handler.make_request('PUT', URLS.PLAYER.PLAYER, {}, auth_token, body=body)

add_multiple_tracks_to_queue(self, spotify_id_list, auth_token=None, **kwargs) async

Add items to the end of the user’s current playback queue

Parameters:

Name Type Description Default
spotify_id_list List[str]

A spotify id list of an item

required
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def add_multiple_tracks_to_queue(self, spotify_id_list: List[str],
                                       auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Add items to the end of the user’s current playback queue

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/](https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/)

    Args:
        spotify_id_list: A spotify id list of an item
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    for spotify_id in spotify_id_list:
        args: dict = {
            'uri': spotify_id,
            **kwargs
        }

        await self.api_request_handler.make_request('POST', URLS.PLAYER.QUEUE, args, auth_token)

add_to_queue(self, spotify_id, auth_token=None, **kwargs) async

Add an item to the end of the user’s current playback queue

Parameters:

Name Type Description Default
spotify_id str

A spotify id of an item

required
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def add_to_queue(self, spotify_id: str, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Add an item to the end of the user’s current playback queue

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/](https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/)

    Args:
        spotify_id: A spotify id of an item
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    args: dict = {
        'uri': spotify_id,
        **kwargs
    }

    await self.api_request_handler.make_request('POST', URLS.PLAYER.QUEUE, args, auth_token)

get_current_track(self, auth_token=None, **kwargs) async

Get the User's Currently Playing Track

Parameters:

Name Type Description Default
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}

Returns:

Type Description
dict

The current track

Source code in async_spotify/api/_endpoints/player.py
async def get_current_track(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> dict:
    """
    Get the User's Currently Playing Track

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/get-the-users-currently-playing-track/](https://developer.spotify.com/documentation/web-api/reference/player/get-the-users-currently-playing-track/)

    Args:
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args

    Returns:
        The current track
    """

    return await self.api_request_handler.make_request('GET', URLS.PLAYER.PLAYING, kwargs, auth_token)

get_devices(self, auth_token=None) async

Get information about a user’s available devices.

Parameters:

Name Type Description Default
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None

Returns:

Type Description
dict

The available devices

Source code in async_spotify/api/_endpoints/player.py
async def get_devices(self, auth_token: SpotifyAuthorisationToken = None) -> dict:
    """
    Get information about a user’s available devices.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/get-a-users-available-devices/](https://developer.spotify.com/documentation/web-api/reference/player/get-a-users-available-devices/)

    Args:
        auth_token: The auth token if you set the api class not to keep the token in memory

    Returns:
        The available devices
    """

    return await self.api_request_handler.make_request('GET', URLS.PLAYER.DEVICES, {}, auth_token)

get_queue(self, auth_token=None, **kwargs) async

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

Parameters:

Name Type Description Default
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}

Returns:

Type Description
dict

The top tracks and artists

Source code in async_spotify/api/_endpoints/player.py
async def get_queue(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> dict:
    """
    Get information about the user’s current playback state, including track or episode, progress,
    and active device.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/get-information-about-the-users-current-playback/](https://developer.spotify.com/documentation/web-api/reference/player/get-information-about-the-users-current-playback/)

    Args:
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args

    Returns:
        The top tracks and artists
    """

    return await self.api_request_handler.make_request('GET', URLS.PLAYER.PLAYER, kwargs, auth_token)

get_recent_tracks(self, auth_token=None, **kwargs) async

Get the Current User's Recently Played Tracks

Parameters:

Name Type Description Default
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}

Returns:

Type Description
dict

The recent tracks

Source code in async_spotify/api/_endpoints/player.py
async def get_recent_tracks(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> dict:
    """
    Get the Current User's Recently Played Tracks

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/get-recently-played/](https://developer.spotify.com/documentation/web-api/reference/player/get-recently-played/)

    Args:
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args

    Returns:
        The recent tracks
    """

    return await self.api_request_handler.make_request('GET', URLS.PLAYER.RECENTLY, kwargs, auth_token)

next(self, auth_token=None, **kwargs) async

Set the volume for the user’s current playback device.

Parameters:

Name Type Description Default
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def next(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Set the volume for the user’s current playback device.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/skip-users-playback-to-next-track/](https://developer.spotify.com/documentation/web-api/reference/player/skip-users-playback-to-next-track/)

    Args:
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    await self.api_request_handler.make_request('POST', URLS.PLAYER.NEXT, kwargs, auth_token)

pause(self, auth_token=None, **kwargs) async

Pause playback on the user’s account

Parameters:

Name Type Description Default
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def pause(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Pause playback on the user’s account

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/pause-a-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/pause-a-users-playback/)

    Args:
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    await self.api_request_handler.make_request('PUT', URLS.PLAYER.PAUSE, kwargs, auth_token)

play(self, auth_token=None, **kwargs) async

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

Parameters:

Name Type Description Default
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def play(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Start a new context or resume current playback on the user’s active device.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/start-a-users-playback/)

    Args:
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    query_params = {}
    if "device_id" in kwargs:
        query_params = {'device_id': kwargs["device_id"]}

    await self.api_request_handler.make_request('PUT', URLS.PLAYER.PLAY, query_params, auth_token,
                                                kwargs)

previous(self, auth_token=None, **kwargs) async

Skips to previous track in the user’s queue.

Parameters:

Name Type Description Default
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def previous(self, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Skips to previous track in the user’s queue.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/skip-users-playback-to-previous-track/](https://developer.spotify.com/documentation/web-api/reference/player/skip-users-playback-to-previous-track/)

    Args:
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    await self.api_request_handler.make_request('POST', URLS.PLAYER.PREVIOUS, kwargs, auth_token)

repeat(self, state, auth_token=None, **kwargs) async

Set the repeat mode for the user’s playback. Options are repeat-track, repeat-context, and off.

Parameters:

Name Type Description Default
state str

track, context or off. track will repeat the current track. context will repeat the current context. off will turn repeat off.

required
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def repeat(self, state: str, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Set the repeat mode for the user’s playback. Options are repeat-track, repeat-context, and off.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/set-repeat-mode-on-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/set-repeat-mode-on-users-playback/)

    Args:
        state: track, context or off.
            track will repeat the current track.
            context will repeat the current context.
            off will turn repeat off.
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    args = {**{'state': state}, **kwargs}
    await self.api_request_handler.make_request('PUT', URLS.PLAYER.REPEAT, args, auth_token)

seek(self, position_ms, auth_token=None, **kwargs) async

Pause playback on the user’s account

Parameters:

Name Type Description Default
position_ms int

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.

required
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def seek(self, position_ms: int, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Pause playback on the user’s account

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/seek-to-position-in-currently-playing-track/](https://developer.spotify.com/documentation/web-api/reference/player/seek-to-position-in-currently-playing-track/)

    Args:
        position_ms: 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.
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    args = {**{'position_ms': position_ms}, **kwargs}
    await self.api_request_handler.make_request('PUT', URLS.PLAYER.SEEK, args, auth_token)

shuffle(self, shuffle_on, auth_token=None, **kwargs) async

Toggle shuffle on or off for user’s playback.

Parameters:

Name Type Description Default
shuffle_on bool

The state of the shuffle

required
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def shuffle(self, shuffle_on: bool, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Toggle shuffle on or off for user’s playback.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/toggle-shuffle-for-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/toggle-shuffle-for-users-playback/)

    Args:
        shuffle_on: The state of the shuffle
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    args = {**{'state': shuffle_on}, **kwargs}

    await self.api_request_handler.make_request('PUT', URLS.PLAYER.SHUFFLE, args, auth_token)

transfer(self, device_id, play=False, auth_token=None) async

Transfer playback to a new device and determine if it should start playing.

Parameters:

Name Type Description Default
play bool

ensure playback happens on new device

False
device_id List[str]

A SINGLE device ID

required
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
Source code in async_spotify/api/_endpoints/player.py
async def transfer(self, device_id: List[str], play: bool = False,
                   auth_token: SpotifyAuthorisationToken = None) -> None:
    """
    Transfer playback to a new device and determine if it should start playing.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/transfer-a-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/transfer-a-users-playback/)

    Args:
        play: ensure playback happens on new device
        device_id: A SINGLE device ID
        auth_token: The auth token if you set the api class not to keep the token in memory
    """

    body = {
        "device_ids": device_id,
        "state": play
    }

    await self.api_request_handler.make_request('PUT', URLS.PLAYER.PLAYER, {}, auth_token, body=body)

volume(self, volume_percent, auth_token=None, **kwargs) async

Set the volume for the user’s current playback device.

Parameters:

Name Type Description Default
volume_percent int

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

required
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}
Source code in async_spotify/api/_endpoints/player.py
async def volume(self, volume_percent: int, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> None:
    """
    Set the volume for the user’s current playback device.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/player/set-volume-for-users-playback/](https://developer.spotify.com/documentation/web-api/reference/player/set-volume-for-users-playback/)

    Args:
        volume_percent: Integer. The volume to set. Must be a value from 0 to 100 inclusive.
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args
    """

    args = {**{'volume_percent': volume_percent}, **kwargs}
    await self.api_request_handler.make_request('PUT', URLS.PLAYER.VOLUME, args, auth_token)

Last update: April 27, 2020