Created
April 4, 2011 20:38
-
-
Save staydecent/902380 to your computer and use it in GitHub Desktop.
video timelime events, lzimm halp mez
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
var video = $('.video'); | |
var vCount = 0; // Or own counter, for counting | |
var chapters = { | |
// seconds : selector | |
// I forget what data types JS has.... LOLZ | |
// Pythonz in my brain | |
1 : 'one-second' | |
} | |
video.bind('timeupdate', function(o) { | |
// as a video is playing, event is triggered as it moves along | |
// we don't like decimals | |
var currentSeconds = parseInt(video.attr('currentTime')); | |
if (currentSeconds >= vCount) { | |
console.log(vCount); | |
// so here we should check if we want to do a 'chapters' event | |
// which would be animating the selector | |
// wishing on smth more elegant than bunch of hard ifs | |
vCount = vCount + 1; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ahhh, first thing to be aware if is if you can jump around the timeline there's miscoordination gonna happen there right? like, vCount = 55, time=55.11512... scrub back to time=3, not gonna fire for 52 seconds now, dunno if that's an issue though.
but to your actual matter, you can do something hacky like setInterval(function() { console.log(GLOBAL_LOG_LINE); }, 1000); then every frame just set GLOBAL_LOG_LINE, otherwise though, your solution should be fine, though parseInt gonna kinda suck, maybe do str comparison or something?