AVPlayer slow loading

I'm using AVPlayer to play mp3 files from a remote url.

i'm having some issues with the initial loading time of the mp3, it is very slow (around 5-8 sec).

i compared it with other third parties players and its much slower, i also compared it with an android player and it is also much slower.

so the problem is not with the url itself nor with the network connection..

another interesting point is that after the AVPlayer start playing the mp3, seeking is very fast (almost immediately), does that mean the player download the entire mp3 file before start playing, and thats the reason it is so slow?

can i control this behaviour? if not, any other ideas what can be the reason?

Replies

I can also confirm that I am having the same challenge. In it's current implementation, AVPlayer will not actually start playing until it has downloaded the full audio file.

The problem is not with the file hosting server, because a class implementing AudioFileStreamOpen() in the AudioToolbox gets play started almost immediately, as soon as first data begins to arrive.

Perhaps AVPlayer began immediately in the past (many forums imply that it has been known to stream), but all iterations of current methods on AVPlayer and its subclasses do not appear to be able to trigger this behavior now. AVPlayer dutifully returns player.currentItem.status = 1 very quickly (indicating that AVPlayer player "isReadyToPlay"), but the audio won't start until the whole file has arrived.

Apple, if there is a way to start outputting audio from AVPlayer as soon as first data starts arriving, please let us know how to implement it. Thanks so much for any help or guidance you can provide.

  • "please let us know how to implement it" - This is what Apple needs to focus on. Actually showing us examples of how certain codes needs to be implemented. Just description is not enough. There developer documentation is absolutely unhelpful

Add a Comment