function initVideoProgress() { function formatTime(time, fragments) { var output = '', fragment; // Maximize the fragments in 3. fragments = Math.max(1, Math.min(3, fragments || 3)); // For every fragment generate output. while (fragments--) { if (output) { output = ':' + output; } // This is the last fragment if (fragments === 0) { fragment = '' + (time | 0); t = 0; } else { fragment = '' + (time | 0) % 60; time /= 60; } // Prefill with 0s if needed. while (fragment.length < 2) { fragment = '0' + fragment; } output = fragment + output; } return output; }
$('video').each(function(index, _video) { var $_controls = findControlsForVideo(_video), $_progress_bars = $_controls.find('.video_progress_bar'); /* Bind The timeupdate Event For The Video */ $(_video).bind('timeupdate', function() { var percentage = 0; if ((typeof this.duration != "undefined") && (this.duration > 0)) { percentage = 100 * this.currentTime / this.duration; console.log(formatTime(this.currentTime, 3)); } $_progress_bars.css("width", percentage + "%"); }); }); } -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com