Question

I have a media player, i.e. vlcj through which i display videos in java frames and panels, i want to know if there is a way in which i can play 2 parts of the video one after the other, for eg i wanna play 10:00 to 12:00 and 13:00 to 14:00 without any break in between them, ive done this by writing playmedia 13:00 to 14:00 in the finished event of my embeddedmediaplayer, but i want to know if there is another way or something shorter, im using vlcj and java (netbeans)

 p = new Canvas();
p.setSize(p1.getWidth(),p1.getHeight());
o = new Canvas();
p1.add(p,BorderLayout.CENTER);
p2.add(o,BorderLayout.CENTER);
m1 = new MediaPlayerFactory();
m2 = new MediaPlayerFactory();
e1 = m1.newEmbeddedMediaPlayer();
e1.setVideoSurface(m1.newVideoSurface(p));
e1.playMedia("src/Video/656.mkv", ":start-time="+(60*15 + 24.6), ":stop-time="+(60*15 + 30.1));
Was it helpful?

Solution

You have two main options:

  1. Use an EmbeddedMediaListPlayerComponent rather than an EmbeddedMediaPlayerComponent, and add your media (and start-time and stop-time media options) to the playlist.

  2. Implement your own playlist, using an ArrayList containing objects representing your playlist item (start-time, end-time and MRL), and manage it using the finished() and error() callbacks in a media player event listener. So you get a finished() event, you advance to the next item in the playlist and play that (with your start-time and stop-time media options).

The main problem with #1 is that the underlying libvlc native media list player is not as reliable as the regular native media player. It seems more buggy and prone to crashing.

The main advantage of #1 is that it is the quickest, most seamless, way to play multiple videos one after another.

The main problem with #2 is that it is more work for you to implement. Also, the changeover from one video to the next might not be quite as seamless as with #1.

For #2 you may also need to consider how you are going to synchronise access to your play list.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top