We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Music Player questions
Page Index Toggle Pages: 1
Music Player questions (Read 210 times)
Music Player questions
Mar 5th, 2009, 12:05am
 
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!!!
Page Index Toggle Pages: 1