Class: Spotted::Resources::Me::Player
- Inherits:
-
Object
- Object
- Spotted::Resources::Me::Player
- Defined in:
- lib/spotted/resources/me/player.rb,
lib/spotted/resources/me/player/queue.rb
Defined Under Namespace
Classes: Queue
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#get_currently_playing(additional_types: nil, market: nil, request_options: {}) ⇒ Spotted::Models::Me::PlayerGetCurrentlyPlayingResponse
Some parameter documentations has been truncated, see Models::Me::PlayerGetCurrentlyPlayingParams for more details.
-
#get_devices(request_options: {}) ⇒ Spotted::Models::Me::PlayerGetDevicesResponse
Get information about a user’s available Spotify Connect devices.
-
#get_state(additional_types: nil, market: nil, request_options: {}) ⇒ Spotted::Models::Me::PlayerGetStateResponse
Some parameter documentations has been truncated, see Models::Me::PlayerGetStateParams for more details.
-
#initialize(client:) ⇒ Player
constructor
private
A new instance of Player.
-
#list_recently_played(after: nil, before: nil, limit: nil, request_options: {}) ⇒ Spotted::Internal::CursorURLPage<Spotted::Models::Me::PlayerListRecentlyPlayedResponse>
Some parameter documentations has been truncated, see Models::Me::PlayerListRecentlyPlayedParams for more details.
-
#pause_playback(device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerPausePlaybackParams for more details.
-
#seek_to_position(position_ms: , device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSeekToPositionParams for more details.
-
#set_repeat_mode(state: , device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSetRepeatModeParams for more details.
-
#set_volume(volume_percent: , device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSetVolumeParams for more details.
-
#skip_next(device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSkipNextParams for more details.
-
#skip_previous(device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSkipPreviousParams for more details.
-
#start_playback(device_id: nil, context_uri: nil, offset: nil, position_ms: nil, uris: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerStartPlaybackParams for more details.
-
#toggle_shuffle(state: , device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerToggleShuffleParams for more details.
-
#transfer(device_ids: , play: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerTransferParams for more details.
Constructor Details
#initialize(client:) ⇒ Player
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Player.
375 376 377 378 |
# File 'lib/spotted/resources/me/player.rb', line 375 def initialize(client:) @client = client @queue = Spotted::Resources::Me::Player::Queue.new(client: client) end |
Instance Attribute Details
#queue ⇒ Spotted::Resources::Me::Player::Queue (readonly)
8 9 10 |
# File 'lib/spotted/resources/me/player.rb', line 8 def queue @queue end |
Instance Method Details
#get_currently_playing(additional_types: nil, market: nil, request_options: {}) ⇒ Spotted::Models::Me::PlayerGetCurrentlyPlayingResponse
Some parameter documentations has been truncated, see Models::Me::PlayerGetCurrentlyPlayingParams for more details.
Get the object currently being played on the user’s Spotify account.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/spotted/resources/me/player.rb', line 26 def (params = {}) parsed, = Spotted::Me::PlayerGetCurrentlyPlayingParams.dump_request(params) @client.request( method: :get, path: "me/player/currently-playing", query: parsed, model: Spotted::Models::Me::PlayerGetCurrentlyPlayingResponse, options: ) end |
#get_devices(request_options: {}) ⇒ Spotted::Models::Me::PlayerGetDevicesResponse
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.
47 48 49 50 51 52 53 54 |
# File 'lib/spotted/resources/me/player.rb', line 47 def get_devices(params = {}) @client.request( method: :get, path: "me/player/devices", model: Spotted::Models::Me::PlayerGetDevicesResponse, options: params[:request_options] ) end |
#get_state(additional_types: nil, market: nil, request_options: {}) ⇒ Spotted::Models::Me::PlayerGetStateResponse
Some parameter documentations has been truncated, see Models::Me::PlayerGetStateParams for more details.
Get information about the user’s current playback state, including track or episode, progress, and active device.
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/spotted/resources/me/player.rb', line 73 def get_state(params = {}) parsed, = Spotted::Me::PlayerGetStateParams.dump_request(params) @client.request( method: :get, path: "me/player", query: parsed, model: Spotted::Models::Me::PlayerGetStateResponse, options: ) end |
#list_recently_played(after: nil, before: nil, limit: nil, request_options: {}) ⇒ Spotted::Internal::CursorURLPage<Spotted::Models::Me::PlayerListRecentlyPlayedResponse>
Some parameter documentations has been truncated, see Models::Me::PlayerListRecentlyPlayedParams for more details.
Get tracks from the current user’s recently played tracks. _Note: Currently doesn’t support podcast episodes._
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/spotted/resources/me/player.rb', line 103 def list_recently_played(params = {}) parsed, = Spotted::Me::PlayerListRecentlyPlayedParams.dump_request(params) @client.request( method: :get, path: "me/player/recently-played", query: parsed, page: Spotted::Internal::CursorURLPage, model: Spotted::Models::Me::PlayerListRecentlyPlayedResponse, options: ) end |
#pause_playback(device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerPausePlaybackParams for more details.
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.
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/spotted/resources/me/player.rb', line 131 def pause_playback(params = {}) parsed, = Spotted::Me::PlayerPausePlaybackParams.dump_request(params) @client.request( method: :put, path: "me/player/pause", query: parsed, model: NilClass, options: ) end |
#seek_to_position(position_ms: , device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSeekToPositionParams for more details.
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.
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/spotted/resources/me/player.rb', line 160 def seek_to_position(params) parsed, = Spotted::Me::PlayerSeekToPositionParams.dump_request(params) @client.request( method: :put, path: "me/player/seek", query: parsed, model: NilClass, options: ) end |
#set_repeat_mode(state: , device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSetRepeatModeParams for more details.
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.
189 190 191 192 193 194 195 196 197 198 |
# File 'lib/spotted/resources/me/player.rb', line 189 def set_repeat_mode(params) parsed, = Spotted::Me::PlayerSetRepeatModeParams.dump_request(params) @client.request( method: :put, path: "me/player/repeat", query: parsed, model: NilClass, options: ) end |
#set_volume(volume_percent: , device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSetVolumeParams for more details.
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.
218 219 220 221 222 223 224 225 226 227 |
# File 'lib/spotted/resources/me/player.rb', line 218 def set_volume(params) parsed, = Spotted::Me::PlayerSetVolumeParams.dump_request(params) @client.request( method: :put, path: "me/player/volume", query: parsed, model: NilClass, options: ) end |
#skip_next(device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSkipNextParams for more details.
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.
245 246 247 248 249 250 251 252 253 254 |
# File 'lib/spotted/resources/me/player.rb', line 245 def skip_next(params = {}) parsed, = Spotted::Me::PlayerSkipNextParams.dump_request(params) @client.request( method: :post, path: "me/player/next", query: parsed, model: NilClass, options: ) end |
#skip_previous(device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerSkipPreviousParams for more details.
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.
272 273 274 275 276 277 278 279 280 281 |
# File 'lib/spotted/resources/me/player.rb', line 272 def skip_previous(params = {}) parsed, = Spotted::Me::PlayerSkipPreviousParams.dump_request(params) @client.request( method: :post, path: "me/player/previous", query: parsed, model: NilClass, options: ) end |
#start_playback(device_id: nil, context_uri: nil, offset: nil, position_ms: nil, uris: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerStartPlaybackParams for more details.
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.
307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/spotted/resources/me/player.rb', line 307 def start_playback(params = {}) parsed, = Spotted::Me::PlayerStartPlaybackParams.dump_request(params) query_params = [:device_id] @client.request( method: :put, path: "me/player/play", query: parsed.slice(*query_params), body: parsed.except(*query_params), model: NilClass, options: ) end |
#toggle_shuffle(state: , device_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerToggleShuffleParams for more details.
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.
338 339 340 341 342 343 344 345 346 347 |
# File 'lib/spotted/resources/me/player.rb', line 338 def toggle_shuffle(params) parsed, = Spotted::Me::PlayerToggleShuffleParams.dump_request(params) @client.request( method: :put, path: "me/player/shuffle", query: parsed, model: NilClass, options: ) end |
#transfer(device_ids: , play: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Me::PlayerTransferParams for more details.
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.
367 368 369 370 |
# File 'lib/spotted/resources/me/player.rb', line 367 def transfer(params) parsed, = Spotted::Me::PlayerTransferParams.dump_request(params) @client.request(method: :put, path: "me/player", body: parsed, model: NilClass, options: ) end |