This site requires JavaScript, please enable it in your browser!
Greenfoot back
Kartoffelbrot
Kartoffelbrot wrote ...

2014/2/20

Playing sounds outside of Greenfoot

Kartoffelbrot Kartoffelbrot

2014/2/20

#
Hello guys, can anyone help me with reading mp3 and other sound files? Usually the SourceDataLines and Clips in Java can only play WAV format. But how can I play other formats like GreenfootSound does? Thanks to everyone, who can help :)
lordhershey lordhershey

2014/2/20

#
http://stackoverflow.com/questions/6045384/playing-mp3-and-wav-in-java the example from most voted solution:
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;

String bip = "bip.mp3";
Media hit = new Media(bip);
MediaPlayer mediaPlayer = new MediaPlayer(hit);
mediaPlayer.play();
JetLennit JetLennit

2014/2/20

#
Ignore this, sorry (no delete post option)
kiarocks kiarocks

2014/2/22

#
If you want to support Java 6, then you'll need to look into another solution. I have an mp3 java project somewhere, so I'll go find what that used.
kiarocks kiarocks

2014/2/22

#
You need to login to post a reply.