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.