Interfacing to VLC with Java
Posted: 08 Nov 2005 18:44
Hi. There didn't seem to be any posts with any java code that demonstrated how to interface to VLC so I wrote some which seems to work. Hope you find it useful
Make sure you change the IP address, VLC.exe location and location of mdeia file to get it to work.
Make sure you change the IP address, VLC.exe location and location of mdeia file to get it to work.
Code: Select all
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
public class SocketDemo {
/**
* @param args
*/
public static void main(String[] args) {
try {
Runtime.getRuntime().exec("C:/Program Files/VideoLAN/VLC/vlc.exe --extraintf=\"rc\" --rc-host=\"10.215.122.68:1234\" --rc-quiet");
Socket MyClient = new Socket("10.215.122.68", 1234);
DataOutputStream output = new DataOutputStream(MyClient.getOutputStream());
final DataInputStream is = new DataInputStream(MyClient.getInputStream());
new Thread()
{
public void run()
{
String response;
try {
while ((response = is.readLine()) != null) {
System.out.println("Server: " + response);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
output.writeBytes("add D:/music/Coldplay/A Rush of Blood to the Head/01 Politik.mp3");
output.writeBytes("\n");
output.writeBytes("play\n");
Thread.sleep(10000);
output.writeBytes("quit\n");
} catch (UnknownHostException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
} catch (InterruptedException e) {
System.out.println(e);
}
}
}