my dog learned polymorphism*
The moose likes Java in General and the fly likes sounds Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "sounds" Watch "sounds" New topic
Author

sounds

Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
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.


I've heard it takes forever to grow a woman from the ground
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
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

Joined: Apr 04, 2004
Posts: 815
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

Joined: Feb 07, 2005
Posts: 2367
Have you tried playing it through an applet to test the file?
Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
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

Joined: Feb 07, 2005
Posts: 2367
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

Joined: Apr 04, 2004
Posts: 815
Thanks, but I'm not planning on going down the applet path... is that just for testing purposes?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Moved to Java in General (intermediate) at author's request.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sounds
 
Similar Threads
Playing a simple .wav file in the application?
Playing Sound in Applet
why is it so??
Apple + sound + permission
How i can play a wav file when a button pressed