javascript - How to fast-forward or rewind an HTML5 video to a certain time point -


i'm trying write javascript , can't figure out why method isn't working.

var vid = document.getelementbyid('myvid'),      ticks = 50, // number of frames during fast-forward     frms = 10, // number of milleseconds between frames in fast-forward/rewind     endtime = 24.0; // time fast-forward/remind (in seconds)  // fast-forward/rewind video end time  var tdelta = (endtime - vid.currenttime)/ticks;  ( var = 0; < ticks; ++i ) {    (function(j){        settimeout(function() {              vid.currenttime = vid.currenttime + tdelta * j;        }, j * frms);    })(i); } 

fiddle: https://jsfiddle.net/f90yu2t4/1/

are html videos not advanced enough support kind of rapid movement place place in video?

two things:

for jsfiddle, code wrapped in window.onload, code inside window.onload isn't executed. should remove wrapper (at least when using jsfiddle).

second, in settimeout function, vid.currenttime = vid.currenttime + tdelta * j; doesn't work intended because second instance of vid.currenttime isn't constant start time. should assign starttime before settimeout function, , have vid.currenttime = starttime + tdelta * j;

with changes, check out here: updated fiddle: https://jsfiddle.net/f90yu2t4/8/


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -