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

function interrupt draw

$
0
0
I have create an application which read a video and where the speed can be modified by event "keyPressed".
This works well but when I press several times the key, the method draw seems stop and my movie in pause until the event endding.
How to solve this problem of interrupt ? How I can reduce the time of the interrupt fonction ?

This is my sketch :

  1. import processing.video.*;
  2. Movie mov;
  3. float speed;

  4. void setup() {
  5.   size(480, 390);
  6.   frameRate(50);
  7.   mov = new Movie(this, "myvideo.mov");
  8.   mov.play();
  9.   speed=0.5;
  10. }

  11. void draw() {
  12.  background(255);
  13.  fill(255);   
  14.  mov.speed(speed);
  15.  image(mov, 90, 90, 390, 390);
  16.   fill(0);
  17.   text( "speed : " + speed, 10, 30);
  18.   if((mov.duration())-(mov.time())<0.1 && speed>0){
  19.     println("fin video "+mov.time()+"mov.duration : "+(mov.duration()));
  20.     mov.jump(0);
  21.   }
  22.   if(speed<0 && (mov.time()-0)<0.1){
  23.      println("fin video "+mov.time());
  24.      mov.speed(abs(speed));
  25.     mov.jump(mov.duration());
  26.   }
  27. }

  28. // Called every time a new frame is available to read
  29. void movieEvent(Movie m) {
  30.   m.read();
  31. }

  32. void keyPressed() {
  33.   if (key == CODED) {
  34.     if (keyCode == LEFT) {
  35.         speed = speed -0.1;
  36.     } else if (keyCode == RIGHT) {
  37.         speed = speed+0.1;
  38.    }
  39.   } 
  40. }
  41.   

Viewing all articles
Browse latest Browse all 1768

Trending Articles