Exspotify.Player (Exspotify v0.1.0)

View Source

Provides functions for interacting with the Player endpoints of the Spotify Web API. Most endpoints require a user access token with appropriate scopes and an active device. See: https://developer.spotify.com/documentation/web-api/reference/player

Summary

Functions

Add an item to the end of the user's playback queue. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

Get a list of the user's available devices. Requires: user-read-playback-state scope.

Get information about the user's currently playing track. Requires: user-read-currently-playing scope.

Get information about the user's current playback state. Requires: user-read-playback-state scope.

Get the user's current playback queue. Requires: user-read-playback-state scope.

Get the user's recently played tracks (paginated). Requires: user-read-recently-played scope.

Pause playback on the user's active device. Warning: This will pause playback for the user. Requires: user-modify-playback-state scope.

Seek to a position in the currently playing track. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

Set playback volume. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

Set repeat mode for playback. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

Skip to the next track in the user's queue. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

Skip to the previous track in the user's queue. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

Start or resume playback on the user's active device. Warning: This will start or change playback for the user. Requires: user-modify-playback-state scope.

Toggle shuffle playback. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

Transfer playback to a new device. Warning: This will change the user's active playback device. Requires: user-modify-playback-state scope.

Functions

add_to_queue(token, uri)

@spec add_to_queue(String.t(), String.t()) ::
  {:ok, any()} | {:error, Exspotify.Error.t()}

Add an item to the end of the user's playback queue. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

get_available_devices(token)

@spec get_available_devices(String.t()) ::
  {:ok, Exspotify.Structs.Devices.t()} | {:error, Exspotify.Error.t()}

Get a list of the user's available devices. Requires: user-read-playback-state scope.

get_currently_playing(token)

@spec get_currently_playing(String.t()) ::
  {:ok, Exspotify.Structs.PlaybackState.t() | nil}
  | {:error, Exspotify.Error.t()}

Get information about the user's currently playing track. Requires: user-read-currently-playing scope.

get_playback_state(token)

@spec get_playback_state(String.t()) ::
  {:ok, Exspotify.Structs.PlaybackState.t() | nil}
  | {:error, Exspotify.Error.t()}

Get information about the user's current playback state. Requires: user-read-playback-state scope.

get_queue(token)

@spec get_queue(String.t()) ::
  {:ok, Exspotify.Structs.Queue.t()} | {:error, Exspotify.Error.t()}

Get the user's current playback queue. Requires: user-read-playback-state scope.

get_recently_played(token, opts \\ [])

@spec get_recently_played(
  String.t(),
  keyword()
) :: {:ok, Exspotify.Structs.RecentlyPlayed.t()} | {:error, Exspotify.Error.t()}

Get the user's recently played tracks (paginated). Requires: user-read-recently-played scope.

pause_playback(token)

@spec pause_playback(String.t()) :: {:ok, any()} | {:error, Exspotify.Error.t()}

Pause playback on the user's active device. Warning: This will pause playback for the user. Requires: user-modify-playback-state scope.

seek_to_position(token, position_ms)

@spec seek_to_position(String.t(), integer()) ::
  {:ok, any()} | {:error, Exspotify.Error.t()}

Seek to a position in the currently playing track. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

set_playback_volume(token, volume_percent)

@spec set_playback_volume(String.t(), integer()) ::
  {:ok, any()} | {:error, Exspotify.Error.t()}

Set playback volume. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

set_repeat_mode(token, state)

@spec set_repeat_mode(String.t(), String.t()) ::
  {:ok, any()} | {:error, Exspotify.Error.t()}

Set repeat mode for playback. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

skip_to_next(token)

@spec skip_to_next(String.t()) :: {:ok, any()} | {:error, Exspotify.Error.t()}

Skip to the next track in the user's queue. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

skip_to_previous(token)

@spec skip_to_previous(String.t()) :: {:ok, any()} | {:error, Exspotify.Error.t()}

Skip to the previous track in the user's queue. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

start_playback(token, body \\ %{})

@spec start_playback(String.t(), map()) ::
  {:ok, any()} | {:error, Exspotify.Error.t()}

Start or resume playback on the user's active device. Warning: This will start or change playback for the user. Requires: user-modify-playback-state scope.

toggle_shuffle(token, state)

@spec toggle_shuffle(String.t(), boolean()) ::
  {:ok, any()} | {:error, Exspotify.Error.t()}

Toggle shuffle playback. Warning: This will change playback for the user. Requires: user-modify-playback-state scope.

transfer_playback(token, device_ids)

@spec transfer_playback(String.t(), [String.t()]) ::
  {:ok, any()} | {:error, Exspotify.Error.t()}

Transfer playback to a new device. Warning: This will change the user's active playback device. Requires: user-modify-playback-state scope.