phoboslab / jsmpeg

MPEG1 Video Decoder in JavaScript
MIT License
6.38k stars 1.43k forks source link

currentTime not work #144

Open wait121000 opened 7 years ago

wait121000 commented 7 years ago

var player = new JSMpeg.Player('video.ts', {canvas: canvas}); player.currentTime = 30; player.play ();

when play it , not begin from 30 second .

phoboslab commented 7 years ago

You have to make sure that the video has actually loaded far enough until you can jump to a specific time.

The easiest way to do this is to set progressive: false in the options, so the whole file will be loaded. You could also force the progressive loader to load everything by setting throttled: false. See the readme for the details.

wait121000 commented 7 years ago

why html5 video tag can do it? this html5 js code is work.

//use html5 <video> tag
video.currentTime = 58;
video.play();
phoboslab commented 7 years ago

JSMpeg can do this too, you just have to load the file first.

The MPEG-TS format does not have an intra-frame index in the file header, like an MP4 does, so we can't jump to arbitrary frames without loading the video file them from the very beginning to the point you want to jump to. We have no way to figure out which file chunk (i.e. byte offset) has the frame you want, so we have to load everything.

You could try building a separate index of intra frames and their corresponding byte offsets in the file, load it via XHR and use this to guide JSMpeg's progressive loader to queue up the correct chunks.

wait121000 commented 7 years ago

thanks for help

wait121000 commented 7 years ago

how to add a progress bar ? like html5

kikyouink commented 1 year ago

how to add a progress bar ? like html5

现在有方案了吗?