Java Audio Clip() Plays Sometimes?

Started by
0 comments, last by isometrixk 13 years, 4 months ago
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 = clip;	try{		soundClip.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]
Advertisement
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]

This topic is closed to new replies.

Advertisement