Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Issues with controlling video clips.

$
0
0
Fairly new to Processing, and could use some help and input. I'm working on a project in which it's necessary to control at least two video clips. I've been using the Processing Movie reference and also this tutorial from Elie Zananiri.

The basic gist is, one video should play constantly on a loop, until a switch (like a key press) makes a second video play, and once that video is done playing, the first video should return to automatic loop, until that switch goes off again.

Through these resources I've been able to set up a basic code, where pressing a key ('1') makes one video loop, pressing another ('2') makes that loop stop and play a second video. That's where I run into problems, so here are my questions:
  1. Pressing '2' again does not make the second video play again. Once it's played one time, it can't be played a second or third. Is there a workaround?
  2. The videos load in layers. Even though I can't make the second video play a second time, I can get the first video to begin looping again after pressing '1'. However, because they load in layers, it is covered by the second, unplayable video. How do I get it to play on top, or to not load in layers?
  3. I need to find a way to make the first video play as soon as the second video is finished, but all the commands within the Processing reference only allow them to play simultaneously. I have considered using a timer for this but am not sure how to proceed or if that's even the right answer. I've had friends and mentors suggest state machines, but that seems like it might be a little complicated for something that ought to be simple. 
  4. Do if/then statements exist within Processing? The book I have on the subject only covers if/else statements and a Google search turned up no answers, so I'm thinking they might not.
Code:

  1. import processing.video.*;

  2. Movie dobBark; // adds variable for Doberman Bark video
  3. Movie dobStop; // adds variable for Doberman Stop video

  4. void setup() { 
  5.   size(480, 272); // defines size of the video window -- needs tweeking.
  6.    dobBark = new Movie(this, "dobBark.m4v"); // loads Doberman Bark vid.
  7.    dobStop = new Movie(this, "dobStop.m4v"); // loads Doberman Stop vid.
  8. }

  9. void draw() { 
  10.    image(dobBark, 0, 0); // without this code, none of the videos will show up
  11.    image(dobStop, 0, 0);

  12. void movieEvent(Movie m) { 
  13.   m.read(); // not really sure what this does but you need it.

  14. void keyPressed() { 
  15.   if(key=='1'){ 
  16.     dobBark.loop(); // if you press the 1 key, Doberman Bark video will loop.
  17.   }
  18.   
  19.   if(key=='2') {
  20.     dobBark.stop(); // if you press the 2 key, the Doberman Bark video will stop
  21.     dobStop.play(); // and the Doberman Stop video will play only once.
  22.   }
I have tried placing a loop command directly after dobStop.play();, and have tried using an if/else statement (if no input, play dogBark, else play dobStop) to no avail, but that might have been due to my inexperience with syntax. Please help! And deepest apologies if I'm doing something totally stupid and haven't noticed.

Viewing all articles
Browse latest Browse all 1768

Trending Articles