This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sounds

 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a sound manager class that looks as follows:



The strange thing is that for arrow.wav and cannonball.wav (two short sounds, <3 seconds), it works fine. However, for doom.wav ( a longer sound, about 4 minutes ), it seems to keep starting the sound over and over again, so you get a mash of 100 versions of it playing at once. Whyzat?

Thanks,
Nick

I picked the applets forum because this is a method of applets, if there's a better forum, feel free to move.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might try using Thread.sleep to pause the application for a number of seconds after you start playing a sound.
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No dice.

I picked a song that has an opening noise, and then relative silence, so I know that the song keeps starting, and isn't just really fuzzy.

Thanks
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried playing it through an applet to test the file?
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know beans about applets, never made one in me life.

Honestly, I don't even really think it's an Applets question, I wonder if people will be annoyed if Icrosspost
[ April 16, 2006: Message edited by: Nick George ]
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This would be the code for the appplet.



Compile the class and then load this HTML file in a browser or appletviewer.



Where you place the name of the sound you want to play as the value in the param tag.

Note that in this example, the sound file should be in the same directory as the .class file and HTML file.
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, but I'm not planning on going down the applet path... is that just for testing purposes?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java in General (intermediate) at author's request.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The applet will let you test the files to see if they do the same thing as they do when you play them in an application.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic