Skip to content

Commit

Permalink
Merge pull request #258 from derekpovah/fetch-queue
Browse files Browse the repository at this point in the history
Add support for fetching the user's current playback queue
  • Loading branch information
guilhermesad authored Aug 20, 2023
2 parents 0cc35cd + 77e0909 commit ac7d5b5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/rspotify/player.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ def play(device_id = nil, params = {})
User.oauth_put(@user.id, url, params.to_json)
end

# Get the user’s current playback queue
#
# @example
# player = user.player
# player.next_up
def next_up
url = "me/player/queue"
response = User.oauth_get(@user.id, url)
return response if RSpotify.raw_response

response["queue"].map do |item|
type_class = RSpotify.const_get(item["type"].capitalize)
type_class.new item
end
end

# Add an item to the end of the user’s current playback queue
# If `device_id` is not passed, the currently active spotify app will be triggered
#
Expand Down

0 comments on commit ac7d5b5

Please sign in to comment.