import java.io.*;
import javax.sound.sampled.*;


public class ThreadSon extends Thread{
	
	
	AmbianceSonore player;
	
	private String fs;
	
	private float vol=0;
	
	int compt=1;
	
	int i=0;
	
	InputStream stream;
	
	public ThreadSon(String fichierson, float gain){ // une fois
		vol=gain;
		fs=fichierson;
		
	}
	
	public ThreadSon(String fichierson, float gain,int c){ // c fois
		vol=gain;
		fs=fichierson;
		compt=c;
		
	}
	
	
	
	
	public void run(){
		i=0;
		while(i!=compt){
			try{
				player=new AmbianceSonore(fs,vol);
				stream=new ByteArrayInputStream(player.getSamples());
				player.play(stream);
				//System.out.println(this.isAlive());
				//System.out.println(i);
				
			}
			catch(Exception e){}
		
		
			try { Thread.currentThread().sleep(100);}
			catch ( InterruptedException e ){};
			
			i++;
			
		}
		
		
		
	}
	
	
	
}