function interrupt draw
in
Core Library Questions
•
8 months ago
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 :
- import processing.video.*;
- Movie mov;
- float speed;
- void setup() {
- size(480, 390);
- frameRate(50);
- mov = new Movie(this, "myvideo.mov");
- mov.play();
- speed=0.5;
- }
- void draw() {
- background(255);
- fill(255);
- mov.speed(speed);
- image(mov, 90, 90, 390, 390);
- fill(0);
- text( "speed : " + speed, 10, 30);
- if((mov.duration())-(mov.time())<0.1 && speed>0){
- println("fin video "+mov.time()+"mov.duration : "+(mov.duration()));
- mov.jump(0);
- }
- if(speed<0 && (mov.time()-0)<0.1){
- println("fin video "+mov.time());
- mov.speed(abs(speed));
- mov.jump(mov.duration());
- }
- }
- // Called every time a new frame is available to read
- void movieEvent(Movie m) {
- m.read();
- }
- void keyPressed() {
- if (key == CODED) {
- if (keyCode == LEFT) {
- speed = speed -0.1;
- } else if (keyCode == RIGHT) {
- speed = speed+0.1;
- }
- }
- }
1