Search code examples
iphoneobjective-cstreamingavplayer

Is there a way to select the bit rate while using AVPlayer for HTTP live audio streaming?


I'm using AVPlayer to stream audio content delivered in two quality formats.

The problem is that when passing from a lower format to a higher one ( done automatically by the framework when wi-fi is available ) there is a delay while playing.

Is there a way to manually select a desired quality in order to prevent that delay?


Solution

  • Update: This was accurate at the time for iOS 4. For an updated iOS 8 answer, see here.


    I've researched this very question for myself and have not found an answer which means I'm pretty positive there is no way to do this. The Apple docs don't always give all the details of what you can do with things but if you look at all the available properties, methods, etc you will find that there is nothing to allow you to tweak the stream.

    I think this is the whole point of HLS. Apple wants iPhone users to have the best streaming experience possible. If they gave the developer the controls to tweak which stream is being used then that defeats the purpose. The system knows best when it comes to switching streams. If the phone cannot handle the additional bandwidth then it won't (or shouldn't) switch to the higher stream. Some things that I have found that you may want to look at...

    Are your files chunked into 10 second increments? If it's more than that you might want to shorten them.

    Some file conversion programs don't get the bit rates exactly right and if that is the case your phone may think it has the bandwidth for, say, a 96 kbps feed but in reality your feed is 115 kbps. Take a look at the accepted answer in this post: iPhone - App Rejected again, HTTP Live Streaming 64kbps baseline feed