Java Sound

2 respostas
F

Ola galera,

Alguém conhece algum framework bom de som ao qual eu possa executar vários sons num aplicativo?!

abraço,

2 Respostas

J

Freak_266:
Ola galera,

Alguém conhece algum framework bom de som ao qual eu possa executar vários sons num aplicativo?!

abraço,

http://www.humatic.de/htools/dsj.htm

pcollares

Tente o jLayer

http://www.javazoom.net/javalayer/javalayer.html

Eu pequeno exemplo para tocar MP3, só não lembro onde achei :D

public class MP3 {
    private String filename;
    private Player player; 
    private boolean isPlaying;

    // constructor that takes the name of an MP3 file
    public MP3(String filename) {
        this.filename = filename;
        isPlaying=false;
    }

    public boolean isPlaying(){
        return isPlaying;
    }
    
    public void close() { if (player != null) player.close(); }

    // play the MP3 file to the sound card
    public void play() {
        
        for (Audio audio : Dados.audios) {
            if (audio!=null)
            audio.stop();
        }
        
        try {
            FileInputStream fis     = new FileInputStream(filename);
            BufferedInputStream bis = new BufferedInputStream(fis);
            player = new Player(bis);
        }
        catch (Exception e) {
            System.out.println("Problem playing file " + filename);
            System.out.println(e);
        }


        new Thread() {
            public void run() {
                try { 
                    isPlaying=true;
                    player.play(); 
                    isPlaying=false;
                }
                catch (Exception e) { System.out.println(e); }
            }
        }.start();
    }
   
}
Criado 7 de agosto de 2012
Ultima resposta 7 de ago. de 2012
Respostas 2
Participantes 3