I have an application that can play an audio playlist using an AVQueuePlayer
.
The actual song's URLs are built dynamically and expires after a certain period of time after being built. So the playlist is constructed using something like a permalink, where the song URL is permanent, and responds with an HTTP status code of 301.
Say, for example, that the song URL is http://myhost.com/song?id=1234, and that URL responds with a 301 (moved permanently) and a Location header with a URL that looks like http://realcontent.com/song?id=...&token=...
This all works fine, the music gets played, but I'm experiencing a delay of a few seconds before the audio starts playing.
What I see is that the AVPlayer is doing:
- a first request with HTTP header "Range: bytes=0-1" to the permalink, it responds with the redirect,
- a request to the redirected URL with the same range
- a sencond request to the permalink with the full range, that gets redirected
- a second request to the redirected URL with the full range.
I would like to avoid the third step, as it is completely unnecessary. The permalink already responded with moved permanently, so the following request will respond the same way.
Is there a setting or something I can change to avoid making that request?