Kabitis
Kabitis

Reputation: 51

IOS send pause video to html5

I have a little problem on IOS native send data to Html5.

Here's code from IOS

 // NSString *script = @"document.getElementById('videoID').pause()";
 NSString *script = @"document.getElementById('videoID').onpause=function()";
 [subView stringByEvaluatingJavaScriptFromString:script]; //I need to send pause data to html5 is possible if I use like this.

and

<video id="videoID" src="Kaberos.mp4" poster="poster_1.png" controls  ></video>

How can i pause video with IOS, It's possible?, if I got something wrong please let me know. Thanks.

Kind Regards,

Kabitis.

Upvotes: 1

Views: 221

Answers (2)

Kabitis
Kabitis

Reputation: 51

oh I'm wrong, now I can fix it

I try this.

[[self.scrollView.subviews objectAtIndex:currentPage-1]stringByEvaluatingJavaScriptFromString:@"document.getElementById('videoID').pause();"];

and If you want to reload page - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { you can use like this

 [[self.scrollView.subviews objectAtIndex:currentPage-1]stringByEvaluatingJavaScriptFromString:@"location.reload();"]; // reload old page

Thanks.

Kind Regards,

Kabitis.

Upvotes: 2

arvy3
arvy3

Reputation: 136

Not sure I understand the question. If you're looking to pause the video then you should use the .pause() method on the video, as you've commented out in the question. If that doesn't work, then try adding that to an click event listener.

Or, if you're trying execute code when the video is paused, try using event listeners to listen for the pause event:

document.getElementById('videoID').addEventListener('pause', pauseEventHandler);

You would put your handling code in the pauseEventHandler function.

I've not coded for iOS before, but you might want to try adding an event listener to see if that works.

Upvotes: 1

Related Questions