0

In my VLCJ application, I would like to implement a rewind and fast forward function similar to the functions provided on streaming services like Netflix or Amazon. My application will eventually (hopefully) be run on smart TVs, so having that functionality will be very useful.

In most of the streaming services, pressing a "back" button causes the video being viewed to skip backwards and continue doing so until the user hits the play button. The fast forward function operates in a similar manner.

On some systems (the Kodi application comes to mind) engagiing a "rewind" control causes a slow rewind, which doubles in speed each time the rewind control is engaged. At one point (usually if the rewind is going at 16x the speed of play) hitting rewind once again actually stops the rewind. The fast forward on applications like Kodi work in a similar manner.

There appears to be no real rewind capability implemented in the VLCJ API.

I am aware of the VLCJ cotrols() functions called skipTime() and skipPosition(). These functions can "skip" a video forward or backward by a certain amount. Unfortunately, all these functions do is skip back (or forward) once. In order to use these functions to do actual rewind or fast forward, they need to be called multiple times, either by repeatedly engaging a rewind (or fast forward) control or by somehow creating a loop which repeatedly calls the function (my attempts to do this ended in abysmal failure).

I note that I can create nice, smooth fast forward behavior using the controls().setRate() function. Unfortunately, there is no way to use that function to go backward (I have tried).

So: is there a way to implement a real rewind or fast forward function using the available VLCJ API? I am using V4.7.3 of the API. Has anyone used it to implement such functions? If so, how did you do it?

Factor Three
  • 2,094
  • 5
  • 35
  • 51

1 Answers1

3

You have discovered already using setRate() for fast-forward, indeed that is all that is available.

VLC does not support reverse playback at all. It's simply impossible due to how VLC decodes video.

The best you can do is implement your own timer that skips back a few seconds, or however long you want, repeatedly. Although this of course will be far from smooth.

caprica
  • 3,902
  • 4
  • 19
  • 39
  • Yes, that I figured out already (note my mention of looping the skipTime() method in my question). My problem is that my attempts to do that have (as I said) all ended in disaster. What I really need to know is: how exactly can I implement something that skips backward repeatedly? – Factor Three Aug 15 '22 at 16:47
  • 1
    @FactorThree It sounds like you were using a loop. Perhaps it would work if, as suggested in this answer, you used a timer? Or, since you're using JavaFX, an animation (see [here](https://stackoverflow.com/questions/9966136/javafx-periodic-background-task/60685975#60685975))? If you've tried all those things, I suggest you provide a [mre] demonstrating the problem. – Slaw Aug 15 '22 at 18:17
  • A timer with proper thread synchronisation should work in principle, although it's tricky because there are numerous threads involved - e.g. a native thread, the timer thread, the JavaFX thread, and the fact that setting position/time is asynchronous. I don't have a ready-made example for this. – caprica Aug 15 '22 at 20:31