tags:

views:

128

answers:

2

Hi all I want to run a program called VLC in java and control it while running, for example if user clicked on pause or fast forward button, I do a specific suitable action. I run VLC by this code :

      try{

            Runtime rt = Runtime.getRuntime();
            Process p = rt.exec(VLCProgramAddFile + " udp://@:" + listeningPort);

            OutputStream out = p.getOutputStream();
            InputStream in = p.getInputStream();

            p.waitFor();
            System.out.println("End of VLC");
        }catch (Exception e){
            System.out.println("error in running VLC");
        }

I have heard about java binding, but I don't know how does it work for this job. please guide me.

thank you, sajad

+1  A: 

You are probably looking for VLCJ, this is a java wrapper for VLC. It allows you to embed VLC media player in a java application, and thus add all your personal controls.

(Do note that for user applications this is fine, but the VLCJ library isn't perfect, you can have several problems pop up.)

EDIT: For my project I've seen memory leaks and issues with long running programs (multiple instances for several hours). Especially the multiple instances doesn't work in combination with some compile options (which are on by default).

Thirler
Thank you, I am trying to learn how to use VLCJ but is there any way to control this called process through in/out streams in my program? Using VLCJ is better or calling .exe file, like I used in my program.Please notice that controlling video while running, is important to me.
sajad
@Thirler: What kind of problems?
Grodriguez
@Sajad I've only got experience with using VLCJ, it is at least possible to start/stop and pause from the application, but I think all commands will work. I have no experience with using the normal VLC gui in combination with your own application. I think if you want to embed the output into your application you need VLCJ.
Thirler
Thank you for your worthy answer.
sajad
A: 

Depending on what you want to ultimately accomplish maybe the gstreamer Java bindings are worth a look which will give you a very fine grained control about the playback. And you can do conversions and everything. They also have a minimalistic video player example application to get you started with.

Waldheinz
Thank you for your good paraphrase !
sajad