GUI de button denemleri ve music import etme

Normal                                            Mouse uzerine gelince                 Tiklayinca

Asagida yazan kod ise bilgisyardan musik secme, oynatma ve durdurma gorevlerini yertine getiriyor.

import ddf.minim.*;

AudioPlayer player;
Minim minim;

PFont font;

void setup()
{
size(800, 600, P3D);
String file = selectInput();
smooth();
minim = new Minim(this);
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

}

 

 

Leave a Reply