public static synchronized void playSound(final String url) {
new Thread(new Runnable() {
// // The wrapper thread is unnecessary, unless it blocks on the
// // Clip finishing; see comments.
public void run() {
try {
Clip clip = AudioSystem.getClip();
AudioInputStream inputStream = AudioSystem.getAudioInputStream(
Main.class.getResourceAsStream("/path/to/sounds/" + url));
clip.open(inputStream);
clip.start();
} } catch (Exception e) {
System.err.println(e.getMessage());
}
}
}).start();
}
I turned it around and it worked well. But I think only the .wav file will go back.
577 Who developed the "avformat-59.dll" that comes with FFmpeg?
585 PHP ssh2_scp_send fails to send files as intended
926 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
575 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
620 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.