CanvasVideoSurface videoSurface = mediaPlayerFactory.newVideoSurface(canvas);
EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer();
mediaPlayer.setVideoSurface(videoSurface);
MediaListPlayer mediaListPlayer = mediaPlayerFactory.newMediaListPlayer();
mediaListPlayer.addMediaListPlayerEventListener(new MediaListPlayerEventAdapter() {
@Override
public void nextItem(MediaListPlayer mediaListPlayer, libvlc_media_t item, String itemMrl) {
System.out.println("nextItem()");
}
});
mediaListPlayer.setMediaPlayer(mediaPlayer); // <--- Important, associate the media player with the media list player
JPanel cp = new JPanel();
cp.setBackground(Color.black);
cp.setLayout(new BorderLayout());
cp.add(canvas, BorderLayout.CENTER);
JFrame f = new JFrame("vlcj embedded media list player test");
f.setIconImage(new ImageIcon(TestMediaListEmbeddedPlayer.class.getResource("/icons/vlcj-logo.png")).getImage());
f.setContentPane(cp);
f.setSize(800, 600);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
MediaList mediaList = mediaPlayerFactory.newMediaList();
mediaList.addMedia("/movies/1.mp4");
mediaList.addMedia("/movies/2.mp4");
mediaList.addMedia("/movies/3.mp4");
mediaListPlayer.setMediaList(mediaList);
mediaListPlayer.setMode(MediaListPlayerMode.LOOP);
mediaListPlayer.play();
// This looping is just for purposes of demonstration, ordinarily you would
// not do this of course
for(;;) {
Thread.sleep(500);
mediaPlayer.setChapter(3);
Thread.sleep(5000);
mediaListPlayer.playNext();
}
// mediaList.release();
// mediaListPlayer.release();
// mediaPlayer.release();