Playing A Playlist
Wraps around this Spotify API endpoint
Warning
This method requires Spotify Premium, and will NOT work without Spotify Premium (see here)
Note
This method does not match up with the API endpoint exactly, instead the ID of the playlist is used to build a Context Object which is then played
If an active device is not found, an error about the response status code not being 2xx will be thrown.
How to use
After creating a Spotify
object, and getting a playlist through either .Playlists.GetPlaylist()
or creating a new playlist with .Playlists.CreatePlaylist()
(And adding tracks to the playlist), the .Play()
method of the returned playlist object can be used.
.Play()
will start playing the playlist on the active device.
Example
This example will:
A) Create a Spotify
object (which will prompt the user for authorization if it is not already done)
B) Create a new (empty) playlist named Test 123
with the description This is an example playlist made by Spotify.ahk
C) Add a track to the new playlist with .AddTrack()
by the track's Spotify ID
D) Will try to play the new playlist on the active device
Spoofy := new Spotify()
NewPlaylist := Spoofy.Playlists.CreatePlaylist("Test 123", "This is an example playlist made by Spotify.ahk")
NewPlaylist.AddTrack("5ogtb9bGQoH8CjZNxmbNHR")
NewPlaylist.Play()