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

Re : Show videos with processing

$
0
0
I find that Processing 2.0's use of seconds (as opposed to frames) to time a video clip makes it difficult to reach certain logical conditions.  I need to add an extra frame (1 second / frames per second) to time() readings for things to work.  This sketch will preload your clips and loop them

  1. import processing.video.*;
  2. Movie video1, video2, video3;

  3. boolean playVideo1 = true;
  4. boolean playVideo2 = false;
  5. boolean playVideo3 = false;


  6. void setup() {
  7.   
  8.   size(500, 500);

  9.   video1 = new Movie(this, "video1.mov");
  10.   video2 = new Movie(this, "video2.mov");
  11.   video3 = new Movie(this, "video3.mov");
  12. }


  13. void draw() {

  14.   if (playVideo1 == true) {
  15.     video1.play();
  16.     image(video1, 0, 0);
  17.     //println(video1.time() + "\t" + video1.duration());   
  18.     if (video1.time() + .03 >= video1.duration()) {
  19.       video1.stop();
  20.       playVideo1 = false;
  21.       playVideo2 = true;
  22.     }
  23.   }

  24.   if (playVideo2 == true) {
  25.     video2.play();
  26.     image(video2, 0, 0);
  27.     //println(video2.time() + "\t" + video2.duration());    
  28.     if (video2.time() + .03 >= video2.duration()) {
  29.       video2.stop();
  30.       playVideo2 = false;
  31.       playVideo3 = true;
  32.     }
  33.   }

  34.   if (playVideo3 == true) { 
  35.     video3.play();
  36.     image(video3, 0, 0);
  37.     println(video3.time() + "\t" + video3.duration());     
  38.     if (video3.time() + .03 >= video3.duration()) {
  39.       video3.stop();
  40.       playVideo3 = false;
  41.       playVideo1 = true;
  42.     }
  43.   }
  44. }


  45. void movieEvent(Movie m) {
  46.   m.read();
  47. }

http://code.google.com/p/simple-cinema/

Viewing all articles
Browse latest Browse all 1768

Trending Articles