31 Ekim 2019 Perşembe

JavaSound LineListener Arayüzü

Giriş
Şu satırı dahil ederiz
import javax.sound.sampled.LineListener;
Clip nesnesini dinler.

update metodu
Örnek
Şöyle yaparız.
// 5) our line listener checks when audio is ended and stops the line
//this is full example, but you manipulated your way
clip.addLineListener(new LineListener() {
  @Override
  public void update(LineEvent event) {
    LineEvent.Type type = event.getType();
    if (type == LineEvent.Type.OPEN) {
    } else if (type == LineEvent.Type.CLOSE) {
      System.exit(0);
    } else if (type == LineEvent.Type.START) {
    } else if (type == LineEvent.Type.STOP) {
      clip.close();
    }
  }
});
Örnek
Şöyle yaparız.
clip.addLineListener(new LineListener() {
  @Override
  public void update(LineEvent event) {
    if (event.getType() == LineEvent.Type.STOP)
      clip.close();
  }
});

Hiç yorum yok:

Yorum Gönder