简体   繁体   中英

Seeking video with VLC web player js

I'm trying to seek through an .avi file that is being streamed from a remote server via vlc plugin for firefox. I was trying to seek through the file. I know that if it is being streamed it could be impossible for the player to know the actual length of the video, and it could be difficult as well to seek through parts of the video which haven't been downloaded yet, but what if I just want to get at position 0? I mean: what if I simply want to restart the video? It should be possible and EASY to do it. Here's my code:

<html>
<title>VLC Mozilla plugin test page</title>
<body>
<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"             version="VideoLAN.VLCPlugin.2"
    width="640"
    height="480"
    id="vlc" target="http://www1003.megaupload.com/files/4ad9c3466e2ce41b3bcfb6146d4d8ca0/Il%20Cavaliere%20Oscuro%20CD1.avi">
</embed>
<script language="Javascript">

function restart()
{
var vlc = document.getElementById("vlc");
vlc.input.time=0;
}

</script>
<a onclick="restart();">DOIT</a>
</body>
</html>

But...! It doesn't work at all. When I click on DOIT, video lags for half a second (so it looks like it can actually "feel" something) but keeps playing from the current position undisturbed. What should I do?

I'm quite desperate with this, any help/suggestion is very appreciated!

use

vlc.playlist.stop();
vlc.input.time = 1;
vlc.playlist.start();

see for reference http://www.videolan.org/doc/play-howto/en/ch04.html#id591206

BUT BEWARE: not all videos are "seekable" - if you happen to stream one of those then the above won't work (happens with DivX plugin too)... in such cases some players implement some sort of buffering themselves to allow for seeking but that's out of scope for a javascript solution...

Seeking is generally not supported in file download services like megaupload. It is possible to do it with normal streaming services, but it must be supported by the web server.

If you want to emulate seeking, you can still increase the buffer size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM