Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="https://stackoverflow.com/questions/2536441/iphone-progressive-download-audio-player" title="This">This</a> questions discusses what you're looking for</p> <p>Edit:</p> <p>If you want to download a file THEN play it, what you need to do is:</p> <p>use an NSURLConnection to download the file to the disk - <a href="https://stackoverflow.com/questions/623735/how-to-download-a-large-file-with-the-iphone-sdk-and-avoid-memory-usage-issues" title="this">this</a> link discusses saving large files (i wouldn't keep 2-5mb's in the memory when i don't need them even thought it will probably work).</p> <p>, than an AVAudioPlayer to play it - check <a href="http://mobileorchard.com/easy-audio-playback-with-avaudioplayer/" rel="nofollow noreferrer" title="this">this</a> out.</p> <p>Edit 2:</p> <p>For the cancel button, it should practically just call the [NSURLConnection cancel] method and do whatever other finishing up your download class is gonna need...</p> <p>For the progress bar, in the NSURLConnectionDelegate method didReceiveResponse, you take the NSURLResponse, cast it to a NSHTTPURLResponse, and retrieve the size of the file you're downloading using the <a href="http://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSURLResponse_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURLResponse/expectedContentLength" rel="nofollow noreferrer" title="expectedContentLength">expectedContentLength</a> method.</p> <p>And then in each call to the NSURLConnection:didRecieveData method you count the incoming bytes using [data length] method, divide it by the <a href="http://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSURLResponse_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURLResponse/expectedContentLength" rel="nofollow noreferrer" title="expectedContentLength">expectedContentLength</a> from the previous URL response and that's the float the represents your progress that you pass to the progress view's <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIProgressView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIProgressView/progress" rel="nofollow noreferrer">progress</a> property</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload