caprica / vlcj

Java framework for the vlc media player
http://www.capricasoftware.co.uk/projects/vlcj
1.1k stars 260 forks source link

How to repeat play video without black frames between plays #1227

Closed caprica closed 2 months ago

caprica commented 2 months ago

Unless and until gapless playback lands in VLC, it is possible to improve the repeat-play situation slightly.

Use input-repeat=65535 when playing media, it will loop seamlessly. 65535 is the maximum, there is no special value it seems for "forever".

package uk.co.caprica.vlcj;

import uk.co.caprica.vlcj.player.component.EmbeddedMediaPlayerComponent;

import javax.swing.JFrame;

public class ListTest {

    public static void main(String[] args) throws Exception {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        EmbeddedMediaPlayerComponent mpc = new EmbeddedMediaPlayerComponent();
        f.setContentPane(mpc);
        f.setSize(800, 600);
        f.setVisible(true);

        mpc.mediaPlayer().media().play("/home/mark/normal_05.mp4", "input-repeat=65535");

        Thread.currentThread().join();
    }
}