Hello!!
I'm trying to build an music player using Minim. Here is what the code looks like:
Code:
import ddf.minim.*;
AudioPlayer player;
Minim minim;
PFont font;
void setup()
{
size(800, 600, P3D);
String file = selectInput();
smooth();
minim = new Minim(this);
font = loadFont("Meera-48.vlw");
player = minim.loadFile(file, 2048);
}
void draw()
{
background(0);
showTime(15, height-15);
if(keyPressed) {
if(key == 'A' || key == 'a')
{
player.play();
}
if(key == 'S' || key == 's')
{
player.pause();
}
}
}
void stop()
{
player.close();
minim.stop();
super.stop();
}
void showTime(int x, int y)
{
// Convert Milliseconds to Minutes and Seconds
String psec = Integer.toString(player.position()/1000);
String pmin = Integer.toString(player.position()/60000);
String tots = Integer.toString(player.length()/1000);
String totm = Integer.toString(player.length()/60000);
// Shows the time
showText(pmin + ":" + psec + "/" + totm + ":" + tots, 48, x, y);
}
void showText(String s, int sz, int x, int y)
{
textFont(font, sz);
text(s, x, y);
}
And I need the following:
- A Little bar that show's the music progress
- Show up the filename at the top
- Some cool background visualization :P
I've tried everything and that doesn't work. Any suggestion?
Bye!!!