/*
 * SoundPlayer.java
 *
 * Created on 16. mars 2004, 13:27
 */

package Sound;

/**
 *
 * @author  Christian Arnesen
 */
import java.net.*;
import java.io.*;
import javax.sound.sampled.*;
import javax.sound.midi.*;
public class SoundPlayer {
    
    /** Creates a new instance of SoundPlayer */
    public SoundPlayer() {
    }
    private static void spillLyd(String fnavn){
        
        File soundFile = new File(fnavn);
        AudioInputStream audioInputStream =null;

          try {
              audioInputStream = AudioSystem.getAudioInputStream(soundFile);
          } catch (Exception e)	{
              e.printStackTrace();
              System.exit(1);
          }


          AudioFormat audioFormat = audioInputStream.getFormat();

          SourceDataLine line;

          DataLine.Info	info = new DataLine.Info(SourceDataLine.class, audioFormat);

          /* Så gjelder det bare å prosessere søknadsskjemaet. */
          line=null;
          try {
            line = (SourceDataLine) AudioSystem.getLine(info);

            line.open(audioFormat);
          } catch (Exception e)	{
            e.printStackTrace();
            System.exit(1);
          }

          line.start();  

          int nBytesRead = 0;

            byte[] abData = new byte[128000]; 
            while (nBytesRead != -1) {
              try {
                nBytesRead = audioInputStream.read(abData, 0, abData.length);
              } catch (IOException e) {
                e.printStackTrace();
              }
              if (nBytesRead >= 0) {
                line.write(abData, 0, nBytesRead);
              }
            }


              line.drain();

              try{
              line.close();
              audioInputStream.close();
              }catch(Exception e){
              }
    }
    
    
    

    public static void spillA(){

       new LydTraad("Sound/a.wav");
    }
   public static void spillE(){

       new LydTraad("Sound/e.wav");
    }
   public static void spillY(){

        new LydTraad("Sound/y.wav");
    }
   public static void spillU(){

        new LydTraad("Sound/u.wav");
    }
   public static void spillI(){

        new LydTraad("Sound/i.wav");
    }
   public static void spillO(){

       new LydTraad("Sound/o.wav");
    }
   public static void spillOE(){

        new LydTraad("Sound/oe.wav");
    }
   public static void spillAE(){

        new LydTraad("Sound/ae.wav");
    }
   public static void spillARING(){

        new LydTraad("Sound/aring.wav");
    }
     
}
