Estoy escribiendo un reproductor de video. Como barra de tiempo utilizo un rango. A medida que se reproduce el video, el rango también cambia. Pero quiero cambiarlo de la manera opuesta. Quiero que el rango haga que el video cambie su hora actual. Pero, debido a que se cambian entre sí, no puedo mover un pulgar. Intenté configurar Interval null pero no funcionó. Dame una mano con esto, por favor.
$(document).ready( function () { $("#PlayerVideo").on("loadedmetadata", function (event) { Video = $("#PlayerVideo")[0]; Duration = Video.duration; hours = Math.floor(Duration / 60 / 60); mins = Math.floor((Duration - hours * 60 * 60) / 60); secs = Math.floor(Duration - mins * 60); $("#durTime").html(hours + ":" + mins + ":" + secs); // display cur time Interval = setInterval( function () { Play(); }, 250 ); }); $("#TimeRange").on("input", function() { $.when().then( function() { Interval = null; } ).then( function () { Video = $("#PlayerVideo")[0]; Video.currentTime = $(this).val()*Duration; console.log("cur time is " + Video.currentTime); CurTime = $(this).val()*Duration; } ).then( function () { Interval = setInterval( function () { Play(); }, 250 ); } ); } ); function Play() { Video = $("#PlayerVideo")[0]; CurTime = Video.currentTime; console.log(CurTime); hours = Math.floor(CurTime / 60 / 60); mins = Math.floor((CurTime - hours * 60 * 60) / 60); secs = Math.floor(CurTime - mins * 60); $("#curTime").html(hours + ":" + mins + ":" + secs); $("#TimeRange").val(CurTime / duration * 100); } });