I manage to make a program that could understand mp3 in Java (by jaco.mp3 jar) and it works. However this means that the .Wav files doesn't work of course. So I fixed so that I could use the Wav but the problem will then be that I can't use the mp3 then. so I found out that I could use the File Extension and my idea was to make like this:
If the last 3 or 4 letters ends with .mp3 then do the mp3 method, if its .Wav then to Wave method. but I don't really know how to manage it together, I was thinking more like a Switch-statement. But I really never worked with File extension before and could need som help with that!
However this is my mp3 method that is like this right now:
public void Choose() {
String userDir = System.getProperty("user.home");
JFileChooser fileChooser = new JFileChooser(userDir +"/Desktop");
int returnValue = fileChooser.showOpenDialog(null);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
System.out.println(selectedFile.getName());
mp3_player = new MP3Player(selectedFile);
lblPlayURL.setText(selectedFile.getName());
}
}
}
as you can see I have a JFileChooser where I pick the song I want of course and I still want to do it, only that the different is now it should work both as .Wav and .mp3. But I don't really know how to go further with it. so any help is needed from you guys! :)
Before people is trying to give any suggestions from a thread that says Playing .Wav and .Mp3. I would just say first that I have read it and there is only answers about each of them, Only mp3 or the .Wav. not both. so thats why I created this thread because I need help!
Aucun commentaire:
Enregistrer un commentaire