Launch VLC Player through Java
Asked Answered
Z

5

5

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

Zahavi answered 24/8, 2011 at 7:23 Comment(1)
possible duplicate of how to control VLC by javaSubjugate
D
3

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();
Donothingism answered 24/8, 2011 at 7:25 Comment(3)
backslashes (\) should be escaped: "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"Untouchable
ProcessBuilder pb = new ProcessBuilder("C://ProgramFiles/VideoLAN/VLC/vlc.exe", "D://avtar.mp4"); Process start = pb.start(); The Vlc player is opening for me but its not playing the video from the specified path.Zahavi
I am done with this problem the solution is something like this, you should paste the video file into yours workspace/yoursapplication/a.pm4Zahavi
N
4

Use VLCJ. Here is the new link

Neese answered 27/8, 2011 at 9:49 Comment(0)
D
3

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();
Donothingism answered 24/8, 2011 at 7:25 Comment(3)
backslashes (\) should be escaped: "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"Untouchable
ProcessBuilder pb = new ProcessBuilder("C://ProgramFiles/VideoLAN/VLC/vlc.exe", "D://avtar.mp4"); Process start = pb.start(); The Vlc player is opening for me but its not playing the video from the specified path.Zahavi
I am done with this problem the solution is something like this, you should paste the video file into yours workspace/yoursapplication/a.pm4Zahavi
L
0

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

Lunette answered 24/8, 2011 at 7:26 Comment(1)
You may want to obtain it from the user ;)Zany
U
0
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.");

   }
}
Untouchable answered 24/8, 2011 at 7:41 Comment(3)
It is unlikely that it is contained in E:Donothingism
What if i want to play a file with VLC ?Vervet
Usually, the first argument of any executable that works with files is the path of the file to open... for example: "vlc.exe MyVideo.mov"Untouchable
M
0

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.

Mama answered 24/8, 2011 at 8:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.