How to make a video start on a full second at 1000 milliseconds...

edited February 2017 in Questions about Code

I'm struggling to understand how to set the parameter so the sketch I've created starts at a full second.

The majority of components including a moving clock, movie and music all need to sync to the same time. However, currently the clock is running to actual time, and the movie and music start immediately from when the user would click 'Run'.

I understand and have used many time framed parameters within my coding, for example draw an ellipse at a certain time such as:

  if (millis() < 24610) {
    fill(255, 255, 0);
    stroke(255, 255, 0);
    ellipse(width/2-140, height/2*k+140, 10, 10);

I just don't understand how to get a movie or song to play at the certain time, in order for everything to sync to your computers time (as the clock does)...

Could I use some part of the following statement?

  if (movie.available() == true) {; 

However add something like... if millis() is 1000 start movie and music...

Sorry, I am still very new to Processing and would appreciate the help a lot!




  • edited December 2016 Answer ✓

    @bmz -- You are on the right track.

    if(millis()==1000) will not work, because you don't know the exact millisecond that a draw frame will happen. It might be 999, or 1001, or something else.

    Here is the example from the Processing reference:

    Movie myMovie;
    void setup() {
      size(200, 200);
      myMovie = new Movie(this, "");;
    void draw() {
      image(myMovie, 0, 0);
    void movieEvent(Movie m) {;

    What you want to do is not play() until (for example) millis()>3000.


    However, you only want it to execute once. You could create a global flag to check whether you have already started playing:

    boolean playnow = false;
    if(playnow==false && millis()>3000){;
  • Thanks so much, worked perfectly!

Sign In or Register to comment.