# Triggering multiple videos using OSC

**URL:** <https://discourse.processing.org/t/triggering-multiple-videos-using-osc/45121>\
**Category:** Libraries\
**Created:** [October 2, 2024, 8:14am UTC](https://discourse.processing.org/t/triggering-multiple-videos-using-osc/45121 "2024-10-02T08:14:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dom](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@dom](https://discourse.processing.org/u/dom)\
**Post date:** [October 2, 2024, 8:14am UTC](https://discourse.processing.org/t/triggering-multiple-videos-using-osc/45121/1 "2024-10-02T08:14:11Z")

</div>

I am trying to build a patch in which multiple videos are overlayed and triggered from Supercollider using OSC. There are four things I am seeking to do which I have not yet achieved.

1. Have multiple videos play at the same time with transparency. In the code below I have used tint, but it has not made the video transparent.
2. I want the video to disappear after play() is complete, but instead it remains there with the final frame.
3. For testing purposes I am trying to trigger a new video using mouseClicked, however when I click the mouse there is no sign of a new video.
4. I want the trigger for the new video to come from OSC. As a beginner in Processing, coming from a music background, I am struggling with this conceptually. Essentially - as I see it - I need to call a function each time an OSC message is sent. However, in terms of code I am not sure what that would look like.

Here is the very basic code I am working with.

```auto
import processing.video.*;

Movie movie;

void setup() {
  size(400, 480);

  movie = new Movie(this, "Earth.mp4");
}

void movieEvent(Movie movie) {
  movie.read();
}

void mouseClicked() {
  movie.play();
  tint(255, 120);
}

void draw() {
  image(movie, 0, 0);
}

```

Thank you for any help, and my apologies if this question seems naive or ignorant. I am constantly reading the documentation/watching Shiffman videos to try to get my head around this language.

One final remark. For this to work, the videos will have to be triggered with a high level of timing accuracy. This project is intended as a video to accompany music that has accurate timing down to the milliseconds. That’s easy with sound, but I’m inexperienced with video, and not sure if the time taken to load a video with mess up the timing.

My concern is that I might be using the wrong tool for the job. I far prefer Processing to MaxMSP or TouchDesigner, for many reasons, but a two big ones being that Processing is a coding environment and Open Source. However, perhaps those environments are better suited to this kind of video manipulation? I hope not.

Many thanks!

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [October 2, 2024, 1:43pm UTC](https://discourse.processing.org/t/triggering-multiple-videos-using-osc/45121/2 "2024-10-02T13:43:15Z")

</div>

Hello @dom!

Sounds like a fun challenge, and definitely doable.

> In the code below I have used `tint()`, but it has not made the video transparent.

Using `tint()` is correct. Try calling `tint()` just before `image(movie, 0, 0)` to ensure it gets applied. Also, make sure there’s something drawn behind the movie—otherwise, the transparency might not be noticeable.

> I want the video to disappear after `play()` is complete, but instead it remains there with the final frame.

You can use `movie.isPlaying()` to check if the video is currently playing. If it returns `false`, you can choose not to draw the video, which effectively hides it after playback.

> For testing purposes I am trying to trigger a new video using `mouseClicked`, but there is no sign of a new video.

Make sure you call `movie.jump(0)` together with `movie.play()`. This resets the video to the start, so it will play from the beginning every time you click.

> I want the trigger for the new video to come from OSC.

For OSC communication, use the `oscP5` library, which you can install from the Contribution Manager. The `oscP5sendReceive` example included with the library is a great starting point. I recommend starting with two separate sketches—one to send OSC messages and the other to receive and play videos.

> For this to work, the videos will have to be triggered with a high level of timing accuracy… not sure if the time taken to load a video will mess up the timing.

Since you’re loading the video in the `setup()` function, load times should not be an issue. I suggest testing a small prototype with the actual videos or ones with similar file sizes and formats to see if the responsiveness meets your needs.

Cheers!  
Raphaël

---

<div class="post-metadata">

**Author:** ![dom](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@dom](https://discourse.processing.org/u/dom)\
**Post date:** [October 2, 2024, 9:32pm UTC](https://discourse.processing.org/t/triggering-multiple-videos-using-osc/45121/3 "2024-10-02T21:32:15Z")

</div>

Hi Raphaël,

Thank you so much for your helpful reply.

> Using `tint()` is correct. Try calling `tint()` just before `image(movie, 0, 0)` to ensure it gets applied. Also, make sure there’s something drawn behind the movie—otherwise, the transparency might not be noticeable.

Basic error. However, without an image behind the movie it is harder to notice any changes.

> You can use `movie.isPlaying()` to check if the video is currently playing. If it returns `false` , you can choose not to draw the video, which effectively hides it after playback.

That is very helpful! Thanks. Especially as ‘isPlaying’ is not in movie’s help file, so great to get that tip.

> Make sure you call `movie.jump(0)` together with `movie.play()` . This resets the video to the start, so it will play from the beginning every time you click.

This I have to think about. My plan is to have 12 videos playing so I think I need to code a class and possibly put them in an array.

For anyone else with this problem I found this thread which seemed helpful… [create new object with mouse click - Processing Forum](https://forum.processing.org/one/topic/create-new-object-with-mouse-click.html)

> Since you’re loading the video in the `setup()` function, load times should not be an issue. I suggest testing a small prototype with the actual videos or ones with similar file sizes and formats to see if the responsiveness meets your needs.

Good idea. It’s still very much a work in progress, but I feel like I’m edging closer. If I can get the mouseClicked to trigger multiple videos then that should test if Processing - and my computer - are capable of the results I am after.

Thanks again for your helpful response.
