Search code examples
iphoneuiwebviewuiwebviewdelegate

Manage the UIWebView loading process


I use UIWebView to present data, and a spinner to show the loading process. The data is an .mp3 file from my server.

I start the spinner when I start loading the webView. Then there is a delay until the audio file starts playing. I need to Stop the spinner quite at that moment.

Notta big deal, but just in case - the loading code:

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://blablabla.mp3"]]];

Question: how could I catch the event when the webView is ready to play the audio (when there is enough data to start playing) ? I need it to stop the spinner.

WebViewDidFinishLoad is the only delegate method I could use and it's not good for me, because it notifies when ALL data is loaded. Even if I use it, it is not getting called when the audio file finishes loading (maybe it's not finishing, I don't know, I just see the loading progress gets to the end while the mp3 is playing). Just in case - the error:

Error Domain=NSURLErrorDomain Code=-999 
"The operation couldn’t be completed. (NSURLErrorDomain error -999.)"
UserInfo=0x1d39d0 {NSErrorFailingURLKey=http://blablabla.mp3,
NSErrorFailingURLStringKey=http://blablabla.mp3}

Any help/tut/link is appreciated. Thanks in advance!


Solution

  • For that kind of control I would not recommend doing it via a webView - you can't get that level of interaction.