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

public class Boombox {
   
   public Boombox(){
      clipLoaded = false;
      
   }
   
   private Clip clip;
   private Boolean clipLoaded;
   
   // takes the name of the .wav file to be played and opens it as a clip
   public boolean loadClip(String name){
      try {
         File f = new File(name + ".wav"); // file name goes here
         URI uri = f.toURI();
         URL url = uri.toURL();
         AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
         
         if (clipLoaded)    // if a clip is already loaded close it
            clip.close();
         
         clip = AudioSystem.getClip();
         clip.open(audioIn);
         clipLoaded = true;
         return clipLoaded;
         
      }
      catch(Exception e){
         clipLoaded = false;
         e.printStackTrace();
         return clipLoaded;
      }
   }
   
   // if a clip it available, plays/resumes it
   public void playClip(){
      if (clipLoaded)
         clip.start();
   }
   
   // pauses the clip
   public void pauseClip(){
      if (clipLoaded)
         clip.stop();
   }
   
   // rewinds the clip to beginning
   public void resetClip(){
      if (clipLoaded)
         clip.setFramePosition(0);
   }
   
   // sets the number of times the clip will be played, -1 for an endless loop
   public void loopClip(int loopNum){
      if (loopNum >= 0)
         clip.loop(loopNum);
      else if (loopNum == -1)
         clip.loop(Clip.LOOP_CONTINUOUSLY);
   }
   
   // closes the clip
   public void closeClip(){
      if (clipLoaded){
         clipLoaded = false;
         clip.close();
      }
   }
   
}

@@ -1,16 +1,33 @@
+package sample;%0A%0A
 import javax.sou
@@ -121,24 +121,50 @@
 ombox %7B%0A   %0A
+   // default constructor%0A
    public Bo
@@ -200,24 +200,190 @@
 alse;%0A      
+l = null;%0A   %7D%0A   %0A   // constructor that takes a LineListener as an arguement%0A   public Boombox(LineListener listener)%7B%0A      clipLoaded = false;%0A      l = listener;
 %0A   %7D%0A   %0A  
@@ -433,16 +433,39 @@
 Loaded;%0A
+   LineListener l;%0A   %0A
    %0A   /
@@ -971,16 +971,112 @@
 dioIn);%0A
+         clip.addLineListener(l);   // adds the listener to the clip now that it is initialized%0A
         
@@ -1832,16 +1832,16 @@
  == -1)%0A
-
         
@@ -1881,24 +1881,429 @@
 );%0A   %7D%0A   %0A
+   // takes a single precision floating point number between 0 and 1 and adjusts the volume%0A   public void adjustClipVolume(float vol)%7B%0A      FloatControl volume = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);%0A      %0A      float range = volume.getMaximum() - volume.getMinimum();%0A      float gain = (range * vol) + volume.getMinimum();%0A      %0A      volume.setValue(gain);%0A      %0A   %7D%0A   %0A
    // closes

Update Boombox.java