How to make 2 videos start/stop by passing the mouse over them

Hello everybody!

I am new in this and I was wondering if someone could help me with this.
I’m trying to start or stop a video when the mouse passed over it, but idk why they don’t appear (only hear the music) or once it has stopped it wont get start again.

In advance thank you all <3

import processing.video.*;

Movie car; //video[1]
Movie bike; //video[2]

void setup(){
 size(2170,700);
  background(255);
 car = new Movie(this, "video[1].mp4");
 bike = new Movie(this, "video[2].mp4");
 
}

void draw(){
 
 image(car, 25, 25 ); 
  car.play(); 

    if (mouseX > 700 ){
        car.pause();    
    } else if (mouseX > 25) {
        car.loop();
         }

  image(bike, 900, 25 ); 
  bike.play(); 

    if (mouseX > 1500 ){
        bike.pause();    
    } else if (mouseX > 900) {
        bike.loop();  
        }
}

I think you need

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

see Movie \ Language (API) \ Processing 3+

IF

Maybe:

    if (mouseX > 700 ){
        car.pause();    
    } else if (mouseX < 700) {
       car.loop();
    }

I hope this helps

2 Likes

Forget it! haha I just fixed it :slight_smile: hahaha

Anyway, thanks for the help! <3

1 Like

Congratulations!

That’s great to hear!

1 Like