0

Im building an HTML5 webapp using the new video tag. I use most of the new features but some of them are not implemented yet and I could use the old QT/JS API.

Apple provides documentation for that : http://developer.apple.com/library/safari/#documentation/QuickTime/Conceptual/QTScripting_JavaScript/bQTScripting_JavaScri_Document/QuickTimeandJavaScri.html#//apple_ref/doc/uid/TP40001526-CH001-SW5

but this is only vor object or embed tags. Do you know if there is a way to do it using the video tag ?

(the whole purpose of my request is to catch the event on iOS where the user can actually press play on a video)

Cystack
  • 3,301
  • 5
  • 35
  • 33

1 Answers1

0

If i understand you correctly that you want to catch the event when a user starts play on a HTML5 Video, you can use the following events:

videoElements = document.getElementsByTagName("video");

for (var i = 0; i < videoElements.length; i++) {
    ele = videoElements[i];
    ele.addEventListener("play", onVideoPlay);
    ele.addEventListener("pause", onVideoPause);
    ele.addEventListener("ended", onVideoEnded);
}

Or is it something else you want to achieve?

joern
  • 27,354
  • 7
  • 90
  • 105
  • Not really ! HTML5 would allow me to do that. No, I want the event right BEFORE, when the play button becomes available (not when it is actually pressed). It is qt_loadedmetadata in QT I think. But the HTML5 onloadedmetadata event ectually fires after the play click... – Cystack Jul 15 '11 at 22:52
  • Aaah, okay. Have you seen this question: http://stackoverflow.com/questions/5181865/checking-if-a-html5-video-is-ready ? Maybe that helps. – joern Jul 15 '11 at 23:00
  • yea but these are very theoretical discussions around specs and stuff. what actually happens is readyState goes to 4 when the first frame of the video appears, which is acutally obviously after the buffering started, etc. (at least on Safari 5) – Cystack Jul 15 '11 at 23:03