I don't know what library you are using, but maybe you could find a "stop" method in your player class.
How to stop a sound using JLayer
Pregunta
I'm using JLayer to play mp3 files in my game, but It's impossible for me to stop the song. That's my code:
public void play(final String sonido) {
reproduciendo.put(sonido, 1);
Thread thread = new Thread() {
public void run() {
while(reproduciendo.get(sonido)!=null) {
try {
Player player = new Player(getSonido(sonido));
player.play();
if(player.isComplete()) reproduciendo.remove(sonido);
} catch(Exception e) {e.printStackTrace();};
}}
};
thread.start();
}
public void stop (String sonido ) {
reproduciendo.remove(sonido);
}
When I remove the song of the hashmap "reproduciendo" with the stop method it should stop, but nothing is done, I've read this way here, but it doesn't work for me. Do you know another way to do it?
Solución
Otros consejos
see my answer to other similar question, just play one audio frame and check a flag if it should pause or stop playing
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow