Play help?
glowkeeper opened this issue · comments
Hi,
How do you actually play a track, once you've returned something from searchTracks
? I'm currently trying something like this:
if (tracks.length) {
spotify.play(tracks[0].uri, function ( err, data ) {
if (err) {
console.error(err)
} else {
console.log(tracks[0].uri)
}
})
}
But I get TypeError: cannot use 'in' operator to search for "device_id" in "spotify:track:5t..."
Yada yada yada. I've tried a few things - apologies if I'm being a bit of a dullard and missing something obvious - I can usually figure this stuff out!
Anyway - feature request? Some examples of actually playing stuff as I can't seem to find any.
Eek!
Ooo - I'm getting closer:
spotify.play({uris: tracks[0].uri}, function ( err, data )...
getting a 400, malformed json
error now, but it's an improvement!
Aha, and this is even closer:
spotify.play({uris: [tracks[0].uri]}
Now it's complaining about no active device...
Okay - I got it working, but I don't know how practical it all is. Basically, I used the console to get me a player
token with all the permissions set. That meant I could do this:
if (tracks.length) {
spotify.getMyDevices( function ( err, data ) {
if (err) {
console.error("oi: ", err)
} else {
spotify.play({device_id: data.devices[0].id, uris: [tracks[0].uri]}, function ( err, data ) {
if (err) {
console.error(err)
} else {
console.log(tracks[0].uri)
}
})
}
})
}
Closing since this is not an issue that needs to be addressed in this library/wrapper.