JMPerez / spotify-web-api-js

A client-side JS wrapper for the Spotify Web API

Home Page:https://jmperezperez.com/spotify-web-api-js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get to know when playback is starting

mystermiam opened this issue · comments

Hello there!

The problem I'm trying to solve is :

"Using the Spotify web API /player endpoint, offering a usable progress-bar through a custom Spotify player".

I've understood that there is no way to get any realtime player updates from posted issues on the Spotify repository.

However, I'd like to know: Would be possible for one to know when the playback is starting ? I mean by that, when one can actually hear the song playing through the speakers, which is different than the request to "/player/play" being completed.

For now, I'm launching a timer to keep the progress bar updated when the request is completed, but it causes various annoying side effects... Also, I'd like to avoid polling the /player endpoint.

Thanks @mystermiam for the suggestion. This is not possible at the moment since that functionality is not provided by Spotify's API, so you are left with checking the playback state every few seconds.

This is for instance what I do in https://github.com/JMPerez/spotify-player (see https://github.com/JMPerez/spotify-player/blob/master/public/spotify-player.js#L73) used on these "now playing" visualizations.