Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-30-2012, 09:34 PM   PM User | #1
kethklx
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
kethklx is an unknown quantity at this point
help - html5 video tag - Eventlistener "timeupdate"

Hi,
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);
myVideo.play();

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

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

Last edited by kethklx; 11-30-2012 at 09:48 PM..
kethklx is offline   Reply With Quote
Old 11-30-2012, 10:16 PM   PM User | #2
kethklx
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
kethklx is an unknown quantity at this point
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) {
myVideo.pause();
kethklx is offline   Reply With Quote
Reply

Bookmarks

Tags
eventlistener, html5, timeupdate, video, video tag

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:46 AM.


Advertisement
Log in to turn off these ads.