6

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?

smplio
  • 150
  • 10
  • 1
    hey, have you figured out why and how to solve this issue? – Ng2-Fun Jan 05 '17 at 14:13
  • try online or with another server. many report that it's a Chrome bug related to the server. i solved the problem just by uploading the video on an online server and setting the full url on the `src` attribute. – taseenb Feb 08 '17 at 19:16
  • I figured out an answer: https://stackoverflow.com/a/54336444/6322589 – lucasvw Jan 23 '19 at 22:14

0 Answers0