Ariel
Ariel

Reputation: 251

Using HTML5 on iPhone - cannot pause

I was wondering whether anyone has tried to use the new tag that comes with HTML5 on the iPhone. Specifically, I didn't manage to make the pause() command to work. Below is a portion of the page. As you can see, I'm trying to pause the video 10sec after it started. It works on Safari on a Mac btw. Has anyone managed to make this work?

<head>
<javascript language="JavaScript">

function timeUpdate()
{
 var myVideo = document.getElementsByTagName('video')[0];
 var time = myVideo.currentTime;
 if (time > 10)
 {
  myVideo.pause();
 }
}

function addListeners()
{
 var myVideo = document.getElementsByTagName('video')[0];
 myVideo.addEventListener('timeupdate',timeUpdate,false);
}

</script>
</head>

<body onload="addListeners()">
 <video controls src="resources/bb_poor_cinderella_512kb.mp4" 
  poster="resources/background.png">
  Video tag not supported!
 </video>
</body>

Thanks,
Ariel

Upvotes: 0

Views: 912

Answers (3)

Barry
Barry

Reputation: 19

As far as i know iPhone wont let you play video inline in the mobile safari browser. So pausing wont work ofcourse. iPhone open the video in an external videoplayer, you dont have control over browser features, so the pausing doenst work.

Upvotes: 2

NibblyPig
NibblyPig

Reputation: 52942

This code is invalid:

<javascript language="JavaScript"> 

There is no HTML tag called <Javascript>

To set the language to javascript, you should use this:

<script type="text/javascript">
// Code here
</script>

Note that the language attribute is deprecated according to the W3C standard (http://www.w3.org/TR/REC-html40/interact/scripts.html) so you should use type rather than language.

Upvotes: 5

Michael Aaron Safyan
Michael Aaron Safyan

Reputation: 95509

You should use <script>, not <javascript language="JavaScript">.

Upvotes: 0

Related Questions