package emergencylanding.k.library.sound;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.lwjgl.openal.AL;
import org.newdawn.slick.openal.Audio;
import org.newdawn.slick.openal.AudioLoader;
import org.newdawn.slick.openal.SoundStore;

import emergencylanding.k.library.util.LUtils;

public class SoundPlayer {
    static {
	Runtime.getRuntime().addShutdownHook(new Thread() {
	    @Override
	    public void run() {
		AL.destroy();
	    }
	});
    }

    private static Audio wavA;
    private static InputStream iStream;
    private static BufferedInputStream bStream;

    /**
     * Plays .wav file
     * 
     * @param soundFile
     */
    public static void playWAV(String soundFile) {
	playWAV(soundFile, 1.0f);
    }

    /**
     * Plays .wav file
     * 
     * @param soundFile
     * @param volume
     */
    public static void playWAV(String soundFile, float volume) {
	playWAV(soundFile, volume, 1.0f);
    }

    /**
     * Plays .wav file
     * 
     * @param soundFile
     * @param volume
     * @param pitch
     */
    public static void playWAV(String soundFile, float volume, float pitch) {
	playWAV(soundFile, volume, pitch, false);
    }

    /**
     * Plays .wav file
     * 
     * @param soundFile
     * @param volume
     * @param pitch
     * @param loop
     */
    public static void playWAV(String soundFile, float volume, float pitch,
	    boolean loop) {
	try {
	    iStream = LUtils.getInputStream(soundFile);
	    bStream = new BufferedInputStream(iStream);
	    wavA = AudioLoader.getAudio("WAV", bStream);
	} catch (IOException e) {
	    e.printStackTrace();
	}

	SoundStore.get().setSoundVolume(volume);

	wavA.playAsSoundEffect(pitch, 1.0f, loop);
    }
}

@@ -506,128 +506,8 @@
  %7D%0A%0A
-    private static Audio wavA;%0A    private static InputStream iStream;%0A    private static BufferedInputStream bStream;%0A%0A
     
@@ -1330,18 +1330,50 @@
  %7B%0A%09
-try %7B%0A%09   
+Audio wavA = null;%0A%09try %7B%0A%09    InputStream
  iSt
@@ -1418,16 +1418,36 @@
 );%0A%09    
+BufferedInputStream 
 bStream 

Make the sound vars not static.