All Downloads are FREE. Search and download functionalities are using the official Maven repository.

wf.utils.java.sound.SoundUtils Maven / Gradle / Ivy

There is a newer version: 3.3.4
Show newest version
package wf.utils.java.sound;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import java.io.InputStream;

public class SoundUtils {


    public static void playSound(InputStream audio){
        new Thread(new Runnable() {
            public void run() {
                try {
                    Clip clip = AudioSystem.getClip();
                    AudioInputStream inputStream = AudioSystem.getAudioInputStream(audio);
                    clip.open(inputStream);
                    clip.start();
                } catch (Exception e) {e.printStackTrace();}
            }
        }).start();
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy