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.