PrintMovieTime example

Processing sketch

PrintMovieTime.pde
/**
 * PrintMovieTime 
 * 
 * Example for the pogg library by Octavi Estape.
 * It plays a Theora movie and prints the current time.
 */
 
import pogg.*;
 
TheoraMovie myMovie;
PFont font;
 
void setup() {
  frameRate(10);
 
  myMovie = new TheoraMovie(this, "BugsShort.ogg");
  myMovie.loop();
 
  size(myMovie.width, myMovie.height);
 
  font = createFont("Monospaced",14);
  textFont(font);
}
 
void draw() {
  myMovie.read();
  image(myMovie, 0, 0);
 
  float sec = myMovie.time();
  String time = formatTime(sec);
 
  text(time,5,15);
 
}
 
String formatTime(float sec) {
  int seconds = (int)sec;
  float fraction = sec-seconds;
  int mill = (int)(fraction *1000);
  int minutes = seconds/60;
  seconds = seconds%60;
  int hours = minutes/60;
  minutes = minutes%60;
 
  String time = "";
  if(hours<10) {
    time = time+"0";
  }
  time = time+hours+":";
  if(minutes<10) {
    time = time+"0";
  }
  time = time+minutes+":";
  if(seconds<10) {
    time = time+"0";
  }
 
  time = time+seconds+".";
  if (mill < 100) {
      time = time + "0";
  }
  if (mill < 10) {
      time = time + "0";
  }
  time = time + mill;
  return time;
}

Result

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

Comments

Enter your comment
VSHKI
 
 
Back to top
printmovietime_example.txt · Last modified: 2021/08/05 14:38 (external edit)
 
 
CC Attribution-Noncommercial-Share Alike 3.0 Unported
chimeric.de = chi`s home Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0