Seek and reverse seek in a VLCJ application

80 Views Asked by At

I am "seeking" the ability to seek forward and backwards on a video being played under vlcj. Information found in the documentation for vlcj API apparently refers to methods that no longer exist.

Is there still a way to do a forward and reverse seek on a video being played by vlcj? If so, how is this done?

Edit to answer questions asked by Slaw below:

  1. I am using VLCJ 4.7.3, with vlcj-javafx V1.1.0.

  2. On the site: https://www.tabnine.com/code/java/methods/uk.co.caprica.vlcj.player.MediaPlayer/seek

there are several references to a seek() function provided by the MediaPlayer class. That function does not exist in the current vlcj.

  1. On a tutorial provided by TutorialsPoint at:

    https://www.tutorialspoint.com/vlcj/vlcj_seek.htm

there is a reference to a function called

mediaPlayer().controls().skipWhile();

which not only does not exist in the current vlcj that I am using, but is not actually used in the seek example program provided below the referance!

1

There are 1 best solutions below

1
caprica On

The way to seek with contemporary versions of vlcj is to use skipTime or skipPosition with a positive or negative delta:

mediaPlayer.controls().skipTime(deltaMillis);

Or:

mediaPlayer.controls().skipPosition(deltaPosition);

If you want to seek to absolute times/positions:

mediaPlayer.controls().setTime(timeMillis);

Or (position between 0.0 and 1.0):

mediaPlayer.controls().setPosition(position);

Note that tabnine and tutorialspoint are not the official or sanctioned documentation for vlcj, so if that's out of date that's an issue for them and not a problem with vlcj's documentation.

In fact, skipWhile has never been a vlcj API function.

Instead, you should look here, or the GitHub project directly:

https://javadoc.io/doc/uk.co.caprica/vlcj/latest/uk/co/caprica/vlcj/player/base/MediaPlayer.html https://javadoc.io/doc/uk.co.caprica/vlcj/latest/uk/co/caprica/vlcj/player/base/ControlsApi.html