View Full Version : help - html5 video tag - Eventlistener "timeupdate"

11-30-2012, 10:34 PM
This code goes into a click event that is supposed to play one second of a movie. The next click increments and plays the next second, etc.

What I have here works for the first click - on the second click, the movie does not play. Third click , the playhead advances to the next position as expected but still is paused, and so on.

Tis is in an Adobe Edge project, and I'm testing in Firefox.

Any help would be greatly appreciated.

//add 1 to "pTime" each click - pTime is where the video should pause
sym.setVariable("pTime", pTime + 1);

// set playhead back 1 second then play//
myVideo.currentTime = (pTime-1);

// event listener checks the current
// movie time/position of the playhead 4 times per second
myVideo.addEventListener("timeupdate", function()

if (myVideo.currentTime >= pTime) {
}}, false);

11-30-2012, 11:16 PM
I think i fixed it. The variable needs to be grabbed again from inside the function, i.e. it's not global. Is there a more elegant way to do this?

myVideo.addEventListener("timeupdate", function() {

var pTime = sym.getVariable("pTime");

if (myVideo.currentTime >= pTime) {