views:

540

answers:

2

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!

+1  A: 

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.

trashgod
Thanks a lot for your comment, it helped
JavaIceCream
+1  A: 

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.

John
I looked at the link and sort of got confused by the code provided on that page. It seems like some parts are missing, but anyway I found my way through for the sound file, thanks!
JavaIceCream