Launch VLC Player through Java

混江龙づ霸主 提交于 2019-12-12 12:14:01

问题


I want to launch my VLC player through a Java program, can any one help me? Thanks in advance.


回答1:


Vlc is located on different places depending on your system, but this is for 64 bit

ProcessBuilder pb = new ProcessBuilder("C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe", "file to start with vlc");
Process start = pb.start();

and this should work for x86:

ProcessBuilder pb = new ProcessBuilder("C:\\Program Files\\VideoLAN\\VLC\\vlc.exe", "file to start with vlc");
Process start = pb.start();



回答2:


Use VLCJ. Here is the new link




回答3:


You might want to try this sample of code:

Runtime.getRuntime().exec("path_to_your_VLC_exe");

Unfortunately you will need to have an absolute path to your executable file, which sometimes cannot be obtained.

Look here for more examples: http://www.rgagnon.com/javadetails/java-0014.html




回答4:


public class Test {
   public static void main(String[] args) throws IOException, InterruptedException {
      Runtime.getRuntime().exec("\"E:\\Program Files\\VideoLAN\\VLC\\vlc.exe\"");

      System.out.println("VLC started.");

   }
}



回答5:


You'll need to specify an absolute path to the program, which might be a problem if you do not know where VLC is stored.



来源:https://stackoverflow.com/questions/7171840/launch-vlc-player-through-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!