/Users/lyon/j4p/src/sound/player/SoundLoader.java

1    package sound.player; 
2     
3    import java.applet.Applet; 
4    import java.applet.AudioClip; 
5    import java.net.MalformedURLException; 
6    import java.net.URL; 
7     
8    class SoundLoader extends Thread { 
9        SoundList soundList; 
10       URL completeURL; 
11       String relativeURL; 
12    
13       public SoundLoader(SoundList soundList, 
14                          URL baseURL, String relativeURL) { 
15           this.soundList = soundList; 
16           try { 
17               completeURL = new URL(baseURL, relativeURL); 
18               System.out.println("completeUrl=" + completeURL); 
19           } catch (MalformedURLException e) { 
20               System.err.println(e.getMessage()); 
21           } 
22           this.relativeURL = relativeURL; 
23           setPriority(MIN_PRIORITY); 
24           start(); 
25       } 
26    
27       public void run() { 
28           AudioClip audioClip = Applet.newAudioClip(completeURL); 
29           soundList.putClip(audioClip, relativeURL); 
30       } 
31   } 
32