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);
}
}
}