[Bluej-discuss] Fix to simplesound project, chapter 11
Seth Bergmann
bergmann at elvis.rowan.edu
Tue Oct 16 16:34:28 BST 2007
When you play a sound clip in the simplesound project, does it always show
a duration of '1 seconds', regardless of the actual length of the sound
clip?
I have a fix for this:
In the loadSound (File file) method of the SoundEngine class replace the
following lines:
currentSoundDuration = (int) (currentSoundClip.getBufferSize() /
(currentSoundClip.getFormat().getFrameSize() *
currentSoundClip.getFormat().getFrameRate()));
with the following line:
currentSoundDuration = (int) (currentSoundClip.getMicrosecondLength() / 1000000) ;
Seth D. Bergmann Associate Professor
Computer Science Department bergmann at cs.rowan.edu
Rowan University 856-256-4500 ext. 3197
Glassboro, NJ 08028 Fax 856-256-4741
More information about the bluej-discuss
mailing list