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.

Community
  • 1
  • 1
Demonedge
  • 1,363
  • 4
  • 18
  • 33
  • 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: http://stackoverflow.com/questions/8518719/how-to-receive-nsnotifications-from-uiwebview-embedded-youtube-video-playback/8554040#8554040 – joern Nov 03 '15 at 11:17
  • I tried that answer, but it doesn't work for ios8 any more. – Demonedge Nov 03 '15 at 11:46

0 Answers0