Sign in to follow this  

Java Audio Clip() Plays Sometimes?

This topic is 2564 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my game applet I have decided to use Java Clip because all my sound clips are less than a second in length. The problem I am facing is 90% of the time the clips play when they should, the other 10% I hear no playback at all.

Source code under my main applet:

private void LoadGameSounds() throws Exception{
File soundFile;
AudioInputStream sound;
Clip clip;

for (int i = 0; i < 5; i++){
soundFile = new File("drop"+(i+1)+".wav");

sound = AudioSystem.getAudioInputStream(soundFile);
// load the sound into memory (a Clip)
clip = AudioSystem.getClip();
clip.open(sound);

board.SetSoundClip(i, clip);
}




The SetSoundClip() Function under MainBoard:

public void SetSoundClip(int i, Clip clip){
soundClip[i] = clip;
try{
soundClip[i].open();
}
catch(LineUnavailableException e){}
}




Since the MainBoard judges whether pieces have 'dropped', MainBoard plays the audio clips.

...if piece dropped:
soundClip[4].stop();
soundClip[4].setFramePosition(0);
soundClip[4].start();




All sound files do load unto the soundClip array and they all playback...90% of the time :D

[Edited by - isometrixk on December 6, 2010 10:08:17 AM]

Share this post


Link to post
Share on other sites
Bump for suggestions or answers? I debugged the program and it plays the sounds everytime in the debugger. I'm confused.

Edit...I found this link, I'm going to try it out when I get home:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4434125

[Edited by - isometrixk on December 6, 2010 10:44:19 AM]

Share this post


Link to post
Share on other sites

This topic is 2564 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this