Problems Playing VLC from processing
in
Integration and Hardware
•
2 years ago
Hi there
A friend of mine has helped me out by giving me some example code on how to play a video using VLC player. However when i try to play a video it will only play if i click anywhere on the VLC window before the small processing window starts up. I'm a complete beginner to all of this so would really appreciate some pointers the code i was given is here
Thanks in advance.
import processing.net.*;
VLC video;
String videoPath = "C:/Documents and Settings/tech-student/My Documents/Downloads/may12_webclip.wmv";
void setup() {
// VLC
video = new VLC(this, "localhost", 2121);
}
void draw() {
if(random(1000) > 999) {
playVideo();
}
}
void playVideo() {
video.addToPlaylist(videoPath);
video.fullscreen(true);
}
// for playing audio and video through VLC over a network connection
class VLC {
Client socket;
Boolean paused;
VLC (PApplet parent, String address, int port) {
// launch VLC
try {
//String[] cmd = {"/Applications/VLC.app/Contents/MacOS/VLC", "--no-osd", "--extraintf=rc", "--rc-host=localhost:" + port, "--rc-fake-tty"};
//windows
String[] cmd = {"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe", "--no-osd", "--extraintf=rc", "--rc-host=localhost:" + port};
Runtime.getRuntime().exec(cmd);
} catch(Throwable t) {
t.printStackTrace();
}
try {
Thread.sleep(5000);
} catch (InterruptedException e) { }
// connect over network
socket = new Client(parent, address, port);
paused = false;
}
void command(String command) {
socket.write(command + "\r\n");
}
void clearPlaylist() {
this.command("clear");
}
void addToPlaylist(String path) {
this.command("add " + path);
}
void fullscreen(Boolean full) {
if(full) {
this.command("f on");
} else {
this.command("f off");
}
}
void seek(String timestamp) {
this.command("seek " + timestamp);
}
void pause(Boolean pause) {
if(paused != pause){
this.command("pause");
paused = pause;
}
}
}
A friend of mine has helped me out by giving me some example code on how to play a video using VLC player. However when i try to play a video it will only play if i click anywhere on the VLC window before the small processing window starts up. I'm a complete beginner to all of this so would really appreciate some pointers the code i was given is here
Thanks in advance.
import processing.net.*;
VLC video;
String videoPath = "C:/Documents and Settings/tech-student/My Documents/Downloads/may12_webclip.wmv";
void setup() {
// VLC
video = new VLC(this, "localhost", 2121);
}
void draw() {
if(random(1000) > 999) {
playVideo();
}
}
void playVideo() {
video.addToPlaylist(videoPath);
video.fullscreen(true);
}
// for playing audio and video through VLC over a network connection
class VLC {
Client socket;
Boolean paused;
VLC (PApplet parent, String address, int port) {
// launch VLC
try {
//String[] cmd = {"/Applications/VLC.app/Contents/MacOS/VLC", "--no-osd", "--extraintf=rc", "--rc-host=localhost:" + port, "--rc-fake-tty"};
//windows
String[] cmd = {"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe", "--no-osd", "--extraintf=rc", "--rc-host=localhost:" + port};
Runtime.getRuntime().exec(cmd);
} catch(Throwable t) {
t.printStackTrace();
}
try {
Thread.sleep(5000);
} catch (InterruptedException e) { }
// connect over network
socket = new Client(parent, address, port);
paused = false;
}
void command(String command) {
socket.write(command + "\r\n");
}
void clearPlaylist() {
this.command("clear");
}
void addToPlaylist(String path) {
this.command("add " + path);
}
void fullscreen(Boolean full) {
if(full) {
this.command("f on");
} else {
this.command("f off");
}
}
void seek(String timestamp) {
this.command("seek " + timestamp);
}
void pause(Boolean pause) {
if(paused != pause){
this.command("pause");
paused = pause;
}
}
}
1