<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with movieevent() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=movieevent%28%29</link>
      <pubDate>Sun, 08 Aug 2021 14:49:50 +0000</pubDate>
         <description>Tagged with movieevent() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedmovieevent%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>mov files not playing</title>
      <link>https://forum.processing.org/two/discussion/28067/mov-files-not-playing</link>
      <pubDate>Thu, 05 Jul 2018 23:43:27 +0000</pubDate>
      <dc:creator>danlj</dc:creator>
      <guid isPermaLink="false">28067@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>Is anyone experiencing issues with video playback? I can't get any .mov files to play... I've even tried to run the example sketches on video playback and only the "reverse" example works, which uses a .mkv file. I haven't tested any other formats yet.</p>

<p>I don't get any errors, just a black screen. I've tried both using movieEvent() and calling a new frame from draw().</p>

<p>I keep a version of Processing 2 (as i still use some libs that were never updated) and .mov playback works fine here.</p>

<p>macOS 10.12.6
Processing 3.3.7</p>
]]></description>
   </item>
   <item>
      <title>Multiple videos smoothness - threaded playback</title>
      <link>https://forum.processing.org/two/discussion/28057/multiple-videos-smoothness-threaded-playback</link>
      <pubDate>Fri, 15 Jun 2018 20:57:02 +0000</pubDate>
      <dc:creator>grumo</dc:creator>
      <guid isPermaLink="false">28057@/two/discussions</guid>
      <description><![CDATA[<p>Hello!
This script only requires a bunch of .mp4s in the data folder. You'll see a collage of 9 videos (or duplicates) in different positions and transparencies. The thing runs ok but even pre-loading the videos at the beginning every time there's a change/swap in one of the videos (around every 4 seconds) the whole thing freezes for a sec, sometimes (try to use mp4s of different sizes).</p>

<p>I tried to use the thread() command in the switching of the videos but nothing happened. I put a println to see the thread but alway show the main thread, I really don't know if I'm doing this ok..</p>

<p>Thanks a LOT for any help!</p>

<pre><code>import processing.video.*;

File path; 
String[] files;
int numfiles = 0;
int timer = -5000;
int tcontrol= 2000;
int numVideos=9;

VideoM[] v = new VideoM[numVideos];
Movie[] vv;

void setup(){
  size(1920, 1080, P2D);
  frameRate(60);
  files = files(); 
  numfiles = files.length;
  if (numfiles&gt;11) numfiles=11;
  loadvideos();

  for(int i = 0;i &lt; numVideos;i++){
     v[i] = new VideoM();
  }
}


void draw() {

  background(0);
  for(int i = 0; i &lt;numVideos; i++){
     v[i].display();
  }

  if ((millis() - timer) &gt; tcontrol)  {
    thread("newvideo");   
    timer = millis();
    tcontrol= int(random(2,6))*1000; 
}
}


void loadvideos(){

 String video;
 vv = new Movie[numfiles];

 for (int i=0; i&lt;numfiles; i++){
   video= files[int(random(numfiles))];
   vv[i] = new Movie(this, video);
   println ("Loading ", video);
 }
}

class VideoM {

 Movie m;
 String video;

 int x;
 int y;
 int w;
 int h;
 int alpha;
 int alphai;
 int fadeout=0;

 VideoM() {
  genera();
  println(numfiles);
  m = vv[int(random(numfiles)) ];
  m.loop();
  // m.volume(random(0.4,0.6));
  // m.speed(random(0.6,1.0));
  m.jump(random(m.duration()));  
  //m.play(); 
 }

 void genera(){
    x=int(random(50, width/2+width/4)); 
    y=int(random(50, height/2+height/4)); 
    w=int(random(280,820));
    h=int(w/1.88);
    alpha=int(random(100,255)); 
    alphai=0; 
 }

 void display(){
   tint(255, alphai);
   if (fadeout==0) {
     alphai++; if (alphai&gt;alpha) alphai=alpha;
   } else {  alphai--; if (alphai&lt;0) {alphai=0;fadeout=0;this.newvid();}
     }

   if (frameCount &gt; 1) { image(m, x, y, w, h); }
 } 

 void cambiavid(){
   fadeout=1;
 }

void newvid() {  
   m=null;
   int j=int(random(numfiles));
   println("cambio: ", j);
   m = vv[j];
   m.loop();
   genera();
   m.jump(random(m.duration())); 
   println(Thread.currentThread());
 }
}  

void newset(){
  for(int i = 0;i &lt; numVideos;i++){
    println(i);
    v[i].newvid();
  }
}

void newvideo(){
  int i = int(random(numVideos));
  //v[i].nuevovid(this);
  v[i].cambiavid();
}

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

boolean bStop,bColor=true;
boolean bSave=false,bVidO=false;
void keyPressed()
{
  int k = keyCode;

  // reset all videos
  if (key == 'n' || key == 'N') {
    newset();
    }

}  


// load files in data

String[] files(){
// The data path of the folder to look in (write your own)
java.io.File folder = new java.io.File(dataPath(""));

// let's set a filter (which returns true if file's extension is .jpg)
java.io.FilenameFilter pngFilter = new java.io.FilenameFilter() {
  public boolean accept(File dir, String name) {
    return name.toLowerCase().endsWith(".mp4");
  }
};

// list all the folders inside the main directory
String[] listFolders = folder.list(new java.io.FilenameFilter() {
  public boolean accept(File current, String name) {
    return new File(current, name).isDirectory();
  }
});

// list the files in the data folder, passing the filter as parameter
String[] filenames = folder.list(pngFilter);

return(filenames);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>stream video on second monitor</title>
      <link>https://forum.processing.org/two/discussion/27915/stream-video-on-second-monitor</link>
      <pubDate>Fri, 04 May 2018 16:22:23 +0000</pubDate>
      <dc:creator>secondsky</dc:creator>
      <guid isPermaLink="false">27915@/two/discussions</guid>
      <description><![CDATA[<p>Hi All, i would be able to stream two video on two different monitor, at the same time.
So far this is the code i written to stream one on the secondary monitor, but is not working:</p>

<pre><code>import processing.video.*;

final PApplet projector0 = new ProjectorSketch();
final PApplet projector1 = new ProjectorSketch();

void setup() {
  size(300, 300, JAVA2D);
  smooth(4);
  noLoop();
  stroke(-1);

  runSketch(new String[] { "--display=1", "--present",  "--sketch-path=" + sketchPath(), "Projector" }, projector0);

}

void draw() {
  background(0);
}


class ProjectorSketch extends PApplet {
  Movie movie;


 void setup() {

   stroke(#FFFF00);
   movie = new Movie(this, "transit.mov");
  movie.loop();

   }


  public void settings() {
    size(displayWidth, displayHeight, JAVA2D);

  }

  void draw() {

  image(movie, 0, 0, width, height);
  }
}

public void movieEvent(Movie m) {
  m.read();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I get sound to fade in and out depending on your location?</title>
      <link>https://forum.processing.org/two/discussion/27718/how-can-i-get-sound-to-fade-in-and-out-depending-on-your-location</link>
      <pubDate>Sat, 07 Apr 2018 19:15:18 +0000</pubDate>
      <dc:creator>karinalopez87</dc:creator>
      <guid isPermaLink="false">27718@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I was able to make my sound play and stop with Kinect but it doesn't loop or fade out. I want my sound to continue playing with the video and just fade in if the interaction is activated and fade out when the interaction is no longer happening. Also, I want my sound to loop.</p>

<pre><code>     import processing.sound.*;
     import org.openkinect.processing.*;
     import processing.video.*;


    Movie vid;
    Movie vid1;
    SoundFile sound1;
    SoundFile sound2;
    Kinect2 kinect2;

    //PImage depthImg;
    //PImage img1;

    //pixel
    int minDepth=0;
    int maxDepth=4500; //4.5m

    boolean off = false;

    void setup() {
      size(1920,1080);
      //fullScreen();
      vid = new Movie(this, "test_1.1.mp4");
      vid1 = new Movie(this, "test_1.1.mp4");
      sound1 = new SoundFile(this, "cosmos.mp3");
      sound2 = new SoundFile(this, "NosajThing_Distance.mp3");

      //MOVIE FILES
          //01.MOV
          //03.MOV
          //02.mov (File's too big)
          //Urban Streams.mp4
          //HiddenNumbers_KarinaLopez.mov
          //test_w-sound.mp4
          //test_1.1.mp4
          //test005.mov
      //SOUND FILES      
          //cosmos.mp3
          //NosajThing_Distance.mp3

      vid.loop();
      vid1.loop();
      kinect2 = new Kinect2(this);
      kinect2.initDepth();
      kinect2.initDevice();
    //depthImg = new PImage(kinect2.depthWidth, kinect2.depthHeight);
    //img1 = createImage(kinect2.depthWidth, kinect2.depthHeight, RGB);
    }

    void movieEvent(Movie vid){
      vid.read();
      vid1.read();
    }


    void draw() { 
      vid.loadPixels();
      vid1.loadPixels();

      //image(kinect2.getDepthImage(), 0, 0);

        int[] depth = kinect2.getRawDepth();

      float sumX=0;
      float sumY=0;
      float totalPixels=0;

        for (int x = 0; x &lt; kinect2.depthWidth; x++){
          for (int y = 0; y &lt; kinect2.depthHeight; y++){
            int offset = x + y * kinect2.depthWidth;
            int d = depth[offset];

            if ( d &gt; 0 &amp;&amp; d &lt; 1000){
          //    //video.pixels[offset] = color(255, 100, 15);
          sumX +=x;
          sumY+=y;
          totalPixels++;
             brightness(0);
            } else {
          //    //video.pixels[offset] = color(150, 250, 180);
              brightness(255);
            }      }
        }
    vid.updatePixels();
    vid1.updatePixels();

    float avgX = sumX/totalPixels;
    float avgY=sumY/totalPixels;


    //VID 01 - Screen 01
    if (avgX&gt;300 &amp;&amp; avgX&lt;500){
    tint(255, (avgX)/2);
    image(vid1, 1920/2, 0);
    if(sound2.isPlaying()==0){
    sound2.play(0.5);
    sound2.amp(0.5);
    }
    }else{
    tint(0, (avgX)/2);
    image(vid1, 1920/2, 0);
    if(sound2.isPlaying()==1){
     delay(1);
    //IT DIMS THE VOLUME TO 0 BUT IT DOESN'T GO BACK TO VOLUME 0.5 [sound2.amp(0.5);]
     sound2.amp(0);
     }
    }
     //VID 02 - Screen 01
     if (avgX&gt;50 &amp;&amp; avgX&lt;200){
    tint(255, (avgX)/3);
    image(vid, 0-(1920/2), 0);
    }else{
       tint(0, (avgX)/3);
       image(vid, 0-(1920/2), 0);
     }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Random video player freezes after two hours</title>
      <link>https://forum.processing.org/two/discussion/24158/random-video-player-freezes-after-two-hours</link>
      <pubDate>Mon, 18 Sep 2017 11:55:10 +0000</pubDate>
      <dc:creator>oehin</dc:creator>
      <guid isPermaLink="false">24158@/two/discussions</guid>
      <description><![CDATA[<p>Hi everybody</p>

<p>For a project I programmed a random video player using the processing video library. If the space bar is pressed a random video is played. After that the player plays a video in a loop until space bar is pressed again. This worked perfectly on my MacBook, however it doesn't in the installation setting with a slightly older iMac. I guess the source for the problem lies in the code. But I cannot figure out were.</p>

<p>Any help is very welcome.</p>

<p>This is the code:</p>

<pre><code>import processing.video.*;

int numMovies = 9;
boolean valid=false;
String[] one = {
  "Video1.mp4", "Video2.mp4", "Video3.mp4", "Video4.mp4", "Video5.mp4", "Video6.mp4", "Video7.mp4", "Video8.mp4", "Video9.mp4"
};

float movieEndDuration = 0.5;

Movie myMovie;
Movie myLoop;

void setup()
{
  fullScreen(P2D);
  myLoop  = new Movie(this, "VideoLoop.mp4");
  myLoop.loop();
}

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


void draw()
{
  if (valid == true) {
    image(myMovie, 0, 0, width, height);
  } else
  {
    image(myLoop, 0, 0, width, height);
  }
  if (valid &amp;&amp; myMovie.time()+ movieEndDuration &gt;= myMovie.duration()) {
    myMovie.stop();
    valid=false;
    myLoop = new Movie(this, "VideoLoop.mp4");
    myLoop.loop();
  }
}


void keyPressed() {
  if (key == ' ' &amp;&amp; valid==true) {
    myMovie.stop();
    myLoop.stop();
  } 
  if (keyCode == ENTER &amp;&amp; valid==true)
  {
    myMovie.stop();
    myLoop.stop();
  }
}


void keyReleased()
{

  if (key == ' ')
  {
    valid=true;
    println(one[int(random(numMovies))]);
    myLoop.stop();
    myMovie = new Movie(this, one[int(random(numMovies))]);
    myMovie.play();
  } 
  if (keyCode == ENTER)
  {
    valid=true;
    myLoop.stop();
    myMovie = new Movie(this, "About.mp4");
    myMovie.play();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>playing 2 or more video files simultaneously</title>
      <link>https://forum.processing.org/two/discussion/26945/playing-2-or-more-video-files-simultaneously</link>
      <pubDate>Tue, 20 Mar 2018 18:06:37 +0000</pubDate>
      <dc:creator>carterdjohnson</dc:creator>
      <guid isPermaLink="false">26945@/two/discussions</guid>
      <description><![CDATA[<p>I want to overlay multiple video files (they're saved inside my data folder). I am able to load one successfully, but the moment I try more than one, all I hear is the audio and the video never loads. Below is some simplified code as an example that doesn't function for me:</p>

<pre><code>import processing.video.*;

Movie vidFile1;
Movie vidFile2;

void setup()
{ 
  size(1920, 1080);
  background(0);


  vidFile1 = new Movie(this, "video1.mp4");
  vidFile1.loop();
  vidFile2 = new Movie(this, "video2.mp4");
  vidFile2.loop();
}

void movieEvent(Movie vidFile1, Movie vidFile2)
{
  vidFile1.read();
  vidFile2.read();
}

void draw()
{
  image(vidFile1,0,0);
  image(vidFile2,720,0);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Kinect and .mov files</title>
      <link>https://forum.processing.org/two/discussion/26694/kinect-and-mov-files</link>
      <pubDate>Wed, 07 Mar 2018 15:27:41 +0000</pubDate>
      <dc:creator>karinalopez87</dc:creator>
      <guid isPermaLink="false">26694@/two/discussions</guid>
      <description><![CDATA[<p>I'm having trouble controlling the .mov file's tint with rawdepth from kinect</p>

<pre><code> import org.openkinect.processing.*;
 import processing.video.*;
  Movie video;
  Kinect2 kinect2;
 int minDepth=0;
  int maxDepth=4500; //4.5m
  void setup() {
  size(1920,1080);
  video = new Movie(this, "final-02.mov");
  video.loop();
  kinect2 = new Kinect2(this);
  kinect2.initDepth();
  kinect2.initDevice();
  }
  void movieEvent(Movie video){
 video.read();
  }
  void draw() { 
  image(video, 0, 0);
  video.loadPixels();

int[] depth = kinect2.getRawDepth();

for (int x = 0; x &lt; kinect2.depthWidth; x++){
  for (int y = 0; y &lt; kinect2.depthHeight; y++){
    int offset = x + y * kinect2.depthWidth;
    int d = depth[offset];


    if (d &gt; 10 &amp;&amp; d &lt; 400){
      //video.pixels[offset] = color(255, 100, 15);
      tint(10,255);
    } else {
      //video.pixels[offset] = color(150, 250, 180);
      tint(250,10);
    }
  }
  println(x);
}

  video.updatePixels();
  image(video,0,0);
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>using fullScreen() to play videos on three different monitors</title>
      <link>https://forum.processing.org/two/discussion/26720/using-fullscreen-to-play-videos-on-three-different-monitors</link>
      <pubDate>Thu, 08 Mar 2018 20:22:11 +0000</pubDate>
      <dc:creator>m4rdones</dc:creator>
      <guid isPermaLink="false">26720@/two/discussions</guid>
      <description><![CDATA[<p>Hi there. 
I'm trying to play three different videos in three different monitors for an art project. I'm using three LED TVs which I set them in 1280x720 pixels each. The code (and the project) includes an ultrasonic sensor that allows to play or stop the videos, but the main issue is that I can't use the <code>fullScreen(P2D, SPAN);</code> function(?). It gaves me the "Framebuffer objects are not supported by this hardware (or driver)..." error. What can I do?!. I searched for info but I didn't find anything. 
So...If you remember any thread or info or a past project with this issue, please comment</p>

<p>Thank you thank you thank you!!</p>

<p>Here's the code:</p>

<pre><code>//import processing.serial.Serial;
import processing.video.*;

//Serial myPort;
//String val;   
Movie video1, video2, video3;

void settings() {
  fullScreen(P2D,SPAN);
}

void setup() {

  background(0);
  video1 = new Movie(this, "estas ahi.mp4");
  video2 = new Movie(this, "estas lejos.mp4");
  video3 = new Movie(this, "me gustaria estar aqui.mp4");
  video1.stop();
  video2.loop();
  video3.stop();
  //String portName = Serial.list()[0];
  //myPort = new  Serial(this, portName, 9600);
  //myPort.bufferUntil('\n');
}

//void serialEvent (Serial myPort) {
  //if (myPort.available() &gt; 0) {
    //val=myPort.readStringUntil('\n');
  //}

//}

//void serialEvent(final Serial s) {
  //val = s.readString().trim();
//}

void draw() {
  //println(val);
  image(video1,480,320,640,480);
  image(video2,120,0,640,480);
  image(video3,200,0,640,480);

} 

void movieEvent(Movie video) {
  video.read();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>play videos and mousepressed</title>
      <link>https://forum.processing.org/two/discussion/26590/play-videos-and-mousepressed</link>
      <pubDate>Thu, 01 Mar 2018 12:34:22 +0000</pubDate>
      <dc:creator>jackpot</dc:creator>
      <guid isPermaLink="false">26590@/two/discussions</guid>
      <description><![CDATA[<p>Hi, i am recently doing some work using processing and arduino. i am new.. so it might be basic question.
there are totally 7 videos. and two separate arrays(or playlist)? 
list1&gt;videos 1, 2, 3, 4
list2&gt; videos 5,6,7</p>

<p>so when it starts, list1 will be played, (1-4)
and if you press the mouse, current video will stop and playlist 2 videos randomly (5~7).
and after the video ends, it returns to play list1.</p>

<p>this code is working to playing list 1
and if i press the mouse, the movie stops for a sec and play again. not going to play list 2...</p>

<p>TT...</p>

<pre><code>  import processing.serial.*;
  import cc.arduino.*;
  import processing.video.*;


  Serial myPort;  // Create object from Serial class
  String val;     // Data received from the serial port
  Arduino arduino;

  int buttonPin = 7;

  Movie myMovie1, myMovie2, myMovie3, myMovie4, myMovie5;
  boolean playMovie1=true;
  boolean playMovie2=false;
  boolean playMovie3=false;
  boolean playMovie4=false;
  boolean playMovie5=false;
  float movieEndDuration = 1.029719;

  int fps = 25;
  String[] moviesNames = { 
    "4.mp4", "5.mp4", "6.mp4" };
  int index = int(random(moviesNames.length));
  Movie[] movies;

  void setup() {
    myPort = new Serial(this,"/dev/cu.usbmodem1451", 9600);
    String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port
    arduino = new Arduino(this, Arduino.list()[0], 9600);
    arduino.pinMode(buttonPin, Arduino.INPUT);
    size(1280, 360);
    frameRate(fps);
    movies = new Movie[moviesNames.length];
    for (int i = 0; i &lt; moviesNames.length; i++) {
      movies[i] = new Movie(this, moviesNames[i]);
    }
    myMovie1 = new Movie(this, "t0.mp4");
    myMovie2 = new Movie(this, "t1.mp4");
    myMovie3 = new Movie(this, "t2.mp4");
    myMovie4 = new Movie(this, "t3.mp4");
    myMovie5 = new Movie(this, "t4.mp4");
  }

  void draw() {
    background(0);
    myMovie1.volume(10); 
    myMovie2.volume(10); 
    myMovie3.volume(10); 
    myMovie4.volume(10); 
    myMovie5.volume(10); 
    image(movies[index], 0, 0, width, height);


  if (playMovie1==true) {
    myMovie1.play();
    image(myMovie1, 0, 0, width, height);


  }


  if ((myMovie1.time() + movieEndDuration) &gt;= myMovie1.duration()) {
    {
      myMovie1.stop();
      playMovie1=false;
      playMovie2=true;
    }
  }


  if (playMovie2==true) {

    myMovie2.play();
    image(myMovie2, 0, 0, width, height);

    if ((myMovie2.time() + movieEndDuration) &gt;= myMovie2.duration()) {
      {
        myMovie2.stop();
        playMovie2=false;
        playMovie3=true;
      }
    }
  }

  if (playMovie3==true) {

    myMovie3.play();
    image(myMovie3, 0, 0, width, height );

    if ((myMovie3.time() + movieEndDuration) &gt;= myMovie3.duration()) {
      {
        myMovie3.stop();
        playMovie3=false;
        playMovie4=true;
      }
    }
  }

  if (playMovie4==true) {

    myMovie4.play();
    image(myMovie4, 0, 0, width, height);
    if ((myMovie4.time() + movieEndDuration) &gt;= myMovie4.duration()) {
      {
        playMovie4=false;
        playMovie5=true;
      }
    }
  }
  }
  void movieEvent(Movie m) {
    m.read();
  }



  // Stops the movie playback when the mouse pressed
  void mousePressed() {
     myMovie1.stop();
    myMovie2.stop();
     myMovie3.stop();
    myMovie5.stop();
     movies[index].play(); 
     // assign newly picked random value to index:
  movies[index].loop(); // and start playing it.
  // Stops the movie playback when the mouse pressed
   int rnd; // keep picking a new index till got a diff. 1:
  while ( (rnd = (int) random(movies.length)) == index );

  // assign newly picked random value to index:
  movies[index].loop(); // and start playing it.
  } 
</code></pre>
]]></description>
   </item>
   <item>
      <title>Interactive video with sound input</title>
      <link>https://forum.processing.org/two/discussion/26401/interactive-video-with-sound-input</link>
      <pubDate>Sat, 17 Feb 2018 13:41:10 +0000</pubDate>
      <dc:creator>komats</dc:creator>
      <guid isPermaLink="false">26401@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I will soon have to make interactive video. As I know a little bit of Processing language, think I should use it for my project.</p>

<p>I have been searching for inspiration and found one of ideas (that might not be as complex for me as a beginer).</p>

<p>So the main question is this:</p>

<p>Is it possible in Processing to code smth like this:</p>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-sCaOy5VukCs"><span class="VideoPreview"><a href="http://youtube.com/watch?v=sCaOy5VukCs"><img src="http://img.youtube.com/vi/sCaOy5VukCs/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>

<p>The main idea is to make some black&amp;white background "come to life" with the sounds. The input sounds make random different blurry color splashes that stays for a while, but doesn't disappear very fast.</p>

<p>Would like to make it a bit complex by having those colorful flashes on top of some video.</p>

<p>Any tuts/videos on mind, where I could learn something similar?</p>
]]></description>
   </item>
   <item>
      <title>Unexpected token : void</title>
      <link>https://forum.processing.org/two/discussion/26498/unexpected-token-void</link>
      <pubDate>Fri, 23 Feb 2018 10:31:00 +0000</pubDate>
      <dc:creator>karlito</dc:creator>
      <guid isPermaLink="false">26498@/two/discussions</guid>
      <description><![CDATA[<p>Hello, here is my program which contains 2 sounds and 2 videos, each one connected to one key. I think everything is almost rightly coded but some error message appear at the end, and my last line" void movieEvent(Movie movie) {" is  highlighted.. 
I dont understand, thanks for your helpp</p>

<p>/**  Affiche tactile interactive - 
*  Quand on appuie sur une touche, cela lance une image, une vidéo, une annim, un son, etc...
<em>/
/// librairies
import processing.sound.</em>;
import processing.video.*;</p>

<p>// variables globales
SoundFile son; // un son
Movie vid; // une vidéo</p>

<p>// bouton son actif ?
boolean son_actif = false;
float tempsDebutSon = 0; // temps du début de la musique a été joué</p>

<p>// bouton son actif1 ?
boolean son_actif1 = false;
float tempsDebutSon1 = 0; // temps du début de la musique a été joué</p>

<p>// bouton video active ?
boolean video_active = false;</p>

<p>// bouton video active1 ?
boolean video_active1 = false;</p>

<p>void setup() {
  //size();
  noStroke();
  background(0);
  fullScreen ();</p>

<p>// chargement du son
  son = new SoundFile(this, "NORMAL.mp3");
  //println(son.duration());</p>

<p>// chargement du son1
  son1 = new SoundFile(this, "MODIF.mp3");
  //println(son.duration());</p>

<p>//// chargement de la video
  vid = new Movie(this, "videos/VID1.mp4");</p>

<p>//// chargement de la video1
  vid1 = new Movie(this, "videos/VID2.mp4");</p>

<p>}</p>

<p>void draw() {</p>

<p>// gestion du son : voir dans keypressed()</p>

<pre><code>// gestion de la vidéo ////////////////////////////////////////
 if (video_active){
   image(vid, 0, 0, width, height);
 }

  if (video_active1){
   image(vid, 0, 0, width, height);
 }
</code></pre>

<p>}</p>

<p>void keyPressed() {
  if (key == CODED) { 
    if (keyCode == RIGHT) { // son
      if (son_actif==false){ // le son ne joue pas
        son.play(); // lancer le son
        son_actif = true; // bouton son_actif on</p>

<p>if (key == CODED) { 
    if (keyCode == RIGHT) { // son1
      if (son_actif1==false){ // le son ne joue pas
        son.play(); // lancer le son
        son_actif1 = true; // bouton son_actif on
      }
    }
     if (keyCode == UP) { // video
     // chargement de la video
      vid = new Movie(this, "videos/VID1.mp4"); 
      // lancement de la video en boucle
      vid.loop();
      // bouton actif
      video_active = true;
      //arreter les autres animations
      video_active1 = false;
    } 
    if (keyCode == LEFT) { // video1
     // chargement de la video1
      vid = new Movie(this, "videos/VID2.mp4"); 
      // lancement de la video en boucle
      vid.loop();
      // bouton actif
      video_active1 = true;
      //arreter les autres aninmations
      video_active = false;
    } 
  }
}</p>

<p>void movieEvent(Movie movie) {
  m.read();
}</p>
]]></description>
   </item>
   <item>
      <title>Connect PIR sensor to launch a webcam and a sound</title>
      <link>https://forum.processing.org/two/discussion/26474/connect-pir-sensor-to-launch-a-webcam-and-a-sound</link>
      <pubDate>Wed, 21 Feb 2018 23:46:34 +0000</pubDate>
      <dc:creator>braisremeseiro</dc:creator>
      <guid isPermaLink="false">26474@/two/discussions</guid>
      <description><![CDATA[<p>Hi again,</p>

<p>I am trying to connect Arduino with Processing using a PIR Sensor. The code in Arduino is alright, however I can not synchronize both to detect the movement and open the webcam and the sound. Please, Can you help me?.</p>

<p>Arduino:</p>

<pre><code>//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;       

//the time when the sensor outputs a low impulse
long unsigned int lowIn;        

//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 5000; 

boolean lockLow = true;
boolean takeLowTime; 

int pirPin = 3;    //the digital pin connected to the PIR sensor's output
int ledPin = 13;


/////////////////////////////
//SETUP
void setup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(pirPin, LOW);

//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(int i = 0; i &lt; calibrationTime; i++){
  Serial.print(".");
  delay(1000);
  }
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}

 ////////////////////////////
 //LOOP
 void loop(){

 if(digitalRead(pirPin) == HIGH){
   digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
   if(lockLow){ 
     //makes sure we wait for a transition to LOW before any further output is made:
     lockLow = false;           
     Serial.println("---");
     Serial.print("motion detected at ");
     Serial.print(millis()/1000);
     Serial.println(" sec");
     delay(50);
     }        
     takeLowTime = true;
    }

   if(digitalRead(pirPin) == LOW){      
   digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state

   if(takeLowTime){
    lowIn = millis();          //save the time of the transition from high to LOW
    takeLowTime = false;       //make sure this is only done at the start of a LOW phase
    }
   //if the sensor is low for more than the given pause,
   //we assume that no more motion is going to happen
   if(!lockLow &amp;&amp; millis() - lowIn &gt; pause){ 
       //makes sure this block of code is only executed again after
       //a new motion sequence has been detected
       lockLow = true;                       
       Serial.print("motion ended at ");      //output
       Serial.print((millis() - pause)/1000);
       Serial.println(" sec");
       delay(50);
       }
     }
     }
</code></pre>

<p>Processing:</p>

<pre><code>import processing.serial.*;
import processing.video.*;
import ddf.minim.*;
import ddf.minim.AudioPlayer;

// Size of each cell in the grid
int cellSize = 20;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture inputCam01;
Movie topLayer;
Minim minim;
AudioPlayer song;
Serial myPort;

void setup() 
{
size(1280, 720);
frameRate(30);
cols = width / cellSize;
rows = height / cellSize;
colorMode(RGB, 255, 255, 255, 100);

// This the default video input, see the GettingStartedCapture 
// example if it creates an error
inputCam01 = new Capture(this, width, height);

// Start capturing the images from the camera
inputCam01.start();  
background(0);

// we pass this to Minim so that it can load files from the data directory
minim = new Minim(this);

// loadFile will look in all the same places as loadImage does.
// this means you can find files that are in the data folder and the 
// sketch folder. you can also pass an absolute path, or a URL.
song = minim.loadFile("data/untitled.wav");
song.play();
song.loop();
}
{
// I know that the first port in the serial list on my mac
// is Serial.list()[0].
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
 String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port
 myPort = new Serial(this, portName, 9600);
}
void movieEvent(Movie topLayer)  
{  
topLayer.read();
}


void draw() 
{ 
if (inputCam01.available()) {
inputCam01.read();
inputCam01.loadPixels();
image(inputCam01, 0, 0);

// Begin loop for columns
for (int i = 0; i &lt; cols; i++) {
  // Begin loop for rows
  for (int j = 0; j &lt; rows; j++) {
    // Where are we, pixel-wise?
    int x = i*cellSize;
    int y = j*cellSize;
    int loc = (inputCam01.width - x - 1) + y*inputCam01.width; // Reversing x to mirror       the image

    float r = red(inputCam01.pixels[loc]);
    // Make a new color with an alpha component
    color c = color(r, 50, 50, 75);

    // Code for drawing a single rect
    // Using translate in order for rotation to work properly
    pushMatrix();
    translate(x+cellSize/2, y+cellSize/2);
    // Rotation formula based on brightness
    rotate((2 * PI * brightness(c) / 255.0));
    rectMode(CENTER);
    fill(c);
    noStroke();
    // Rects are larger than the cell for some overlap
    rect(0, 0, cellSize+6, cellSize+6);
    popMatrix();
}
}
}
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Play and replay the video after few second of the playing time message.</title>
      <link>https://forum.processing.org/two/discussion/26370/play-and-replay-the-video-after-few-second-of-the-playing-time-message</link>
      <pubDate>Thu, 15 Feb 2018 21:10:43 +0000</pubDate>
      <dc:creator>moonilsun</dc:creator>
      <guid isPermaLink="false">26370@/two/discussions</guid>
      <description><![CDATA[<p>Hello</p>

<p>I was trying to make a code for playing my project. 
But I couldn't figure out how to make the same video play and after finished showing few second (maybe 5 seconds) of how many times video played. and again playing the video.</p>

<ol>
<li>after the finished video, then showing the message</li>
<li>the message counting how many times played.</li>
<li>5 sec after automatically play again.</li>
</ol>

<p>It could be a very obvious question, but few days of searching, I still couldn't find the solution...</p>

<p>please anyone can advise on this problem?</p>

<pre><code>import processing.video.Movie;

Movie vid;
boolean ended;

void setup() {
  frameRate(30);
  textSize(050);
  textAlign(CENTER, BASELINE);
  fill(0);

  vid = new Movie(this, "StudioOutside.mov") {
    @ Override public void eosEvent() {
      super.eosEvent();
      myEoS();
    }
  };

  vid.play();
  while (vid.width == 0 | vid.height == 0)  delay(10);

  surface.setSize(vid.width, vid.height); // P3
  //size(vid.width, vid.height); // P2
}

void draw() {
  if (!ended)  background(vid);
  else {
    if (key == ' ' || key == ' ') {
      keyPressed = true;
    if (keyPressed == true) {
     background(vid);
     vid.play();
    }
      } else {
    vid.stop();
    background(255);
    text("Playback has finished!", width&gt;&gt;1, height&gt;&gt;1);
  }
  }
}

void movieEvent(final Movie m) {
  m.read();
}

void myEoS() {
  ended = true;
  frameRate(1);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>GLSL and video Texture</title>
      <link>https://forum.processing.org/two/discussion/26054/glsl-and-video-texture</link>
      <pubDate>Sat, 20 Jan 2018 23:12:54 +0000</pubDate>
      <dc:creator>vjjv</dc:creator>
      <guid isPermaLink="false">26054@/two/discussions</guid>
      <description><![CDATA[<p>hello everyone. Im trying to pass a video as a texture into a fragment shader. but the sketch crash when i run it.</p>

<p>here is the code:</p>

<pre><code>  import processing.video.*;
import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.*;

PeasyCam cam;
PShader sh;
float count;
Movie mov;
PGraphics p;

void setup (){

size(1440, 900, P3D );
mov = new Movie(this, "osc_noc.mov");
mov.play();
p = createGraphics(width,height);
cam = new PeasyCam(this, 500);
sh = loadShader("basicShaderFrag.glsl", "basicShader.glsl");
}

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

void draw(){
background(0);
shader(sh);
count +=0.09;
sh.set("u_time", count);

sphere(100);
p.beginDraw();
p.background(0);
p.image(mov, 0, 0, 200, 200);
p.endDraw();
sh.set("tex",p);
// image(p, 5, 260 ,200, 200);
}

#version 150

uniform mat4 transform;
uniform sampler2D tex;

in vec4 position;
in vec2 texCoord;
in vec3 normal;

out vec2 TexCoord;

void main(){

  TexCoord = texCoord;
  gl_Position = transform * position;
}


#ifdef GL_ES
precision mediump float;
#endif

#define PI 3.14

in vec2 TexCoord;
uniform float u_time;
uniform sampler2D tex;

void main(){
  vec2 uv = TexCoord;

  gl_FragColor = vec4(texture(tex, TexCoord));
}
</code></pre>

<p>a white screen appears, and next it close. the console just say: "Finished". 
it may be a bug? i could pass a PImage as a texture. but when i link the fragment and shader program into the sketch folder then crash. ..</p>
]]></description>
   </item>
   <item>
      <title>Movie.duration() always returns 0.0, framerate() and speed() do not seem to affect playback</title>
      <link>https://forum.processing.org/two/discussion/26225/movie-duration-always-returns-0-0-framerate-and-speed-do-not-seem-to-affect-playback</link>
      <pubDate>Sat, 03 Feb 2018 07:06:49 +0000</pubDate>
      <dc:creator>ajohnsonlaird</dc:creator>
      <guid isPermaLink="false">26225@/two/discussions</guid>
      <description><![CDATA[<p>I've just started to experiment with the Movie library and I've run into some basic questions.</p>

<p>Here's the testbed code:</p>

<pre><code>import processing.video.*;
Movie myMovie;
int screenSizeX = 800;
int screenSizeY = 600;
float duration = 0;

void settings()
{
  size(screenSizeX, screenSizeY);
}
void setup() {

  myMovie = new Movie(this, "20180201103135_20180201103155_01_M.dav");
  myMovie.frameRate(25);
  myMovie.speed(0.01);
  duration = myMovie.duration();
  println("setup duration =" + duration);
  duration = myMovie.playbin.queryDuration().toSeconds();
  println("setup playbin.queryDuration() duration =" + duration);
  myMovie.loop();
}

void draw() {
  image(myMovie, 0, 0);
  println("Duration=" + myMovie.duration());
}

// Called every time a new frame is available to read
void movieEvent(Movie m) {
  m.read();
  duration = myMovie.duration();
  println("movieEvent duration =" + duration);
}
</code></pre>

<p>When I run it, duration always appear to return 0.0 regardless of when I test it -- including if I call playbin directly (mimicking the library code at line 270 here: <a rel="nofollow" href="https://github.com/processing/processing-video/blob/master/src/processing/video/Movie.java">https://github.com/processing/processing-video/blob/master/src/processing/video/Movie.java</a> ).</p>

<p>The console output is:<br />
    setup duration =0.0<br />
    setup playbin.queryDuration() duration =0.0<br />
    movieEvent duration =0.0<br />
    Duration=0.0<br />
    Duration=0.0<br />
    movieEvent duration =0.0<br />
    Duration=0.0<br />
    :<br /></p>

<p>What I was really trying to do (apart from experimenting with playback at various speeds) was figure out how to detect when a Movie has finished playing? I've seen some example code that did this:</p>

<pre><code>if (myMovie.time() &gt;= myMovie.duration()) // Test if the playhead is at the end
{
   // end of Movie
}
</code></pre>

<p>Of course that's destined to fail if .duration() always returns zero. So that raises the question, how do you tell when a movie has finished?? I supposed I could check when .time() stops changing, but that squawks a dreaded red text error on the console when the code runs "off the end" of the Movie.</p>

<p>Anyone got any ideas how you test for when a Movie has finished playing? I need to work my way through a directory with hundreds of different movie files and extract individual frames -- I've figured out what I thought would be the hard part only to screech to a halt on this "simple" problem. :(</p>

<p>Oh....and anyone got any ideas why myMovie.frameRate() and .speed() don't appear to do anything?</p>

<p>Thanks in advance
Andy</p>
]]></description>
   </item>
   <item>
      <title>Capture movie and video (It is all wrong?)</title>
      <link>https://forum.processing.org/two/discussion/26211/capture-movie-and-video-it-is-all-wrong</link>
      <pubDate>Thu, 01 Feb 2018 20:23:34 +0000</pubDate>
      <dc:creator>yioko</dc:creator>
      <guid isPermaLink="false">26211@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I am very new on processing and try to make a capture movie with recorded video, but unfortunately, I can not fix it for many days and nights. I am very tired of all this. I want to quit but must to do for a college, and maybe in the future for installation. Can any of you help me please, and show me where is the problem(s)?
Thank you
(sorry for my English languages, are not my native languages)</p>

<pre><code>                                        import processing.video.*;

                                        int numPixels;
                                        // Number of columns and rows in the system
                                        int[] previousFrame;
                                        // Variable for capture device
                                        Movie movie;
                                        Capture video;


                                        void setup() { 
                                           size(640, 480);
                                          movie = new Movie(this, "VROXI.mp4"); 
                                          movie.loop();
                                        }

                                        // Step 4. Read new frames from the movie.
                                        void movieEvent(Movie movie) {  
                                          movie.read();
                                        }

                                        // Step 5. Display movie.
                                        void draw() {
                                          image(movie, 0, 0);
                                          video = new Capture(this, width, height);

                                          // Start capturing the images from the camera
                                          video.start(); 
                                          video.read(); // Read the new frame from the camera
                                          video.loadPixels(); // Make its pixels[] array available

                                          numPixels = video.width * video.height;
                                          // Create an array to store the previously captured frame
                                          previousFrame = new int[numPixels];
                                          loadPixels();
                                        }
                                        // When using video to manipulate the screen, use video.available() and
                                        // video.read() inside the draw() method so that it's safe to draw to the screen

                                        {int movementSum = 0; // Amount of movement in the frame
                                        for (int i = 0; i &lt; numPixels; i++) { // For each pixel in the video frame...
                                          color currColor = video.pixels[i];
                                          color prevColor = previousFrame[i];
                                          // Extract the red, green, and blue components from current pixel
                                          int currR = (currColor &gt;&gt; 16) &amp; 0xFF; // Like red(), but faster
                                          int currG = (currColor &gt;&gt; 8) &amp; 0xFF;
                                          int currB = currColor &amp; 0xFF;
                                          // Extract red, green, and blue components from previous pixel
                                          int prevR = (prevColor &gt;&gt; 16) &amp; 0xFF;
                                          int prevG = (prevColor &gt;&gt; 8) &amp; 0xFF;
                                          int prevB = prevColor &amp; 0xFF;
                                          // Compute the difference of the red, green, and blue values
                                          int diffR = abs(currR - prevR);
                                          int diffG = abs(currG - prevG);
                                          int diffB = abs(currB - prevB);
                                          // Add these differences to the running tally
                                          movementSum += diffR + diffG + diffB;
                                          // Render the difference image to the screen
                                          pixels[i] = color(diffR, diffG, diffB);
                                          // The following line is much faster, but more confusing to read
                                          //pixels[i] = 0xff000000 | (diffR &lt;&lt; 16) | (diffG &lt;&lt; 8) | diffB;
                                          // Save the current color into the 'previous' buffer
                                          previousFrame[i] = currColor;
                                        }
                                        // To prevent flicker from frames that are all black (no movement),
                                        // only update the screen if the image has changed.
                                        if (movementSum &gt; 0) {
                                          updatePixels();
                                          println(movementSum); // Print the total amount of movement to the console
                                        }
                                        }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Existing Video to text with Ascii</title>
      <link>https://forum.processing.org/two/discussion/26198/existing-video-to-text-with-ascii</link>
      <pubDate>Wed, 31 Jan 2018 15:48:17 +0000</pubDate>
      <dc:creator>sevc</dc:creator>
      <guid isPermaLink="false">26198@/two/discussions</guid>
      <description><![CDATA[<p>Hello everybody,</p>

<p>I'm a real noob so I would realy apreciate if someone would tell me what's wrong with my code.
First I just want to use Ascii code to convert an existing video (not using webcam) to text. 
So I copy past the script- changing it a litle bit after I had some error with font- 
Anyway, now I dont have an error message but the sketch is just a black screen ....</p>

<p>Here is the code :</p>

<pre><code>import processing.video.*;
Movie video;
boolean cheatScreen;
String letterOrder =
  " .`-_':,;^=+/\"|)\\&lt;&gt;)iv%xclrs{*}I?!][1taeo7zjLu" +
  "nT#JCwfy325Fp6mqSghVd4EgXPGZbYkOA&amp;8U$@KHDBWNMR0Q";
char[] letters;

float[] bright;
char[] chars;

PFont font;
float fontSize = 1.5;
void setup() {
  size(1440, 1080);
  video = new Movie(this, "Torrent.mts");
  video.play();
 int count = video.width * video.height;
  font = loadFont("ProcessingSansPro-Regular-48.vlw");
    letters = new char[256];
  for (int i = 0; i &lt; 256; i++) {
    int index = int(map(i, 0, 256, 0, letterOrder.length()));
    letters[i] = letterOrder.charAt(index);
  }
    chars = new char[count];
      bright = new float[count];
  for (int i = 0; i &lt; count; i++) {
     bright[i] = 128;
  }
}
void MovieEvent(Movie m) {
  m.read();
}

void draw() {
  background(0);

  pushMatrix();

  float hgap = width / float(video.width);
  float vgap = height / float(video.height);

  scale(max(hgap, vgap) * fontSize);
  textFont(font, fontSize);

  int index = 0;
  video.loadPixels();
  for (int y = 1; y &lt; video.height; y++) {
     translate(0,  1.0 / fontSize);
      pushMatrix();
    for (int x = 0; x &lt; video.width; x++) {
      int pixelColor = video.pixels[index];
      int r = (pixelColor &gt;&gt; 16) &amp; 0xff;
      int g = (pixelColor &gt;&gt; 8) &amp; 0xff;
      int b = pixelColor &amp; 0xff;
 int pixelBright = max(r, g, b);
 float diff = pixelBright - bright[index];
      bright[index] += diff * 0.1;

      fill(pixelColor);
      int num = int(bright[index]);
      text(letters[num], 0, 0);
      index++;
 translate(1.0 / fontSize, 0);
    }
    popMatrix();
  }
  popMatrix();

  if (cheatScreen) {
    set(0, height - video.height, video);
  }
}
void keyPressed() {
  switch (key) {
    case 'g': saveFrame(); break;
    case 'c': cheatScreen = !cheatScreen; break;
    case 'f': fontSize *= 1.1; break;
    case 'F': fontSize *= 0.9; break;
}
}
</code></pre>

<p>Also, once I resolved this problem I would like to know how to use only a restreign number of letters (in a way that all the parts off the image that uses others letters will deseaper)</p>

<p>And sorry for my broken english, I'm french ;)</p>

<p>Thank you all for the help</p>
]]></description>
   </item>
   <item>
      <title>how do i trigger video without it freezing?</title>
      <link>https://forum.processing.org/two/discussion/26056/how-do-i-trigger-video-without-it-freezing</link>
      <pubDate>Sun, 21 Jan 2018 11:15:57 +0000</pubDate>
      <dc:creator>luketaylor96</dc:creator>
      <guid isPermaLink="false">26056@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys, i am currently working on a project where i need to read a database once to store a specific word in a variable, trigger a video to play and then repeat. However i can load the database in and pick out that specific word but when i get to the triggering it is like it plays one frame of the video and then freezes until the next repeat, I can't seem to solve this and some help would be great. Ill post my code below.</p>

<pre><code>import processing.video.*;
Movie joyMov, sadnessmMov, angerMov, fearMov, analyticalMov, confidentMov, tentativeMov;
JSONArray values;

String mLab = "";

String Joy = "Joy";
String Fear = "Fear";
String Anger = "Anger";
String Sadness = "Sadness";
String Analytical = "Analytical";
String Confident = "Confident";
String Tentative = "Tentative";
String tone1;

void setup() {
  size(640, 360);
  //fullScreen();
  //surface.setResizable(true);
  background(0);
  frameRate(30);
  joyMov = new Movie(this, "joy.mp4");
  sadnessmMov = new Movie(this, "");
  angerMov = new Movie(this, "");
  fearMov = new Movie(this, "");
  analyticalMov = new Movie(this, "");
  confidentMov = new Movie(this, "");
  tentativeMov = new Movie(this, "");
  joyMov.loop();
}

void draw() {

  float count = frameCount % 150;
  if (count == 0) { 
   readDB();
   println(tone1);
   if(tone1.equals(Joy) == true) {
     println("the tone is: Joy");
     playJoyMov();
   } else if(tone1.equals(Anger) == true) {
     println("the tone is: Anger");
   } else if(tone1.equals(Sadness) == true) {
     println("the tone is: Sadness");
   } else if(tone1.equals(Fear) == true) {
     println("the tone is: Fear");
   } else if(tone1.equals(Analytical) == true) {
     println("the tone is: Analytical");
   } else if(tone1.equals(Confident) == true) {
     println("the tone is: Confident");
   } else if(tone1.equals(Tentative) == true) {
     println("the tone is: Tentative");
   }
  }
}

void readDB(){
  //load json from mlabs db
  values = loadJSONArray(mLab);
      //println(values[values.size()]);

  //for (int i = 0; i &lt; values.size(); i++) {

    JSONObject tweet = values.getJSONObject(values.size()-1);
    println(tweet);

    //String location = tweet.getString("location");
    //String text = tweet.getString("tweet");
    //tone = tweet.values.getString("tone");
    tone1 = tweet.getString("tone");
    //println(location + " | " + text + " | " + tone);

  //}
}

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

void playJoyMov() {
  image(joyMov, 0, 0, width, height);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>opengl video sketch gets stuck after a minute</title>
      <link>https://forum.processing.org/two/discussion/26053/opengl-video-sketch-gets-stuck-after-a-minute</link>
      <pubDate>Sat, 20 Jan 2018 20:01:45 +0000</pubDate>
      <dc:creator>dehyde</dc:creator>
      <guid isPermaLink="false">26053@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to run a sketch (motion font) but after a minute or so it gets stuck no matter what
I'm getting a lot of errors</p>

<pre><code>java.lang.NullPointerException
    at processing.opengl.Texture.copyBufferFromSource(Texture.java:827)
    at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at processing.video.Movie.read(Unknown Source)
    at draft_write_text_and_blend.movieEvent(draft_write_text_and_blend.java:179)
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at processing.video.Movie.fireMovieEvent(Unknown Source)
    at processing.video.Movie.invokeEvent(Unknown Source)
    at processing.video.Movie$1.bufferFrame(Unknown Source)
    at org.gstreamer.elements.BufferDataAppSink$AppSinkNewBufferListener.newBuffer(BufferDataAppSink.java:163)
    at org.gstreamer.elements.AppSink$2.callback(AppSink.java:184)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:485)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:515)
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.
</code></pre>

<p>the code for the sketch itself:</p>

<pre><code>String str = "בבוקריוםאהזברהקמה";
String alphabet = "אבגדהוזחטיכךלמםנןסעפצץקרשת";
int wordsNum = 2;

int frameNum = 0;

int t = 0;

int[] wordsLength;

float fontMultiplier = 1;

float kerning =-110;
float leading =-100;
float charLocation = 0;
float lineLocation = 0;

float fontHeight = 122*fontMultiplier;
float fontWidth = 160*fontMultiplier;

float horMargin = 100+fontWidth;
float vertMargin = 70;

Movie[] letterAsso;


import processing.video.*;
void setup() {
  size(1200, 900, P2D);

  frameRate(60);

  // finding out how many words are there    (important for the wordsLength array)

  for (int i = 0; i&lt;str.length(); i++) {
    if (str.charAt(i)==' ') {
      wordsNum++;
    }
  }

  println("number of words is: ", wordsNum);

 int letCount = 0;

  wordsLength = new int[wordsNum];
  for (int i = 0; i&lt;str.length(); i++) {
    if (str.charAt(i)==' '||i==str.length()-1) {
      wordsLength[t]=letCount;
      letCount=0;
      t++;
    } else {
      letCount++;
    }
  }
  println(wordsLength);



  letterAsso = new Movie[alphabet.length()];
  for (int i=0; i&lt;alphabet.length(); i++) {
      letterAsso[i] = new Movie(this, alphabet.charAt(i)+".mov");
    }

  //for (int i=0; i&lt;alphabet.length()/3; i++) {

  //    letterAsso[i].loop();

  //      println("breakpointB"+i);
  //  }

  //for (int i=alphabet.length()/3; i&lt;2*alphabet.length()/3; i++) {

  //    letterAsso[i].loop();

  //      println("breakpointC"+i);
  //  }

  //for (int i=2*alphabet.length()/3; i&lt;alphabet.length(); i++) {

  //    letterAsso[i].loop();

  //      println("breakpointC"+i);
  //  }


  t=0;
}

void draw() {

  background(255);
  blendMode(MULTIPLY);

  if(frameCount-1&lt;alphabet.length()){
          letterAsso[frameCount-1].loop();
  }
  charLocation = 0;
  lineLocation = 0;
  t = 0;
  for (int let = 0; let &lt; str.length(); let++) {
    float letterxLocation = width-horMargin+charLocation-fontWidth;
     //println(str.length());
    image(letterAsso[alphabet.indexOf(str.charAt(let))], letterxLocation, vertMargin+lineLocation, fontWidth*fontMultiplier, fontHeight*fontMultiplier);
    //println(letterAsso[alphabet.indexOf(str.charAt(let))]);


    //for (int i=0; i&lt;str.length(); i++) {
    //  if (str.charAt(i)!=' ') {
    //    currentLetter[i] = new Movie(this, str.charAt(i)+".mov");
    //    //currentLetter[i].frameRate(2);
    //    currentLetter[i].loop();
    //    currentLetter[i].jump(random(0, 7));
    //  } else {
    //    currentLetter[i] = new Movie(this, "space.mov");
    //  }
    //}

    // Character Location

    charLocation = charLocation - fontWidth - kerning;

    // checking if it's a new word

    if (str.charAt(let)==' ' &amp;&amp; t &lt; wordsNum) {

      // creatng a new line

      if (width-horMargin+charLocation-wordsLength[t+1]*(fontWidth+kerning) &lt; horMargin) {
        charLocation = 0;
        lineLocation = lineLocation + fontHeight + leading;
      }
      t++;
    }
  }
  fill(0);
  textSize(16);


  text("Frame rate: " + int(frameRate), 10, 20);

  //saveFrame("output/framer_####.jpg");

  //blendMode(BLEND);
  //filter(INVERT);
}


void keyPressed(){
  if (keyCode == BACKSPACE) {
  if (str.length() &gt; 0) {
    str = str.substring(0, str.length()-1);
  }
} else if (keyCode == DELETE) {
  str = "";
} else if (keyCode != SHIFT) {
  str = str + key;
}
}

void movieEvent(Movie m) {
  m.read();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to switch between multiple movies?/Play movie after a movie?</title>
      <link>https://forum.processing.org/two/discussion/25847/how-to-switch-between-multiple-movies-play-movie-after-a-movie</link>
      <pubDate>Sat, 06 Jan 2018 14:13:14 +0000</pubDate>
      <dc:creator>liiwn</dc:creator>
      <guid isPermaLink="false">25847@/two/discussions</guid>
      <description><![CDATA[<p>Hello everybody.</p>

<p>I'm new here, so sorry if the question is something easy to solve. I'm working on a project and it doesn't work the way it should. Im selecting an area via a webcam. If something enters the selection (mensaanwezig) it should play a video.</p>

<p>There's playing a video at all times, myMovie 1 (should be looping).
When something enters it switches to myMovie 2.
When the person leaves/and when the end of myMovie2 has been reached, it should play myMovie3 at full length, regardless if something enters or leaves the area. after myMovie3 happened it should switch back to the start of myMovie 1.</p>

<p>I managed to get myMovie2 to play when somebody enters the area, but it switches back to myMovie 1 immediately when something leaves the area.</p>

<p>Can somebody tell me what i'm missing?</p>

<pre><code>import processing.video.*;

Movie myMovie;
Movie myMovie2;
Movie myMovie3;


int x, y, w=20, h=20 ;
int togglemouse=1;
int H, S, B, Hold, Sold, Bold;
int verschil, threshold=50;
int modeselector=1;
color kleur;
boolean mensaanwezig; 
boolean changed = false;

Capture cam;

void setup() {
  size(640, 480);
  //fullScreen();

  myMovie = new Movie(this, "Movie01B.mp4");
  myMovie2 = new Movie(this, "Movie02B.mp4");
  myMovie3 = new Movie(this, "Movie03B.mp4");

  myMovie.loop();
  myMovie2.loop();
  myMovie3.loop();

  cam = new Capture(this, 640, 480, "Logitech Webcam C930e");
  cam.start();
} 

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

..........................

void projectionmode() {

  if (mensaanwezig ==true) {
    if (changed==false) {
      changed=true;
      myMovie2.jump(0);
    }


    if (myMovie2.time() &lt; /**myMovie2.duration*/ 45) {
      myMovie2.play();
      image(myMovie2, 0, 0);
    } else {
      myMovie3.play();
      image(myMovie3, 0, 0);
      if (myMovie3.time() &lt;= /**myMovie3.duration*/ 45) {
        changed=false;
      }
    }
  } else {
    if (changed==true) {
      changed=false;
    }
    myMovie.play();
    image(myMovie, 0, 0);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to draw with color tracking?</title>
      <link>https://forum.processing.org/two/discussion/25866/how-to-draw-with-color-tracking</link>
      <pubDate>Mon, 08 Jan 2018 05:31:41 +0000</pubDate>
      <dc:creator>sph_831</dc:creator>
      <guid isPermaLink="false">25866@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I watched a lot of Daniel Shiffman tutorials and wanted to write a piece of code that draws out the path in which a certain color moves across the screen in my video. Lets say if my video were a skateboard, and I did a trick with color wheels on, I'd like to have the program draw the movement by following the colored wheels throughout it's movement.</p>

<p>What I have so far:</p>

<pre><code>// Most of this code I learned how to write thanks to Daniel Shiffman

import processing.video.*;

Movie video;

color trackColor; 
float threshold = 20;
float distThreshold = 75;

ArrayList&lt;Blob&gt; blobs = new ArrayList&lt;Blob&gt;();

void setup() {
  size(1080, 720);
  video = new Movie(this, "sk8.mov");
  video.loop();
  trackColor = color(206, 74, 129);
}

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

void keyPressed() {
  if (key == 'a') {
    distThreshold++;
  } else if (key == 'z') {
    distThreshold--;
  }
  println(distThreshold);
}

void draw() {
  video.loadPixels();
  image(video, 0, 0);

  blobs.clear();

  threshold = 62;

  for (int x = 0; x &lt; video.width; x++ ) {
    for (int y = 0; y &lt; video.height; y++ ) {
      int loc = x + y * video.width;
      color currentColor = video.pixels[loc];
      float r1 = red(currentColor);
      float g1 = green(currentColor);
      float b1 = blue(currentColor);
      float r2 = red(trackColor);
      float g2 = green(trackColor);
      float b2 = blue(trackColor);

      float d = distSq(r1, g1, b1, r2, g2, b2); 

      if (d &lt; threshold*threshold) {

        boolean found = false;
        for (Blob b : blobs) {
          if (b.isNear(x, y)) {
            b.add(x, y);
            found = true;
            break;
          }
        }

        if (!found) {
          Blob b = new Blob(x, y);
          blobs.add(b);
        }
      }
    }
  }

  for (Blob b : blobs) {
    if (b.size() &gt; 500) {
      b.show();
    }
  }
}


float distSq(float x1, float y1, float x2, float y2) {
  float d = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
  return d;
}

void mousePressed() {
  // Save color where the mouse is clicked in trackColor variable
  int loc = mouseX + mouseY*video.width;
  trackColor = video.pixels[loc];
}
class Blob {
  float minx;
  float miny;
  float maxx;
  float maxy;

  Blob(float x, float y) {
    minx = x;
    miny = y;
    maxx = x;
    maxy = y;
  }

  void show() {
    stroke(0);
    fill(255);
    strokeWeight(2);
    rectMode(CORNERS);
    rect(minx, miny, maxx, maxy);
  }

  void add(float x, float y) {
    minx = min(minx, x);
    miny = min(miny, y);
    maxx = max(maxx, x);
    maxy = max(maxy, y);
  }

  float size() {
    return (maxx-minx)*(maxy-miny); 
  }

  boolean isNear(float x, float y) {
    float cx = (minx + maxx) / 2;
    float cy = (miny + maxy) / 2;

    float d = distSq(cx, cy, x, y);
    if (d &lt; distThreshold*distThreshold) {
      return true;
    } else {
      return false;
    }
  }
}
</code></pre>

<p>What this code successfully does is track the color of the wheels on my skateboard, and follows the wheels throughout the clip. However, I am trying to figure out how to make it not just follow the wheels, but draw a line in the path where the wheels were before.</p>

<p>Any help would be greatly appreciated.</p>

<p>Thank you</p>
]]></description>
   </item>
   <item>
      <title>Associating videos to characters generatively</title>
      <link>https://forum.processing.org/two/discussion/25858/associating-videos-to-characters-generatively</link>
      <pubDate>Sun, 07 Jan 2018 21:36:15 +0000</pubDate>
      <dc:creator>dehyde</dc:creator>
      <guid isPermaLink="false">25858@/two/discussions</guid>
      <description><![CDATA[<p>Hi</p>

<p>I'm trying to create a movie-based typeface.
I want each letter to create a movie object. for example letter X needs to call X.mov and become an item in and array.</p>

<pre><code>   currentLetter = new Movie[str.length()];
  for (int i=0; i&lt;str.length(); i++) {
    currentLetter[i] = new Movie(this, str.charAt(i)+".mov");
    currentLetter[i].jump(random(currentLetter[i].duration()));
  }
</code></pre>

<p>this returns:</p>

<blockquote class="Quote">
  <p>"Could not load movie file  .mov"</p>
</blockquote>

<p>here is the entire code:</p>

<pre><code>String str = "abab aba";
int wordsNum = 1;

int t = 0;

int[] wordsLength;

float kerning = -130;
float leading = 0;
float charLocation = 0;
float lineLocation = 0;

float fontHeight = 120;
float fontWidth = 160;

float horMargin = 100;
float vertMargin = 100;

Movie[] currentLetter;


import processing.video.*;
void setup() {
  size(1200, 900);
  frameRate(30);
  // finding out how many words are there    (important for the wordsLength array)

  for (int i = 0; i&lt;str.length(); i++) {
    if (str.charAt(i)==' ') {
      wordsNum++;
    }
  }
  println("number of words is: ", wordsNum);


  int letCount = 0;

  wordsLength = new int[wordsNum];
  for (int i = 0; i&lt;str.length(); i++) {
    if (str.charAt(i)==' ') {
      wordsLength[t]=letCount;
      letCount=0;
      t++;
    } else {
      letCount++;
    }
  }
  println(wordsLength);

  currentLetter = new Movie[str.length()];
  for (int i=0; i&lt;str.length(); i++) {
    currentLetter[i] = new Movie(this, str.charAt(i)+".mov");
    currentLetter[i].jump(random(currentLetter[i].duration()));
  }


  t=0;
}

void draw() {
  background(255);
  blendMode(DARKEST);
  charLocation = 0;
  lineLocation = 0;
  t = 0;
  for (int let = 0; let &lt; str.length(); let++) {
    float letterxLocation = width-horMargin+charLocation-fontWidth;
    image(currentLetter[let], letterxLocation, vertMargin+lineLocation, fontWidth, fontHeight);

    // Character Location

    charLocation = charLocation - fontWidth - kerning;

    // checking if it's a new word

    if (str.charAt(let)==' ' &amp;&amp; t &lt; wordsNum) {

      // creatng a new line

      if (width-horMargin+charLocation-wordsLength[t]*(fontWidth+kerning) &lt; horMargin) {
        charLocation = 0;
        lineLocation = lineLocation + fontHeight + leading;
      }
      t++;
    }
  }
}

void movieEvent(Movie m) {
  m.read();
}
</code></pre>

<p>Any ideas? :)
Thank you!</p>
]]></description>
   </item>
   <item>
      <title>100% CPU utilisation when playing multiple videos using the video library</title>
      <link>https://forum.processing.org/two/discussion/14329/100-cpu-utilisation-when-playing-multiple-videos-using-the-video-library</link>
      <pubDate>Fri, 08 Jan 2016 01:14:24 +0000</pubDate>
      <dc:creator>alzxul</dc:creator>
      <guid isPermaLink="false">14329@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'm trying to play some movies and sound in a processing sketch; there are 10 movies and 1 sound file - all the movies are fairly small [&lt;=5MB]; I create them in setup and call .play() on them, and then in draw() I use image() on them, and I also use movieEvent() function to call .read() on them; whenever I run this the videos lag and my CPU spikes to 100%</p>

<p>Surely playing 10 concurrent movies isn't that onerous?</p>

<p>Does anyone have any ideas for how to improve the performance or can tell me if I'm doing something wrong or missing something?</p>

<p>Any help would be much appreciated, thanks</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>Movie files do not show, no error</title>
      <link>https://forum.processing.org/two/discussion/25854/movie-files-do-not-show-no-error</link>
      <pubDate>Sat, 06 Jan 2018 22:16:09 +0000</pubDate>
      <dc:creator>dehyde</dc:creator>
      <guid isPermaLink="false">25854@/two/discussions</guid>
      <description><![CDATA[<p>Hi
I'm trying to make video files load to represent letters (motion font basically);
For some reason the video files don't show. I tried following the examples but no succes. I'm also not getting any error.</p>

<p>Any ideas?</p>

<pre><code>String str = "abbaabbaa abb aabbaaab baaab";
int let  = 0;
int wordsNum = 1;

int t = 0;

int[] wordsLength;

float kerning = 0;
float leading = 0;
float charLocation = 0;
float lineLocation = 0;

float horMargin = 100;
float vertMargin = 100;

float fontHeight = 30;
float fontWidth = 40;


import processing.video.*;
Movie Alef;
Movie Bet;
Movie Gimel;
Movie Dalet;
Movie Hey;
Movie Vav;

public void setup() {
  size(1200, 900);

  // finding out how many words are there    (important for the wordsLength array)

  for (int i = 0; i&lt;str.length(); i++) {
    if (str.charAt(i)==' ') {
      wordsNum++;
    }
  }
  println("number of words is: ", wordsNum);


  int letCount = 0;

  wordsLength = new int[wordsNum];
  for (int i = 0; i&lt;str.length(); i++) {
    if (str.charAt(i)==' ') {
      wordsLength[t]=letCount;
      letCount=0;
      t++;
    } else {
      letCount++;
    }
  }
  println(wordsLength);

  //alef = loadImage("א.jpg");
  //bet = loadImage("ב.jpg");

  Alef = new Movie(this, "a.wmv");
  Alef.loop();
  Bet = new Movie(this, "b.wmv");
  Bet.loop();


  t=0;
}

void draw() {

  for (int let = 0; let &lt; str.length(); let++) {

    if (str.charAt(let)=='a') {
      image(Alef, width-horMargin+charLocation, vertMargin+lineLocation, fontWidth, fontHeight);
      println("a");
    };
    if (str.charAt(let)=='b') {
      image(Bet, width-horMargin+charLocation, vertMargin+lineLocation, fontWidth, fontHeight);
      println("b");
    };


    // Character Location

    charLocation = charLocation - fontWidth - kerning;
    //println(charLocation);


    // checking if it's a new word

    if (str.charAt(let)==' ' &amp;&amp; t &lt; wordsNum) {


      // creatng a new line

      if (width-horMargin+charLocation-wordsLength[t]*fontWidth &lt; horMargin) {
        charLocation = 0;
        lineLocation = lineLocation + fontHeight + leading;
      }
      t++;
    }



    //   if (width-horMargin+charLocation &lt; horMargin){

    //   }
  }
}

void movieEvent(Movie m) {
  m.read();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Movie</title>
      <link>https://forum.processing.org/two/discussion/25849/movie</link>
      <pubDate>Sat, 06 Jan 2018 16:37:31 +0000</pubDate>
      <dc:creator>Geist5000</dc:creator>
      <guid isPermaLink="false">25849@/two/discussions</guid>
      <description><![CDATA[<p>Hello I am trying to play a Video in my programm, but the audio is asynchronous. What did i worng?</p>

<pre lang="javascript">
import processing.video.*;
Movie movie;
void setup(){
  size(500,500);
  movie = new Movie(this,"Spieler 1_x264.mov");
  movie.play();
  
}

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

void movieEvent(Movie m){
  m.read();
}
</pre>
]]></description>
   </item>
   <item>
      <title>GreenScreen Effect for movie</title>
      <link>https://forum.processing.org/two/discussion/25647/greenscreen-effect-for-movie</link>
      <pubDate>Wed, 20 Dec 2017 00:13:04 +0000</pubDate>
      <dc:creator>Marhu</dc:creator>
      <guid isPermaLink="false">25647@/two/discussions</guid>
      <description><![CDATA[<p>I'm working on a greenscreen project right now and my task is to use a video with a greenscreen in the background. The green background should be replaced by an image. In the foreground, there is someone doing some random stuff (that doesn't matter). Only the green background is important.
So first I tried some steps which are easier, they all worked pretty good, but now I'm trying to replace the green pixels from the greenscreen in the backgorund with black colored pixels, so that we have a black background.
I used that code:</p>

<pre><code>import processing.video.*;   //importing the video library
Movie movie;   //declaring movie

void setup() {
  size(1280, 720);
  movie = new Movie(this, "greenscreen_hand.mp4");   //loading movie and..
  movie.loop();   //..looping the movie
}

void draw() {
  loadPixels();
  movie.loadPixels();
  for (int j = 0; j &lt; height; j++) {

    for (int i = 0; i &lt; width; i++) {

      int stelle = i+(j*width);   //iterating through the screen and setting the number of the index through the whole frame
      float red = red(movie.pixels[stelle]);   //RGB values of the pixel
      float green = green(movie.pixels[stelle]);
      float blue = blue(movie.pixels[stelle]);

      color c = color(0, 0, 0);   //black pixels

      if (red&gt;40 &amp;&amp; red&lt;80 &amp;&amp; green&gt;190 &amp;&amp; blue&gt;60 &amp;&amp; blue&lt;90) {   //if pixel is kind of green

        movie.set(i, j, c);   //new pixel color
      }
    }
  }

  image(movie, 0, 0);
}

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

void mousePressed() {   //that actually doesn't matter, it's just for some information from some steps before
  int stelle = mouseX+(mouseY*width);

  float red = red(movie.pixels[stelle]);
  float green = green(movie.pixels[stelle]);
  float blue = blue(movie.pixels[stelle]);

  println("R: " + red +" "+ "G: " + green +" "+ "B: " + blue);
}
</code></pre>

<p>Now I got a whole bunch of problems.
Well, sometimes there is an ArrayIndexOutOfBoundsException: 0
(I don't know why actually :/)
and sometimes it works and the video is starting, but the background is flickering (half-green and half-black)
(maybe because pixels are loading too slow in every millisecond frame?)</p>

<p>Can someone help me? Or some suggestions about what I could change?</p>
]]></description>
   </item>
   <item>
      <title>Video tracking for progress bar using movie and ControlP5</title>
      <link>https://forum.processing.org/two/discussion/25606/video-tracking-for-progress-bar-using-movie-and-controlp5</link>
      <pubDate>Sun, 17 Dec 2017 06:55:17 +0000</pubDate>
      <dc:creator>Izzy280</dc:creator>
      <guid isPermaLink="false">25606@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I have been coding a progress bar using some examples that I found. The bar is almost done but it doesn't constantly update. Can someone assist me in getting it to update while the video is playing?
<a href="https://forum.processing.org/two/discussion/8103/using-a-controlp5-slider-as-video-progress-bar#latest" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/8103/using-a-controlp5-slider-as-video-progress-bar#latest</a>
`</p>

<pre><code>//using processing video and movie
import processing.video.*;
import controlP5.*;
import java.awt.geom.*;
ControlP5 cp5;
Movie movie;

boolean play;
int speed = 1;
int progress;

   void setup() {
   size(1280, 360);
   cp5 = new ControlP5(this);
    background(0);
    // Load and play the video in a loop
    movie = new Movie(this, "video.mov");
   movie.play();
    movie.speed(speed);

 //Progress Bar
  ProgressBar p;
  p = new ProgressBar(cp5, "progress"); 
 p.setPosition(130, 345).setSize(350, 10).setRange(0,  (int) 
movie.duration()).listen(true);
//callback listener for Timeline object
 p.addCallback(new CallbackListener() {
  public void controlEvent(CallbackEvent theEvent) {
   if(theEvent.getAction() == ControlP5.ACTION_PRESS) {
    float x = theEvent.getController().getPointer().x();
    float a1 = 0;
    float a2 = theEvent.getController().getWidth();
    float b1 = theEvent.getController().getMin();
    float b2 = theEvent.getController().getMax();
    float val = map(x,a1,a2,b1,b2);
    theEvent.getController().setValue(val);
    println("now change movie time to ", val, movie.time());
   movie.jump((float) val);
      }
    }
  }
  );
 // a toggle to switch between play and pause mode
 cp5.addToggle("play")
.setPosition(10,375)
.setSize(50,19)
.getCaptionLabel().align(CENTER,CENTER);
 }
  void movieEvent(Movie m) {
  m.read();
 }
 void draw() {
   if (play) {
   // update the progressBar value/position
   // replace with audio-track position: progress = player.position();

 image(movie, width/2, 0, width/2, height);

   if (movie.available()) movie.read();
   progress = (int) movie.time();
 }
  }
      class ProgressBar extends Controller&lt;ProgressBar&gt; {
      public ProgressBar(ControlP5 theControlP5, String theName) {
      super(theControlP5, theName);
      setView(new ControllerView&lt;ProgressBar&gt;() {

   public void display(PGraphics pg, ProgressBar c) {
     pg.fill(!isMouseOver() ? c.getColor().getForeground():c.getColor().getActive());
    pg.rect(0, 0, c.getWidth(), c.getHeight());

    float val = map(c.getValue(),c.getMin(), c.getMax(), 0, c.getWidth()); 
    pg.fill(255);
    pg.rect(0, 0, val, c.getHeight());
  }
}
);
}

     public ProgressBar setValue(float theValue) {
     return super.setValue(constrain(theValue, getMin(), getMax()));
 }

  public ProgressBar setRange(int theStart, int theEnd) {
  _myMin = theStart;
  _myMax = theEnd;
  return this;
  }
}
</code></pre>

<p>`</p>
]]></description>
   </item>
   <item>
      <title>Draw random 'X' and remain drawing to same location.</title>
      <link>https://forum.processing.org/two/discussion/25415/draw-random-x-and-remain-drawing-to-same-location</link>
      <pubDate>Wed, 06 Dec 2017 11:24:36 +0000</pubDate>
      <dc:creator>leevanchief</dc:creator>
      <guid isPermaLink="false">25415@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,
My issue is with the drawX() function. At the moment it draws an 'X' in a random place which then disappears as the next frame of 'myVid' refreshes the screen. I want to be able to draw each individual 'X' to its random location but then continue draw to that same location throughout the sketch. Thus resulting in an ever growing number of 'X's across the screen. I think i need to assign each individual 'X' to an array as it is drawn in order for it to maintain its (x,y) position. But i am not sure how to go about this. Hope this is clear. Any help would be greatly appreciated:</p>

<pre><code>PFont font; 
import processing.video.*;
Movie myVid;
String letter = "X";
float x;
float y;
float interval  = 1200;
float currentTime;
int offset = 100;

void setup() {
  size(540, 540);
  background(254);
  myVid = new Movie(this, "seaClip_001.mp4");
  myVid.loop();
  //frameRate(0.5);
}

void draw() {
  image(myVid, 0, 0-offset, 540, 540);
  drawFrame();
  drawX();
}

void drawFrame() {
  shapeMode(CENTER);
  fill(1);
  rect(width/2, 0, 10, height);
  shapeMode(LEFT);
  rect(0, 390, width, 10);
  //fill(color'ffa7e8');
  fill(255, 167, 232);
  rect(0, 400, width, 140);
}

void drawX() {
  fill(0);
  font = createFont("Arial", 1);
  textFont(font);
   x = random(width);
   y = random(height);
  if (currentTime &gt; 1000)
    textSize(random(120, 500));
  text(letter, x, y);
  currentTime = millis() % interval; //
}

void movieEvent(Movie m) {
  m.read();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to trigger an action with face detection?</title>
      <link>https://forum.processing.org/two/discussion/25482/how-to-trigger-an-action-with-face-detection</link>
      <pubDate>Sat, 09 Dec 2017 23:44:10 +0000</pubDate>
      <dc:creator>arnolds112</dc:creator>
      <guid isPermaLink="false">25482@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
Is it possible to use face detection to trigger a video to play?
if webcam detects a face, video plays
im having trouble with achieving this</p>
]]></description>
   </item>
   <item>
      <title>I would like to play full movie every time when I touch yellow rectangle</title>
      <link>https://forum.processing.org/two/discussion/25451/i-would-like-to-play-full-movie-every-time-when-i-touch-yellow-rectangle</link>
      <pubDate>Fri, 08 Dec 2017 09:22:08 +0000</pubDate>
      <dc:creator>gyoza</dc:creator>
      <guid isPermaLink="false">25451@/two/discussions</guid>
      <description><![CDATA[<p>I have figured out how to play and stop a movie.</p>

<p>Here I would like to know 2 things.</p>

<ol>
<li><p>I dont want screen to become black when I stop a movie.</p></li>
<li><p>I would like to play full movie every time when I touch yellow rectangle.
In other words, I dont want to stop a movie in a middle of video.</p></li>
</ol>

<p>Thank You, Arigato m()m</p>

<pre><code>import processing.video.*; 
Movie movie;

void setup() {
  colorMode(HSB, 360, 100, 100); 
  size(1280, 720);
  movie = new Movie( this, "movie.avi");
  frameRate(60);
}

void ellipseFront() {
  fill(0, 100, 100);
  ellipse(width*1/3, height/2, 100, 100);
}

void ellipseBack() {
  fill(120, 100, 100);
  ellipse(width*2/3, height/2, 100, 100);
}

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

void playMovie() {
  fill(60, 100, 100);
  rect(100, 100, 200, 200); //yellow rectangle
  image( movie, 0, 0, width, height);
  if (mouseX &gt; 100 &amp;&amp; mouseX &lt;300 &amp;&amp; mouseY &gt; 100 &amp;&amp; mouseY &lt;300) {  //when I touch yellow rect play movie
    movie.play();
  } else {
    movie.stop();
  }
}

void draw() {
  background(360);
  ellipseBack();
  playMovie();
  ellipseFront();
}
</code></pre>
]]></description>
   </item>
   </channel>
</rss>