0

I am using Java to play video clips where the filename is stored in a MySQL database. Everything is working correctly, but whenever a video comes on, it always takes around 5 seconds to start playing and the screen is gray at first. Here is a snippet of code from my application:

String[] s = new String[] {"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe", "C:\\Users\\Downloads\\" + filename + ".mp4"};

  try {

    Process process = runtime.exec(s);

    Timer timer = new Timer();

    timer.schedule( new TimerTask(){
       public void run() { 
           System.out.println("Video exit");
           process.destroy();
           Start();

       }
     }, delay);

Filename is the name of the video file that is retrieved from the MySQL database and delay is how long each video is. After the duration of the video, I exit out of the video that is currently playing by calling process.destroy() and go onto the next video by calling Start(). What is a more efficient way of doing this? By more efficient, I mean, is there a way to call process.destroy() as soon as the current video is done playing, therefore not needing to deal with the video duration variable. Ultimately, I want to know how I can play video after video simultaneously in the most efficient way using Java.

drake
  • 259
  • 4
  • 17
  • I know it is quite a year ago. I would like to know why this question is related to Android? –  Feb 23 '17 at 14:32
  • I was implementing this in Android Studio for a school project. – drake Sep 11 '17 at 20:16

1 Answers1

0

You can utilize vlcj for your application. See this: Embed vlcj player in JPanel and this: Embedding VLCJ in JPanel. You can also add a listener to the video player so you can programmed it to automatically play the next video after the currently played video is done. I've tested queueing video files and the delay before the next video starts to play is just very short. With vlcj, your java video application can be as powerful as vlc.

Community
  • 1
  • 1
d_air
  • 631
  • 1
  • 4
  • 12