Class: Spotify::PlayerResource
Instance Attribute Summary
Attributes inherited from Resource
#client
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Instance Method Details
#add_to_queue(uri:, device: nil) ⇒ Object
51
52
53
54
|
# File 'lib/spotify/resources/player.rb', line 51
def add_to_queue(uri:, device: nil)
response = post_request("me/player/queue?uri=#{uri}&device=#{device}", body: nil)
response.success?
end
|
12
13
14
15
|
# File 'lib/spotify/resources/player.rb', line 12
def devices
response = get_request("me/player/devices")
Collection.from_response(response, type: Device, key: "devices")
end
|
#next(device: nil) ⇒ Object
36
37
38
39
|
# File 'lib/spotify/resources/player.rb', line 36
def next(device: nil)
response = post_request("me/player/next", body: { device_id: device }.compact)
response.success?
end
|
#pause(device: nil) ⇒ Object
31
32
33
34
|
# File 'lib/spotify/resources/player.rb', line 31
def pause(device: nil)
response = put_request("me/player/pause", body: { device_id: device }.compact)
response.success?
end
|
#play(device: nil) ⇒ Object
26
27
28
29
|
# File 'lib/spotify/resources/player.rb', line 26
def play(device: nil)
response = put_request("me/player/play", body: { device_id: device }.compact)
response.success?
end
|
#playing(**params) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/spotify/resources/player.rb', line 17
def playing(**params)
response = get_request("me/player/currently-playing", params: params)
if response == true
nil
else
Player.new response.body
end
end
|
#previous(device: nil) ⇒ Object
41
42
43
44
|
# File 'lib/spotify/resources/player.rb', line 41
def previous(device: nil)
response = post_request("me/player/previous", body: { device_id: device }.compact)
response.success?
end
|
46
47
48
49
|
# File 'lib/spotify/resources/player.rb', line 46
def queue
response = get_request("me/player/queue")
Collection.from_response(response, type: Track, key: "queue")
end
|
#state(**params) ⇒ Object
3
4
5
6
7
8
9
10
|
# File 'lib/spotify/resources/player.rb', line 3
def state(**params)
response = get_request("me/player", params: params)
if response == true
nil
else
Player.new response.body
end
end
|