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]