File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes sounds Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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: 2341
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: 2341
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: 2341
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: 56150
    
  13

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2341
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://zeroturnaround.com/jrebel/download
 
subject: sounds
 
Similar Threads
How i can play a wav file when a button pressed
why is it so??
Apple + sound + permission
Playing a simple .wav file in the application?
Playing Sound in Applet