package sound;

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

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;


/**
 * Represents a AudioClip 
 * Could've extended DirectClip because it basically is one, but its not visible.
 * 
 * @author Vinzenz
 */
public class AudioClip{
	private Clip clip;
	private AudioInputStream ais;
	
	public AudioClip(BufferedInputStream is) throws UnsupportedAudioFileException, IOException, LineUnavailableException{
		clip = AudioSystem.getClip();
		ais = AudioSystem.getAudioInputStream(is); 				
	}
	
	public void open(){
		try{
			if(!clip.isOpen())
				clip.open(ais);
		}catch(Exception e){
			System.err.println("AudioClip: Sound couldn't be opened");
		}
	}
	public void start(){
		open();
		clip.setFramePosition(0);
		clip.start();
	}
	
	public void loop(){
		open();
		clip.loop(Clip.LOOP_CONTINUOUSLY);
	}
	public void loop(int count){
		open();
		clip.loop(count);
	}
	public void close(){
		clip.close();
	}
	public boolean isRunning() {
		return clip.isRunning();
	}
	public void stop() {
		clip.stop();
	}
}

@@ -747,32 +747,84 @@
 ); %09%09%09%09%0D%0A%09%7D%0D%0A%09%0D%0A
+%09/**%0D%0A%09 * Opens the sound to operate with it%0D%0A%09 */%0D%0A
 %09public void ope
@@ -829,16 +829,16 @@
 pen()%7B%0D%0A
-
 %09%09try%7B%0D%0A
@@ -973,24 +973,77 @@
 ;%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A
+%09%0D%0A%09/**%0D%0A%09 * Plays the sound immediately once%0D%0A%09 */%0D%0A
 %09public void
@@ -1113,24 +1113,89 @@
 ();%0D%0A%09%7D%0D%0A%09%0D%0A
+%09/**%0D%0A%09 * Plays the sound immediately in an infinite loop%0D%0A%09 */%0D%0A
 %09public void
@@ -1249,32 +1249,147 @@
 INUOUSLY);%0D%0A%09%7D%0D%0A
+%09%0D%0A%09/**%0D%0A%09 * Plays the sound multiple times%0D%0A%09 * %0D%0A%09 * @param count The count how often the sound is played%0D%0A%09 */%0D%0A
 %09public void loo
@@ -1431,32 +1431,68 @@
 op(count);%0D%0A%09%7D%0D%0A
+%09%0D%0A%09/**%0D%0A%09 * Close the sound%0D%0A%09 */%0D%0A
 %09public void clo
@@ -1511,32 +1511,96 @@
 p.close();%0D%0A%09%7D%0D%0A
+%09%0D%0A%09/**%0D%0A%09 * Returns whether the sound is running or not%0D%0A%09 */%0D%0A
 %09public boolean 
@@ -1642,20 +1642,59 @@
 ing();%0D%0A
-
 %09%7D%0D%0A
+%09%0D%0A%09/**%0D%0A%09 * Stops the playback%0D%0A%09 */%0D%0A
 %09public 

Update AudioClip.java