0

I have these code in my object.html function to get the video pause notification:

<script type="text/javascript">
    var myPlayer = document.getElementById("example_video_1");
    myPlayer.addEventListener('pause',function(){window.location.href = "yourapp://buttonClicked";},false);
</script>

So when the video pauses, the website can jump to yourapp://buttonClicked. Then I have these code in objective-c to catch the pause event:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    NSLog(@"The value of path is:%@",[request.URL path]);

    if ([[request.URL scheme] isEqual:@"yourapp"]) {
        if ([[request.URL path] isEqual:@"buttonClicked"]) {
            NSLog(@"====================");
        }
        return NO; // Tells the webView not to load the URL
    }
    else {
        return YES; // Tells the webView to go ahead and load the URL
    }
}

But I never got this notification in objective-c: when I paused the video, no jump occured (the shouldStartLoadWithRequest function was not called). How can I fix this problem? Thx.

By the way, the method I used is from here, I did exactly what this link told me to do.

2
  • 1
    There are no official notifications when you play / pause a video in a UIWebView. Check out the answer to this question for a detailed explanation and a possible work around: stackoverflow.com/questions/8518719/… Commented Nov 3, 2015 at 11:17
  • I tried that answer, but it doesn't work for ios8 any more. Commented Nov 3, 2015 at 11:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.