cemdemirer

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

}

 

 

GUI

Processingde arayuz cizimi


size(1600, 1000);
background(#414042);
stroke(255);
noFill();

//Grids Kutusu
rect(15, 30, 30, 130);

//Videos Kutusu
rect(15, 175, 30, 130);

//Movie Import
rect(15, 320, 30, 30);

//Music Import
rect(15, 365, 30, 30);

//Save Movie
rect(225, 320, 30, 30);

//Save Music
rect(225, 365, 30, 30);

//Visuals
rect(285, 175, 1300, 735);

//Music Control
rect(640, 945, 80, 40);
rect(720, 945, 80, 40);
rect(800, 945, 80, 40);
rect(880, 945, 80, 40);

 

//Playlist
stroke(#BCBEC0);
rect(15, 410, 240, 500);
stroke(#00B3D0);
fill(#00B3D0);
rect(15, 410, 240, 20);
stroke(#BCBEC0);
fill(#BCBEC0);
rect(15, 450, 240, 20);
rect(15, 490, 240, 20);
rect(15, 530, 240, 20);
rect(15, 570, 240, 20);
rect(15, 610, 240, 20);
rect(15, 650, 240, 20);
rect(15, 690, 240, 20);
rect(15, 730, 240, 20);
rect(15, 770, 240, 20);
rect(15, 810, 240, 20);
rect(15, 850, 240, 20);
rect(15, 890, 240, 20);

//Playlist Buyuk Kare
rect(905, 952, 48, 24);

// “+” Save Movie, Save Music
smooth();
stroke(255);
strokeWeight(3);
line(22, 335, 38, 335);
line(30, 327, 30, 343);
line(30, 372, 30, 388);
line(22, 380, 38, 380);

//Time Line
line(590, 927.5, 1010, 927.5);
PFont font;

//Playlist Text
font = loadFont(“GillSans-BoldItalic-12.vlw”);
textFont(font);
fill(255);
text(“P L A Y L I S T”,95, 425);

//Grids Text
font = loadFont(“GillSans-20.vlw”);
textFont(font);
fill(255);
pushMatrix();
translate(-13,170);
rotate(-PI/2);
text(“Grids” , 50,50);
popMatrix();

//Videos Text
font = loadFont(“GillSans-20.vlw”);
textFont(font);
fill(255);
pushMatrix();
translate(-13,318);
rotate(-PI/2);
text(“Videos” , 50,50);
popMatrix();

//Playlist Ucgenler
fill(255);
triangle(750, 955, 750, 975, 775, 965);
triangle(830, 955, 830, 975, 855, 965);
triangle(690, 955, 690, 975, 665, 965);
//Playlist Kucuk Kare
rect(887, 965, 25, 13);