<?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 jump() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=jump%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:58:54 +0000</pubDate>
         <description>Tagged with jump() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedjump%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Trouble Assigning ASCII Values to Jump Points in Audio File</title>
      <link>https://forum.processing.org/two/discussion/27870/trouble-assigning-ascii-values-to-jump-points-in-audio-file</link>
      <pubDate>Sat, 28 Apr 2018 18:17:30 +0000</pubDate>
      <dc:creator>sammy</dc:creator>
      <guid isPermaLink="false">27870@/two/discussions</guid>
      <description><![CDATA[<p>Hi! I am trying to make a simple audio sampler by triggering 1 second segments of a 10 second audio file from the computer keyboard. In the code below, I'm trying to trigger second 1 of the file with the 'a' key, second 2 with the 's' key, and so on.</p>

<p>At the moment, this code doesn't make any sound, though I got the keyTyped() <a rel="nofollow" href="https://p5js.org/reference/#/p5/keyTyped">example</a> to trigger changes in a sketch. Is the problem in my use of <code>song.playMode('restart')</code>? Or should I <code>preload()</code> the sound? Or do I need to assign number ASCII values to the samples?</p>

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

<pre><code>var song;

function setup(){
  song = loadSound('10sec.mp3');
}

function keyTyped() {
    song.playMode('restart');
    if (keyCode === 'a') {
        song.jump(0, 1);
    } else if (keyCode === 's') {
        song.jump(5, 1);
    } else if (keyCode === 'd') {
        song.jump(2, 1);
    }
}
</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>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>Video error on reverse on video library</title>
      <link>https://forum.processing.org/two/discussion/14733/video-error-on-reverse-on-video-library</link>
      <pubDate>Tue, 02 Feb 2016 23:01:07 +0000</pubDate>
      <dc:creator>Per</dc:creator>
      <guid isPermaLink="false">14733@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>Im made this sketch but as soon as I hit reverse on the videolibrary with help of negative movie.speed it causes a error. Any solution?:</p>

<blockquote class="Quote">
  <p>(Processing core video:475): GStreamer-WARNING **: wrong STREAM_LOCK count 0</p>
  
  <p>(Processing core video:475): GStreamer-CRITICAL **: gst_segment_set_seek: assertion `start &lt;= stop' failed</p>
</blockquote>

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

Movie movie; // Step 1. Declare Movie object

void setup() {
  size(560, 480);
  // Step 2. Initialize Movie object
  movie = new Movie(this, "test1.mov");
  movie.loop();
  movie.jump(5);
  movie.pause();
}
// Step 4. Read new frames from movie
void movieEvent(Movie movie) {
  movie.read();
}
void draw() {
  image(movie, 650, 0);
}

void keyReleased() {
  if (key == 'a') movie.play(); // play
  if (key == 's') movie.pause(); // pause
  if (key == 'd') movie.stop(); // stop
  if (key == 'f') movie.jump(5); // jump
  movie.speed(1.0);
}

void keyPressed() {
  if (key == 'g') movie.speed(5.0); // forward
  if (key == 'h') movie.speed(-5.0); // reverse
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Minim Question: Is there a possibility to sync multiple mp3s?</title>
      <link>https://forum.processing.org/two/discussion/22960/minim-question-is-there-a-possibility-to-sync-multiple-mp3s</link>
      <pubDate>Tue, 06 Jun 2017 15:43:05 +0000</pubDate>
      <dc:creator>fransoletti</dc:creator>
      <guid isPermaLink="false">22960@/two/discussions</guid>
      <description><![CDATA[<p>Hello there, newbie here.</p>

<p>I made a sketch which plays 9 mp3 files simultaneously using Minim. Those 9 files represent a whole track split into its individual instruments. 
My problem is that the files are not being triggered at the exact same time and therefore don't play in sync.
Is there a way to preload the files in advance so processing can trigger them at the exact same time, or is there anything else i could do?</p>

<p>Thanks in advance! :)</p>

<pre><code>import ddf.minim.*;
Minim minim;
AudioPlayer player;
AudioPlayer player2;
AudioPlayer player3;
AudioPlayer player4;
AudioPlayer player5;
AudioPlayer player6;
AudioPlayer player7;
AudioPlayer player8;
AudioPlayer player9;

void setup()
{
  size(1128, 575, P2D);
  minim = new Minim(this); 
  player = minim.loadFile("track1.mp3");
  player2 = minim.loadFile("track2.mp3");
  player3 = minim.loadFile("track3.mp3");
  player4 = minim.loadFile("track4.mp3");
  player5 = minim.loadFile("track5.mp3");
  player6 = minim.loadFile("track6.mp3");
  player7 = minim.loadFile("track7.mp3");
  player8 = minim.loadFile("track8.mp3");
  player9 = minim.loadFile("track9.mp3");
}

void draw()
{
  background(240);
  stroke(150, 100, 40); 

  //WAVEFORMS
  for (int i = 0; i &lt; player.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player.bufferSize(), 0, width);
    line( x1, 75 + player.left.get(i)*50, x2, 75 + player.left.get(i+1)*50 );
    line( x1, 100 + player.right.get(i)*50, x2, 75 + player.right.get(i+1)*50 );
  }

  stroke(20, 150, 90); 

  for (int i = 0; i &lt; player2.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player2.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player2.bufferSize(), 0, width);
    line( x1, 125 + player2.left.get(i)*50, x2, 125 + player2.left.get(i+1)*50 );
    line( x1, 150 + player2.right.get(i)*50, x2, 125 + player2.right.get(i+1)*50 );
  }

  stroke(0, 70, 130); 

  for (int i = 0; i &lt; player3.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player3.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player3.bufferSize(), 0, width );
    line( x1, 175 + player3.left.get(i)*50, x2, 175 + player3.left.get(i+1)*50 );
    line( x1, 200 + player3.right.get(i)*50, x2, 175 + player3.right.get(i+1)*50 );
  }

  stroke(80, 70, 130); 

  for (int i = 0; i &lt; player4.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player4.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player4.bufferSize(), 0, width );
    line( x1, 225 + player4.left.get(i)*50, x2, 225 + player4.left.get(i+1)*50 );
    line( x1, 250 + player4.right.get(i)*50, x2, 225 + player4.right.get(i+1)*50 );
  }

  stroke(#9CC6A1); 

  for (int i = 0; i &lt; player5.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player5.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player5.bufferSize(), 0, width );
    line( x1, 275 + player5.left.get(i)*50, x2, 275 + player5.left.get(i+1)*50 );
    line( x1, 300 + player5.right.get(i)*50, x2, 275 + player5.right.get(i+1)*50 );
  }


  stroke(#FA8A56); 

  for (int i = 0; i &lt; player6.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player6.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player6.bufferSize(), 0, width );
    line( x1, 325 + player6.left.get(i)*50, x2, 325 + player6.left.get(i+1)*50 );
    line( x1, 350 + player6.right.get(i)*50, x2, 325 + player6.right.get(i+1)*50 );
  }

  stroke(#1ACFFF);

  for (int i = 0; i &lt; player7.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player7.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player7.bufferSize(), 0, width );
    line( x1, 375 + player7.left.get(i)*50, x2, 375 + player7.left.get(i+1)*50 );
    line( x1, 400 + player7.right.get(i)*50, x2, 375 + player7.right.get(i+1)*50 );
  }

  stroke(#D567DE); 

  for (int i = 0; i &lt; player8.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player8.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player8.bufferSize(), 0, width );
    line( x1, 425 + player8.left.get(i)*50, x2, 425 + player8.left.get(i+1)*50 );
    line( x1, 450 + player8.right.get(i)*50, x2, 425 + player8.right.get(i+1)*50 );
  }

  stroke(#5A555A);

  for (int i = 0; i &lt; player9.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player9.bufferSize(), 0, width);
    float x2 = map( i+1, 0, player9.bufferSize(), 0, width );
    line( x1, 475 + player9.left.get(i)*50, x2, 475 + player9.left.get(i+1)*50 );
    line( x1, 500 + player9.right.get(i)*50, x2, 475 + player9.right.get(i+1)*50 );
  }
}

void keyPressed()
{

    player.rewind();
    player.play();
    player2.rewind();
    player2.play();
    player3.rewind();
    player3.play();
    player4.rewind();
    player4.play();
    player5.rewind();
    player5.play();
    player6.rewind();
    player6.play();
    player7.rewind();
    player7.play();
    player8.rewind();
    player8.play();
    player9.rewind();
    player9.play();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to set the starting point of videos?</title>
      <link>https://forum.processing.org/two/discussion/21897/how-to-set-the-starting-point-of-videos</link>
      <pubDate>Sat, 08 Apr 2017 20:58:47 +0000</pubDate>
      <dc:creator>rickymarto</dc:creator>
      <guid isPermaLink="false">21897@/two/discussions</guid>
      <description><![CDATA[<p>I'd like to make a code which play portions of a loaded video, setting the starting point and the duration of those portions of clip. It is a sort of random granular playback.</p>

<p>How can I play a clip from a starting point which is not the beginning of a loaded clip? How can I set the duration of the grains?</p>

<p>I'm using the default video library.</p>

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

Movie video;

void setup() {
  size(600, 400);
  video = new Movie(this, "station.mov");
  video.loop();
}

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

void draw() {
  image(video, 0, 0);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Frame Accurate Interactive Video Playback - a solution for 1.5.x but not working in 3.x</title>
      <link>https://forum.processing.org/two/discussion/21585/frame-accurate-interactive-video-playback-a-solution-for-1-5-x-but-not-working-in-3-x</link>
      <pubDate>Fri, 24 Mar 2017 16:07:35 +0000</pubDate>
      <dc:creator>chrios1001</dc:creator>
      <guid isPermaLink="false">21585@/two/discussions</guid>
      <description><![CDATA[<p>After much hacking I have made a sketch that does frame accurate interactive video playback.
I based this on tips and code from the older processing forums.
BUT - it only works in processing 1.5.1
I had to use various workarounds, and I don't know why they work.
It is something to do with the conversion from time in seconds to an accurate frame number.
A limitation of the jump() command.</p>

<p>I'm posting this code in the hope that it might help others
and maybe to find a solution that works in Processing 3.x</p>

<p>here's the code with lots of comments and link to a reliable test video:</p>

<pre><code>/*
 An example of frame accurate interactive video playback
 Tested working for frame accurate interactive viewing of videos at 25fps and 30fps - any length.
 This only works in processing 1.5.1
 I cannot get it working in newer versions of Processing
 This is probably due to the switch to the gstreamer library

 Easiest way to check it's working is to use a movie file with the
 correct frame number printed on each frame so you can spot skipping frames
 as you use the keys: -/+ to navigate.

 The suitable video for this sketch (with it's numbered frames) can be d/ld here:
 <a href="http://33dd.com/processing/100_Numbered_frames_30fps.mov" target="_blank" rel="nofollow">http://33dd.com/processing/100_Numbered_frames_30fps.mov</a>
 */

import processing.video.*; 
Movie myMovie; 
float movieFps=30.00;//fps of the movie - please set to match your movie file
float advanceLength = 1/(movieFps-0.01);//get length of one frame in seconds - and subtract 0.01 (why -0.01 I don't know??)
//this movie is 30fps - but sketch is only accurate if we declare fps as 29.99fps - why??

void setup()
{ 
  size(640, 320, P2D);//P2D needed for processing 1.5.--
  //size(640, 320);//use this method in processing 2.++ - no more P2D
  background(0); 

  //load a movie with visible framenumbers - makes it easier to check accuracy
  myMovie = new Movie(this, "100_Numbered_frames_30fps.mov"); //see link at top for video source
  myMovie.loop();//play the movie
  myMovie.speed(0);//best way to stop the movie - pause() halts the thread - so we must use speed(0)
} 

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

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

void keyPressed()
{ //use - / +  keys to go back and forward one frame
  if (key == '-')
  {
    if (myMovie.time() &lt; advanceLength)//if movie time &lt; 1 frame jump to start of movie (another hack needed to make it work)
    {
      myMovie.jump((myMovie.time() - advanceLength) % 0);
    } else  
    {//for some reason this only works accurately if we jump backwards then forward one frame
      myMovie.jump((myMovie.time() - advanceLength) % myMovie.duration()); 
      myMovie.jump((myMovie.time() + advanceLength) % myMovie.duration());
    }
  }  
  if (key == '=')
  {
    //jump forward by one frame 
    myMovie.jump((myMovie.time() + advanceLength) % myMovie.duration());
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Video 1.0.1 - Read a frame from a paused video?</title>
      <link>https://forum.processing.org/two/discussion/20383/video-1-0-1-read-a-frame-from-a-paused-video</link>
      <pubDate>Fri, 20 Jan 2017 20:37:56 +0000</pubDate>
      <dc:creator>Krystman</dc:creator>
      <guid isPermaLink="false">20383@/two/discussions</guid>
      <description><![CDATA[<p>I'm using Processing to make a small app. I want to display and edit text overlays on top of a video file - similar to subtitles. For that, I want to be able to jump a paused video to a specific timecode and display the video frame at that time. Unfortunately, this doesn't seem to work.</p>

<p>So if I make something like this:</p>

<p><code>movie.pause();
movie.jump(30);
movie.read();</code></p>

<p>The video will NOT show the frame at second 30, but whatever frame was on the screen before the jump. If I jump around in the video the same frame keeps being displayed until I hit play.</p>

<p>Is there a workaround for this?</p>
]]></description>
   </item>
   <item>
      <title>Jump() in videolibrary causes java error ...</title>
      <link>https://forum.processing.org/two/discussion/13673/jump-in-videolibrary-causes-java-error</link>
      <pubDate>Thu, 26 Nov 2015 21:46:31 +0000</pubDate>
      <dc:creator>Per</dc:creator>
      <guid isPermaLink="false">13673@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>The jump() doesnt work for me in the video library when im using processing on Raspberry PI.</p>

<p>Any tips how to solve this or using another library for video? 
Or another way creating looppoints in video?</p>

<p>I get this errormessage:</p>

<blockquote class="Quote">
  <p>#</p>
  
  <h1>A fatal error has been detected by the Java Runtime Environment:</h1>
  
  <p>#</p>
  
  <h1>SIGSEGV (0xb) at pc=0x76ecdf4c, pid=1498, tid=1755313248</h1>
  
  <p>#</p>
  
  <h1>JRE version: Java(TM) SE Runtime Environment (8.0_51-b07) (build 1.8.0_51-b07)</h1>
  
  <h1>Java VM: Java HotSpot(TM) Client VM (25.51-b07 mixed mode linux-arm )</h1>
  
  <h1>Problematic frame:</h1>
  
  <h1>C  [libarmmem.so+0x2f4c]</h1>
  
  <p>#</p>
  
  <h1>Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again</h1>
  
  <p>#</p>
  
  <h1>An error report file with more information is saved as:</h1>
  
  <h1>/tmp/hs_err_pid1498.log</h1>
  
  <p>got a frame 640 368 true
  #</p>
  
  <h1>If you would like to submit a bug report, please visit:</h1>
  
  <h1><a href="http://bugreport.java.com/bugreport/crash.jsp" target="_blank" rel="nofollow">http://bugreport.java.com/bugreport/crash.jsp</a></h1>
  
  <h1>The crash happened outside the Java Virtual Machine in native code.</h1>
  
  <h1>See problematic frame for where to report the bug.</h1>
  
  <p>#
  Could not run the sketch (Target VM failed to initialize).
  For more information, read revisions.txt and Help → Troubleshooting.</p>
</blockquote>

<p>Heres the sketch:</p>

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

Movie movie;

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

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

void draw() {
  //if (movie.available() == true) {
  //  movie.read();
  //}
  image(movie, 0, 0, width, height);
}

void keyPressed() {
  if (key == 'j') {
    movie.jump(1.0);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Help add array</title>
      <link>https://forum.processing.org/two/discussion/17713/help-add-array</link>
      <pubDate>Mon, 01 Aug 2016 04:57:36 +0000</pubDate>
      <dc:creator>triple0</dc:creator>
      <guid isPermaLink="false">17713@/two/discussions</guid>
      <description><![CDATA[<p>Can someone help me incorporate a video array of up to 6 videos into this code provided? Including a void mousePressed function to click through to the next video. The way this code is written is so the video doesn't play naturally from start to finish~ so it can't be a timer function that simply plays all the videos after one another. The end result should be a basic video slideshow loop ONLY when clicked to view the next video.</p>

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

Movie mov;
int newFrame = 0;

void setup() {
  size(640, 360);
  background(0);
  // Load and set the video to play. Setting the video 
  // in play mode is needed so at least one frame is read
  // and we can get duration, size and other information from
  // the video stream. 
  mov = new Movie(this, "transit.mov");  

  // Pausing the video at the first frame. 
  mov.play();
  mov.jump(0);
  mov.pause();
}

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

void draw() {
  background(0);
  image(mov, 0, 0, width, height);
  fill(255);
  text(getFrame() + " / " + (getLength() - 1), 10, 30);
  int f=ceil (map(mouseX,0,width,1,getLength()));
  setFrame(f);
}

//void keyPressed() {
//  if (key == CODED) {
//    if (keyCode == LEFT) {
//      if (0 &lt; newFrame) newFrame--; 
//    } else if (keyCode == RIGHT) {
//      if (newFrame &lt; getLength() - 1) newFrame++;
//    }
//  } 
//  setFrame(newFrame);  
//}

int getFrame() {    
  return ceil(mov.time() * 30) - 1;
}

void setFrame(int n) {
  mov.play();

  // The duration of a single frame:
  float frameDuration = 1.0 / mov.frameRate;

  // We move to the middle of the frame by adding 0.5:
  float where = (n + 0.5) * frameDuration; 

  // Taking into account border effects:
  float diff = mov.duration() - where;
  if (diff &lt; 0) {
    where += diff - 0.25 * frameDuration;
  }

  mov.jump(where);
  mov.pause();  
}  

int getLength() {
  return int(mov.duration() * mov.frameRate);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Problem with toggling between multiple videos on processing 2.2.1</title>
      <link>https://forum.processing.org/two/discussion/7852/problem-with-toggling-between-multiple-videos-on-processing-2-2-1</link>
      <pubDate>Wed, 29 Oct 2014 08:11:12 +0000</pubDate>
      <dc:creator>silvergravel</dc:creator>
      <guid isPermaLink="false">7852@/two/discussions</guid>
      <description><![CDATA[<p>hi,<br />
so im quite a noob, just clearing that.<br />
im working on a project which involves switching between multiple videos on processing when i press a key. im trying to do some initial testing right now, and trying to get processing to switch between two videos on keypress. the video switches alright, but i cant see it in the applet window! the previous video ( in the paused state continues to stay on top ) . how do i fix this?? please help. find the code below -</p>

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

    Movie theMov;
    Movie theMov2;



    void setup() { 
      size(1440, 900);
      theMov = new Movie(this, "sin_city.mp4");
      theMov2 = new Movie(this, "blue_velvet.mp4");

      theMov.stop();  
      theMov2.stop();
    }

    void draw() { 
      background (0);
      image(theMov, 0, 0);
      image(theMov2, 0, 0); 
    } 

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

    void keyPressed(){
      if (key == 'p'){

            theMov2.pause();
            background(0);
            theMov.play();

              } else if (key == 'o'){

                       theMov.pause();
                       background(0);
                       theMov2.play();

                     }


}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Movie: Fast forward to position instead of jump()</title>
      <link>https://forum.processing.org/two/discussion/15056/movie-fast-forward-to-position-instead-of-jump</link>
      <pubDate>Mon, 22 Feb 2016 09:25:59 +0000</pubDate>
      <dc:creator>Kong</dc:creator>
      <guid isPermaLink="false">15056@/two/discussions</guid>
      <description><![CDATA[<p>Hey Everybody,</p>

<p>I am currently working on an interactive poster that changes depending on the position of the viewer. The poster is a .mov-Movie. The tricky part for me is now: <strong>I want the transition between the current frame and the next frame to be "fluid" so it should fast forward or fast rewind to the next position instead of jumping with jump().</strong></p>

<p>Plz help and thank you for your comments in advance!</p>

<p>Here is the relevant part:</p>

<p><strong>Code:</strong></p>

<pre><code>// MOVIE INTERACTION: Movie goes to frame equal to Xposition of tracker


float ratio = v2.x / (float) width;

float moviePos = ratio*movie.duration();

println(moviePos);
&gt;   
movie.jump(moviePos);

movie.read();
&gt; 
image(movie,0,0);

}
</code></pre>

<p>note: v2.x is the tracker position on the x-axis</p>
]]></description>
   </item>
   <item>
      <title>Change to video 2 if "key pressed".</title>
      <link>https://forum.processing.org/two/discussion/14869/change-to-video-2-if-key-pressed</link>
      <pubDate>Thu, 11 Feb 2016 23:42:45 +0000</pubDate>
      <dc:creator>FilipeHenriques</dc:creator>
      <guid isPermaLink="false">14869@/two/discussions</guid>
      <description><![CDATA[<p>Hello, so I have the code that follows next, what I pretend is to create a rule where if I press the key "2" it will play the video number 2 , but I don't know how to get it. I have all the videos in the same folder. The names are : video1.mp4 , video2.mp4...etc . I need a rule where I play video 2 by pressing key number 2. Please help me.</p>

<p>Code :</p>

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

Movie theMov; 
boolean isPlaying;
boolean isLooping;


void setup() { 
  size(600, 300);

  theMov = new Movie(this, "C:/Users/Filipe/Documents/Processing/libraries/video/video1.mp4");
  theMov.loop();  //plays the movie over and over
  isPlaying = true;
  isLooping = true;


}

void draw() { 
  background(0);
  image(theMov, mouseX-theMov.width/2, mouseY-theMov.height/4);
} 

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

void keyPressed() {
  if (key == 'p') {
    // toggle pausing
    if (isPlaying) {
      theMov.pause();
    } else {
      theMov.play();
    }
    isPlaying = !isPlaying;

  } else if (key == 'l') {
    // toggle looping
    if (isLooping) {
      theMov.noLoop();
    } else {
      theMov.loop();
    }
    isLooping = !isLooping;

  } else if (key == 's') {
    // stop playing
    theMov.stop();
    isPlaying = false;

  } else if (key == 'j') {
    // jump to a random time
    theMov.jump(random(theMov.duration()));

  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>sound jump() and stop()</title>
      <link>https://forum.processing.org/two/discussion/14410/sound-jump-and-stop</link>
      <pubDate>Tue, 12 Jan 2016 10:55:52 +0000</pubDate>
      <dc:creator>pA55</dc:creator>
      <guid isPermaLink="false">14410@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>From the example <a href="http://p5js.org/examples/examples/Sound_Load_and_Play_Sound.php" target="_blank" rel="nofollow">http://p5js.org/examples/examples/Sound_Load_and_Play_Sound.php</a>
I made a test</p>

<pre><code>var song;

function setup() {
  song = loadSound('assets/lucky_dragons_-_power_melody.mp3');
  createCanvas(720, 200);
  background(255,0,0);
}

function mousePressed() {
  if ( song.isPlaying() ) { // .isPlaying() returns a boolean
    song.stop();
    song.jump(3);
    background(255,0,0);
  } else {
    song.play();
    background(0,255,0);
  }
}
</code></pre>

<p>When I click, there is more than one "song". I would like to make a jquery ui slider (<a href="https://api.jqueryui.com/slider/#entry-examples" target="_blank" rel="nofollow">https://api.jqueryui.com/slider/#entry-examples</a>) and jump in the song. How to go to a position in the song without multiplaying it ?</p>
]]></description>
   </item>
   <item>
      <title>rewind?????</title>
      <link>https://forum.processing.org/two/discussion/13859/rewind</link>
      <pubDate>Wed, 09 Dec 2015 16:34:58 +0000</pubDate>
      <dc:creator>ruski15</dc:creator>
      <guid isPermaLink="false">13859@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I am trying to rewind my songs but I am not able. Do you know the function?</p>

<p>Thanks.</p>
]]></description>
   </item>
   <item>
      <title>Status bar with movie and ControlP5</title>
      <link>https://forum.processing.org/two/discussion/13716/status-bar-with-movie-and-controlp5</link>
      <pubDate>Mon, 30 Nov 2015 20:49:52 +0000</pubDate>
      <dc:creator>Jose_Aparecido</dc:creator>
      <guid isPermaLink="false">13716@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys,</p>

<p>I'm trying to put a bar to control the time / position when running a film, based on this example:
<a href="https://forum.processing.org/two/discussion/8103/using-a-controlp5-slider-as-video-progress-bar" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/8103/using-a-controlp5-slider-as-video-progress-bar</a></p>

<p>To show the bar as the elapsed time, ran regular ...</p>

<p>But how do if you want to advance the film? It did not work when I tried movie.position () (as sound).</p>

<p>Someone could give a tip, or where can I find some documentation on the subject?</p>

<p>Below the code I am using as an example:</p>

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

ControlP5 cp5;
Movie movie1;

float md, mt;

int progress;
boolean play;

void setup() {
  size(600, 400);
  cp5 = new ControlP5(this);

  movie1 = new Movie(this, "D:/Projetos/Videos/Branca_de_Neve.mpg");
  movie1.play();

  ProgressBar p; // custom Controller class, see implementation below
  p = new ProgressBar(cp5, "progress"); // "progress" here will be linked to variable progress
  //p.setPosition(100, 300).setSize(200, 20).setRange(0, 1000).listen(true);
  p.setPosition(70, 330).setSize(350, 10).setRange(0,  (int) movie1.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, movie1.time());

        //movie1.position(); //????
      }
    }
  }
  );

  // a toggle to switch between play and pause mode
  cp5.addToggle("play")
     .setPosition(10,375)
     .setSize(50,19)
     .getCaptionLabel().align(CENTER,CENTER);
}


void draw() {
  background(0);
  if (play) {
    // update the progressBar value/position
    // replace with audio-track position: progress = player.position();

    if (movie1.available()) movie1.read();
    image(movie1, 70, 40);

    //progress++;
    progress = (int) movie1.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>Thanks for listening</p>
]]></description>
   </item>
   <item>
      <title>scrolling in a movie through mouseX</title>
      <link>https://forum.processing.org/two/discussion/13599/scrolling-in-a-movie-through-mousex</link>
      <pubDate>Sun, 22 Nov 2015 13:59:12 +0000</pubDate>
      <dc:creator>Tilia</dc:creator>
      <guid isPermaLink="false">13599@/two/discussions</guid>
      <description><![CDATA[<p>Hi people,</p>

<p>im very new to this and im quite sure it should be very easy to do this but i don't know how.
i want to load a video in processing an control the displaying of the frames of the video through the mouseX position.</p>

<p>that is my code:</p>

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

void setup() {
  frameRate(30);
  size(1244, 700);
  myMovie = new Movie(this, "Komp 1.mov");
  myMovie.play();    
}

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

void draw() {
  image(myMovie, 0,0);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to avoid multiple keypresses from Fruit Piano sensors (Arduino USB HID)</title>
      <link>https://forum.processing.org/two/discussion/13225/how-to-avoid-multiple-keypresses-from-fruit-piano-sensors-arduino-usb-hid</link>
      <pubDate>Sat, 24 Oct 2015 13:31:08 +0000</pubDate>
      <dc:creator>dekwaedsteniet</dc:creator>
      <guid isPermaLink="false">13225@/two/discussions</guid>
      <description><![CDATA[<p>I'm using Capacitive Sensors to measure input from fruit to trigger events in Processing (like a sound, or in this case a video). I don't want to delay the Arduino program, so it keeps scanning for input. The Arduino sens keypresses (as a USB HID device) to the pc, so I can detect keypresses in Processing. The problem is that often the Arduino is scanning so fast that it sends multiple Keypresses, so the video keeps triggering.</p>

<p>I want to solve this in Processing, so that I don't have to use a delay in the Arduino code. My question is, how do I integrate this type of code:</p>

<pre><code>int sX, sY, sT;

void setup(){
  size(200,200);
}

void draw(){
  background(0);
  if( mousePressed ){
    sX = mouseX;
    sY = mouseY;
    sT = millis() + 2000;
  }
  if( millis() &gt; sT &amp;&amp; millis() &lt; sT + 2000 ){
    fill(255,0,0);
    rect(sX-5, sY-5, 10, 10);
  }
}
</code></pre>

<p>into this:</p>

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


int maxmyMovies = 5; 
int myMoviesIndex = 0; 
Movie[] myMovies = new Movie[maxmyMovies];

void setup() {

  size(1280, 720);
  for (int i = 0; i &lt; myMovies.length; i ++ ) {
    myMovies[i] = new Movie(this, i + ".mp4");
    myMovies[i].loop();
  }
}

void movieEvent(Movie myMovies) {

  myMovies.read();
}

void draw() {
  image(myMovies[myMoviesIndex], 0, 0, 1280, 720); // Displaying one image
}

void keyPressed() {

  if (key=='a') {
    myMovies[myMoviesIndex].pause();
    myMovies[myMoviesIndex].jump(0.0);
    myMoviesIndex = 1;
    myMovies[myMoviesIndex].play();
  } 
  if (key=='b') {
    myMovies[myMoviesIndex].pause();
    myMovies[myMoviesIndex].jump(0.0);
    myMoviesIndex = 2;
    myMovies[myMoviesIndex].play();
  } 
  if (key=='c') {
    myMovies[myMoviesIndex].pause();
    myMovies[myMoviesIndex].jump(0.0);
    myMoviesIndex = 3;
    myMovies[myMoviesIndex].play();
  } 
  if (key=='d') {
    myMovies[myMoviesIndex].pause();
    myMovies[myMoviesIndex].jump(0.0);
    myMoviesIndex = 4;
    myMovies[myMoviesIndex].play();
  }
}
</code></pre>

<p>I have to scan for almost the entire alphabet, so the code is getting very messy. Is there also a way of simplifying this? Thanks in advance for your help.</p>
]]></description>
   </item>
   <item>
      <title>how to make a video: play + jump + play + jump …</title>
      <link>https://forum.processing.org/two/discussion/13095/how-to-make-a-video-play-jump-play-jump</link>
      <pubDate>Sun, 18 Oct 2015 17:46:20 +0000</pubDate>
      <dc:creator>ms68</dc:creator>
      <guid isPermaLink="false">13095@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am also new to processing and would be very thankful if someone could help me with the following issue.</p>

<p>With the help of the video library I am trying to play a video that randomly jumps forwards, plays a limited and random amount of time and jumps randomly forward and plays again randomly until it reaches its end and repeats/loops.</p>

<p>Jumping is random inbetween the parameters of 15 and 30 seconds. Playing between 5 and 13 seconds.
I only got him jumping but not playing inbetween the jumps … althought the code I can give is without jumping so far:</p>

<pre><code>int clip_duration_max = 13;
int clip_duration_min = 5;
int clip_jump_max = 30;
int clip_jump_min = 15;

import processing.video.*;
Movie sequence;

void setup() {
  //size(displayWidth, displayHeight);
  size(640, 480);
  frameRate(25);
  sequence = new Movie(this, "sequence.mp4");
  sequence.loop();
}

void draw() {
  image(sequence, 0, 0);
  sequence.read(); 
  int sequence_duration = int(sequence.duration()); // get sequence duration
  int sequence_time = int(sequence.time());
  int jumper = int(random(clip_jump_min, clip_jump_max));  
  int sequence_length = int(random(clip_duration_min, clip_duration_max));
  int next_jumping_point = sequence_time + jumper + sequence_length;
}
</code></pre>

<p>Can anybody help me guiding to the next steps?</p>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>Delay on movie.play()</title>
      <link>https://forum.processing.org/two/discussion/11944/delay-on-movie-play</link>
      <pubDate>Mon, 03 Aug 2015 07:42:57 +0000</pubDate>
      <dc:creator>swisjnu</dc:creator>
      <guid isPermaLink="false">11944@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys, I'm trying to play four videos at the same time but it seems like the play() or loop() has a delay between each activation. I just want to play all of them together as I need all of them to be in sync. Is there anything I can do to make this work? Thanks.</p>
]]></description>
   </item>
   <item>
      <title>how to track rotation?</title>
      <link>https://forum.processing.org/two/discussion/11862/how-to-track-rotation</link>
      <pubDate>Tue, 28 Jul 2015 07:20:27 +0000</pubDate>
      <dc:creator>mattleaf</dc:creator>
      <guid isPermaLink="false">11862@/two/discussions</guid>
      <description><![CDATA[<p>hi there,</p>

<p>i have a sketch in 3d which uses the OCD library</p>

<p>if you use the method camera1.aim(x, y, z) - you can point to a specific location in 3d space...</p>

<p>i have a box at (0,0, 150) which the camera is pointed at</p>

<p>but, if i start rotating the scene, the camera stays locked on that spot, but the object goes off on its own orbit.</p>

<p>does anyone know how i might keep the camera locked on the target, while rotating?</p>

<p>if by rotating the world then the boxes location of (0,0,150) is now something else, then I guess I need to have the camera track a variable that store that location, but I dont know what that value is, because the whole world is rotating (as I understand it) with the translate function.</p>

<p>If you uncomment the rotation code, you can see what I mean</p>

<pre><code>import damkjer.ocd.*;
Camera camera1;
float rot = 0.0;
float a = 0;
float x, y, z;
float cx, cy, cz;
void setup() {

  size(1000, 1000, P3D);
  smooth(8);

  camera1 = new Camera(this, 1, -300);  


  camera1.aim(0, 0, 150);
}


  void draw() {
  camera1.feed();

  background(0, a);


  colorMode(HSB, 360); // colorMode must be in the PGraphics

  rot = rot + 0.1;

  pushMatrix();
  rotateX(radians(-rot*5));
  rotateY(radians(-rot*5));
  stroke(360, 350, 360, 360);
  fill(255, 360);
  sphereDetail(20);
  sphere(100);
  popMatrix();

  pushMatrix();

//  rotateX(radians(rot*10));

  pushMatrix();
  translate(0, 0, 150);
  stroke(120, 360);
  box(5);
  popMatrix();

  popMatrix();
}
</code></pre>
]]></description>
   </item>
   </channel>
</rss>