Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- void setup() {
- size(400,400);
- background(0);
- textSize(50);
- text("HI", 30, 50);
- }
- void draw(){
- play();
- text("BYE", 30, 50);
- exit();
- }
- void play(){
- //open mp4 file using xine media player
- String commandToRun = "xine file:///home/me/sketchbook/webcam_capture/out.mp4" ;
- File workingDir = new File("/bin");
- String returnedValues; // value to return any results
- // give us some info:
- println("Running command: " + commandToRun);
- println("Location: " + workingDir);
- println("---------------------------------------------\n");
- // run the command!
- try {
- Process p = Runtime.getRuntime().exec(commandToRun, null, workingDir);
- // variable to check if we've received confirmation of the command
- int i = p.waitFor();
- // if we have an output, print to screen
- if (i == 0) {
- // BufferedReader used to get values back from the command
- BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
- //read the output from the command
- while ( (returnedValues = stdInput.readLine ()) != null) {
- println(returnedValues);
- }
- }
- // if there are any error messages but we can still get an output, they print here
- else {
- BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
- //if something is returned (ie: not null) print the result
- while ( (returnedValues = stdErr.readLine ()) != null) {
- println(returnedValues);
- }
- }
- }
- // if there is an error, let us know
- catch (Exception e) {
- println("Error running command!");
- println(e);
- // when done running command, quit
- println("\n---------------------------------------------");
- println("DONE!");
- exit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment