0

I am trying to run the command Pause for 10 seconds on the currently opened vlc on Windows8.1 command line.

I opened the vlc and run video.mp4 file on it and after 5 seconds it's supposed to pause the video.mp4 for 10 seconds.

here is my code

public class VlcControl {
@Override
public void start(Stage primaryStage) {
    try {           
        manipulateVLC("rotate");//open video.mp4 on vlc
        Thread.sleep(5000);//let the video run for 5 seconds 
        manipulateVLC("enterd");//pause the video 
    
    } catch(Exception e) {
        e.printStackTrace();
    }
}

public static void main(String[] args) {
    launch(args);
}   
    

public void manipulateVLC(String tachesysteme) throws IOException {
    ProcessBuilder processBuilder = new ProcessBuilder();
  if(tachesysteme.equals("rotate")) {       
    processBuilder.command("cmd.exe", "/c", "vlc C:\\video.mp4");
    processBuilder.directory(new File("C:\\Program Files\\VideoLAN\\VLC"));         
    processBuilder.redirectErrorStream(true);
    processBuilder.start();

  }if(tachesysteme.equals("translate")) {
        processBuilder.command("cmd.exe", "/c", "TASKKILL /IM vlc.exe");    
        processBuilder.directory(new File("C:\\Program Files\\VideoLAN\\VLC"));         
        processBuilder.redirectErrorStream(true);
        processBuilder.start();

  }if(tachesysteme.equals("enterd")) {
    processBuilder.command("cmd.exe", "/c", "vlc vlc://pause:10");
    processBuilder.directory(new File("C:\\Program Files\\VideoLAN\\VLC"));         
    processBuilder.redirectErrorStream(true);
    processBuilder.start();
    
 }    
}
}

The command pause doesn't work for me, any help is much appreciated. I am using VLC 3.0.11

Sarrah
  • 3
  • 2
  • You have launched CMD.EXE to launch VLC showing the video, your command for "enterd" does not work because it launches cmd.exe again which launches a new copy of VLC. You will only be able to control VLC if you have command line interaction with the FIRST VLC. Unless you can get this working without Java from 2 different CMD windows, you won't be able to do it from Java. – DuncG Jul 27 '20 at 16:31
  • You probably need to be using VLC web interface if this page is still current for VLC [https://stackoverflow.com/questions/22026684/control-vlc-with-requests-java] – DuncG Jul 27 '20 at 16:49
  • Thank you @DuncG for the quick replay !! So I won't be able to launch a vlc instance and keep control it from java using cmd ? I will give a try to the HTTP requests from java thank you again. – Sarrah Jul 28 '20 at 10:04
  • I merged to Http requests and it works perfectly for me! Thank you again – Sarrah Jul 28 '20 at 13:26

0 Answers0