You could use sun java library to add the music... Look at this link about how to do it... The example shouldn't be deprecated yet.
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
depends on what "sound". what kind of file are we talking about? .midi? .wav? .mp3?
the first few can be played with using nothing but core java, but if you want (for instance) to play .mp3 files you'll need an additional library to get it to work.
stultuske
Industrious Poster
4,381 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
I have ... no idea what you are talking about. the IDE you use (you could even use notepad) doesn't matter, it doesn't change the code.
but, seriously: Google rules. just a search for "play wav with java" gave this as first result:
Link
stultuske
Industrious Poster
4,381 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
"C:\Documents and Settings\JonathanConnelly\Desktop\Pokemon_Red_Blue_Yellow_Battle_music.wav"
Not sure if white spaces in the folder name are ligit? You may need to escape that... By the way, I think you may need to look into pathSeparator() from File class...
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
Hmm... Try this then... Not sure if it matters...
AePlayWave aw = new AePlayWave( "C:\\Documents\ and\ Settings\\JonathanConnelly\\Desktop\\Pokemon_Red_Blue_Yellow_Battle_music.wav" );
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
OK, so my guess is wrong that it requires to escape white spaces (I don't run Java on Windows box :(). How about you try to run a smaller .wav file first? What is your current .wav file size by the way?
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
whether or not you want it to run after clicking on a button or at startup does not change the code of playing the music file at all.
you want it to play in the background the whole time?
run it first from early within the main. start an additional thread that monitors whether or not your sound finished playing (or any other way) and if done, re-start it.
stultuske
Industrious Poster
4,381 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
Question Answered as of 4 Months Ago by
Taywin
and
stultuske