Announcements

Help Wizard

Step 1

NEXT STEP

Feature Request: Airplay flag on player api

Feature Request: Airplay flag on player api

There are many aspects of using the API that it would be very important to know a user is using Airplay to play from their device. Airplay adds a 2 second delay to the playback and if you are developing an app that needs to be in sync to the music it is important to know that Airplay is in use on the device currently. I did not see any way to know this from my reading of the player API endpoints.

 

My use case is I have been developing a visualization app that connects with Spotify and generates the visualizations using the audio-analysis and audio-features api endpoints and for it to work with Airplay's 2 second delay, I need to know so I can add in the delay. From all the reading I have seen on Airplay the delay is always 2 seconds

Reply
1 Reply

An even better option would be to use whatever API exists for a playback device for the hardware latency. iOS for instance exposes:

 

You can query iOS's current hardware audio latency by -[AVAudioSession outputLatency],

According to the document for outputLatency:

Using an AirPlay enabled device for your audio content can result in a 2-second delay. Check for this delay in game content.

And according to my experience, this value changes when switching output device

Bluetooth is typically 100ms, Airplay always 2000ms

 

on the endpoint: https://api.spotify.com/v1/me/player

instead a new field hwlatency_ms on the device object could contain the current latency value so that can maintain an accurate sync with the audio that is actually being heard by the user. Spotify app could even use this as currently it displays the wrong track time when using Airplay and shows that the track is playing even before the initial 2 second bufferring has finished and audio is actually playing

Suggested posts