mercredi 31 décembre 2014

Playing MP3s in Java from within the Project


Vote count:

0




I am working on a Java project that involves playing mp3 files. I want my application to play the files from within the project so I have the music files stored in a folder called music which is in a source folder called resources. This is the code I have right now but when I run it I get a Bitstream errorcode 102. I can't seem to figure out what is wrong, any help? I am using the javazoom library (javazoom.jl.player.Player) Any help would be appreciated



public void play() {
try {
InputStream stream = MP3.class.getClassLoader()
.getResourceAsStream("/music/LoveStory.mp3");
BufferedInputStream bis = new BufferedInputStream(stream);
player = new Player(bis);
} catch (Exception e) {
System.out.println("Problem playing file " + filename);
System.out.println(e);
}

// run in new thread to play in background
new Thread() {
public void run() {
try {
player.play();
} catch (Exception e) {
System.out.println(e);
}
}
}.start();

}


asked 42 secs ago







Playing MP3s in Java from within the Project

Aucun commentaire:

Enregistrer un commentaire