Question

I need some code example on how I would use a filepath from a harddrive location to then play a .wav sound file when opened in swing GUI. I don't need it to show a play button, or pause or stop. I just want it to play when I select the 'Sound' option from my 'Files' in my window (I know how to do that already, no need to explain that).

So basically, just how to play a .wav sound file from a filepath (i.e. c:/cake/thereisnone.wav) inside of a JFrame.

And how can I easily apply methods to that sound file afterwards.

Also, if anyone knows how to apply methods on a BufferedImage in a JFrame, that would be helpful too.

Thank you very much everyone!

Was it helpful?

Solution

Suns sound tutorial is really good. I also found this like helpful: http://www.developer.com/java/other/article.php/2173111/Java-Sound-Playing-Back-Audio-Files-using-Java.htm it shows sample code and one way to do it.

OTHER TIPS

1) See the Sound tutorial's Overview of the Sampled Package.

2) Override paintComponent() in JPanel to call drawImage(); add the panel to the JFrame. See Painting with Fill Objects for examples.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top