Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Create progress bar for song.

$
0
0

Hello,

I'm trying to create a code that will play a song and have a bar created across the campus in relation to the player's position in the song. Right now I am able to create a line that moves across the screen, but I would like to be able to have a new line created every time the player moves, so it will eventually draw a bar. However, the drawing the bar part has me stumped. Would someone be able to help in how to make it so the line does not disappear?

Here is the code I have so far:

import ddf.minim.*; import ddf.minim.signals.*; import ddf.minim.analysis.*; import ddf.minim.effects.*;

Minim minim; AudioPlayer player;

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

minim = new Minim( this );

player = minim.loadFile("Little Secrets.mp3");
player.play();

}

void draw() { background( 255 );

float x = map( player.position(), 0, player.length(), 0, width );

stroke( 0 );
strokeWeight (5);
line( x, 0, x, height );

}

void stop() { player.close(); minim.stop(); super.stop(); }


Viewing all articles
Browse latest Browse all 2896

Trending Articles