We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm working on a media player and implementing drag and drop capability. The problem is that when I drag and drop the file into the space, it will print out the path, but I'm having trouble finding a way to convert the path into a string, so I can use it to load the next song into the media player.
import com.temboo.core.*;
import com.temboo.Library.LastFm.Artist.*;
import drop.*;
import ddf.minim.*;
import ddf.minim.ugens.*;
import ddf.minim.analysis.*;
import ddf.minim.spi.*;
SDrop drop;
MyDropListener listen;
TembooSession session = new TembooSession("joshuahodge", "myFirstApp", "apiKey");
Minim minim;
AudioPlayer song;
Button button;
AudioMetaData meta;
FFT fft;
LastFM lastFM;
float n;
float t;
String fileName = "/Users/djatwar/Desktop/Base On- UTube (Adam Baum Remix) FINAL MASTER.wav";
void setup() {
size (800, 800);
drop = new SDrop (this);
listen = new MyDropListener();
drop.addDropListener (listen);
button = new Button ();
minim = new Minim (this);
song = minim.loadFile(fileName, 1024);
meta = song.getMetaData();
lastFM = new LastFM();
//create fft with a time domain buffer the same as the player sample buffer
fft = new FFT (song.bufferSize(), song.sampleRate());
}
void draw() {
background(255);
listen.draw();
lastFM.search();
lastFM.displayBio();
button.drawButton(10, 10);
button.metaData();
button.bioBox();
fft.forward (song.mix);
int [] frame = new int [fft.specSize()];
for (int i = 0; i < fft.specSize(); i++) {
strokeWeight(10);
line(i, height, i, height - fft.getBand(i));
}
}
void keyPressed(){
lastFM.keyPressed();
}
void mousePressed() {
button.mousePressed();
lastFM.mousePressed();
}
void dropEvent (DropEvent theDropEvent){
if (theDropEvent.isFile()){
File myFile = theDropEvent.file();
println(theDropEvent.file());
}
}
When I println I get the path in the console but how can I get that as a string? I tried loadStrings() but it doesn't recognize as I have a file.
Thanks for any help.
Answers
http://docs.Oracle.com/javase/8/docs/api/java/io/File.html
Thanks that's perfect. Learned a lot