How to play sounds in java
Wendigo0937 (0)

Hello there, I am trying to create a program (in java) that takes input representing music notes, and then plays them back. In order to have this program work, I need to be able to have my program tell the user's computer to play sounds. I have a solution that worked in eclipse, but does not seem to be working in repl. The file I have attached is not supposed to do any of the reading (that part works fine), just supposed to play the wav file I added to it.

a link to my repl that does not work and that contains all the same code as my fully functional eclipse program can be found here : https://repl.it/@Wendigo0937/Sound2

You are viewing a single comment. View All
mwilki7 (287)

@Wendigo0937
Just thinking out loud.
You could send that sound file to your browser and have your browser immediately play it. But this means you'd have to have an HTTP (or some sort of file exchange app) server running alongside the java code dedicated only to sending files.

https://stackoverflow.com/questions/3732109/simple-http-server-in-java-using-only-java-se-api

Playing the sound in your browser is easy. Just need to get it from the server is the more challenging part.