import java.util.*; import java.net.*; import java.io.*; import java.applet.*; public class Sound { Show show; AudioClip a; boolean ok=true; public Sound(Show s){ ok=true; show=s; } public void load(String file){ ok=true; URL u; try{ //System.out.println("loading sound file: "+file); // Try opening file u=new URL(file); InputStream ia = u.openStream(); BufferedReader in = new BufferedReader(new InputStreamReader(ia)); String inputLine; if((inputLine = in.readLine()) == null ) ok=false; else { if(file.indexOf("level") > -1){ // If there is a 404 file or another HTML file that results in the lookup .. check the header //System.out.println("Status of "+file+" = "+inputLine); if(inputLine.indexOf(".snd") < 0)ok=false; } } in.close(); if(ok) a=show.applet.getAudioClip(u); }catch(Exception e){ok=false;} } public void play(URL u){ ok=true; try{ a=show.applet.getAudioClip(u); }catch(Exception e){ok=false;} } public void play(){ ok=true; try{ a.play(); }catch(Exception e){ok=false;} } public void loop(){ ok=true; try{ a.loop(); }catch(Exception e){ok=false;} } public void stop(){ ok=true; try{ a.stop(); }catch(Exception e){ok=false;} } public boolean getOK(){return ok;} }