I am trying to make my own HTML5 video player and i am using this code to change currentTime of a video:
$(document).ready(function(){
...
//controls.total is my seekbar
controls.total.click(function(e) {
var x = e.pageX;
var prog = $(this);
var maxduration = video.duration;
var position = x - prog.offset().left;
var percentage = 100 * position / prog.width();
if(percentage > 100) {
percentage = 100;
}
if(percentage < 0) {
percentage = 0;
}
controls.progress.css('width',percentage+'%');
if ( video.seekable.length > 0 ) {
video.currentTime = maxduration * percentage / 100;
}
});
...
}
It works just as it should to in IE9, Edge and Firefox. But It doesn't work in Chrome. It just sets currentTime to 0. Why?