0

Can you give me a function in java can play a sound from the library of the system?

24th Jun 2017, 6:23 PM
Okba Khenfer
Okba Khenfer - avatar
2 Réponses
+ 3
I doubt there's any under the System library. You could use javax or java.io. You can also use the start() method to play the audio, in the Clip class. (You would first need to open it to some inputStream) Some different versions/code(examples) here: https://stackoverflow.com/questions/26305/how-can-i-play-sound-in-java Clip: https://docs.oracle.com/javase/7/docs/api/javax/sound/sampled/Clip.html
24th Jun 2017, 6:33 PM
Rrestoring faith
Rrestoring faith - avatar
+ 2
if you want to play a beep from the motherboard buzzer print the ASCII bell charachter. On SL Code Playground will probably beep the server in the server room(if it is equipped with a buzzer). System.out.print("\007");
24th Jun 2017, 9:04 PM
seamiki
seamiki - avatar