Reputation: 131
I am making make a web app where I'll embed my spotify podcast episode. I need certain things to happen on my website once a certain number of seconds have been played. Is there a way to get the playback time using the API?
Upvotes: 1
Views: 1656
Reputation: 7404
Use
/v1/me/player/currently-playing
which returns progress_ms
Example:
Request
curl -X GET "https://api.spotify.com/v1/me/player/currently-playing" -H "Authorization: Bearer {your access token}"
Response
{
"context": {
"external_urls" : {
"spotify" : "http://open.spotify.com/user/spotify/playlist/49znshcYJROspEqBoHg3Sv"
},
"href" : "https://api.spotify.com/v1/users/spotify/playlists/49znshcYJROspEqBoHg3Sv",
"type" : "playlist",
"uri" : "spotify:user:spotify:playlist:49znshcYJROspEqBoHg3Sv"
},
"timestamp": 1490252122574,
"progress_ms": 44272, <------
...
Also take into consideration that this API is in Beta and may be subject to change without notice. (or have functional or performance issues)
API Documentation is here and here.
Upvotes: 2