IPhone UIWebView playing MP3. Dismissal protocol?

So I can’t find the documentation on how to do this, maybe someone knows what is going on here.

I am in UITableView (with UINavigationController) in my application and run UIWebView, which downloads an mp3 file on the Internet by pushing the Web View controller onto the navigation controller stack. This works great, the file runs and plays in QuickTime, which uses Safari.

The problem is that as soon as the audio file is finished, or the user clicks the "Finish" button, the player will be released and the application will return to an empty webView with my navigation bar. I can click the back button to return to my original UITableView, but this blank screen is ugly and has to go.

So, what action can I use to send a message [webviewcontroller.navigationcontroller popviewcontroller]? Does an instance of any other class (such as AVAudioPlayer) load to play sound? Do I need to subclass something? Apple's documentation of how it plays audio in a UIWebView is basically irrelevant.

+5
source share
3 answers

, , ; , . UIWebview initWithFrame: CGRectMake (0.0,0.0,1.0,1.0), , NSURLRequest . , nav.

+5

, javascript location.href, - :

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
        navigationType:(UIWebViewNavigationType)navigationType {

    NSString* path=[[request URL] relativePath];
    BOOL shouldContinue=YES;

    if ([path isEqualToString:@"/_my_custom_link"])
    {
        shouldContinue=NO;
        // do magical stuff
    }
    return shouldContinue;
}

, ,

stringByEvaluatingJavaScriptFromString 
+1

- : UIWebView - ( iOS 4.1).

, - , .

+1
source

All Articles