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

**URL:** <https://discourse.processing.org/t/how-to-make-2-videos-start-stop-by-passing-the-mouse-over-them/28660>\
**Category:** Libraries\
**Tags:** homework\
**Created:** [March 19, 2021, 2:51pm UTC](https://discourse.processing.org/t/how-to-make-2-videos-start-stop-by-passing-the-mouse-over-them/28660 "2021-03-19T14:51:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellosofieo](https://avatars.discourse-cdn.com/v4/letter/h/c57346/32.png) [@hellosofieo](https://discourse.processing.org/u/hellosofieo)\
**Post date:** [March 19, 2021, 2:51pm UTC](https://discourse.processing.org/t/how-to-make-2-videos-start-stop-by-passing-the-mouse-over-them/28660/1 "2021-03-19T14:51:16Z")

</div>

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

```auto
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();  
        }
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 19, 2021, 3:37pm UTC](https://discourse.processing.org/t/how-to-make-2-videos-start-stop-by-passing-the-mouse-over-them/28660/2 "2021-03-19T15:37:07Z")

</div>

I think you need

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

```

see [Movie \ Language (API) \ Processing 3+](https://www.processing.org/reference/libraries/video/Movie.html)

**IF**

Maybe:

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

```

I hope this helps

---

<div class="post-metadata">

**Author:** ![hellosofieo](https://avatars.discourse-cdn.com/v4/letter/h/c57346/32.png) [@hellosofieo](https://discourse.processing.org/u/hellosofieo)\
**Post date:** [March 22, 2021, 11:53am UTC](https://discourse.processing.org/t/how-to-make-2-videos-start-stop-by-passing-the-mouse-over-them/28660/4 "2021-03-22T11:53:58Z")

</div>

Forget it! haha I just fixed it 🙂 hahaha

Anyway, thanks for the help! \<3

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 22, 2021, 1:56pm UTC](https://discourse.processing.org/t/how-to-make-2-videos-start-stop-by-passing-the-mouse-over-them/28660/5 "2021-03-22T13:56:35Z")

</div>

Congratulations!

That’s great to hear!
