Jump to content
  • Advertisement
Sign in to follow this  

Java Audio Clip() Plays Sometimes?

This topic is 2758 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();

board.SetSoundClip(i, clip);

The SetSoundClip() Function under MainBoard:

public void SetSoundClip(int i, Clip clip){
soundClip = clip;
catch(LineUnavailableException e){}

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

...if piece dropped:

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:

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!