那个AudioClip在Applet播放就行,但在Application里如何办呢?

解决方案 »

  1.   

    private void playSound(String file){
        InputStream is = null;
        AudioStream as = null;
        try {
          is = getClass().getResourceAsStream(file);
          if(is==null){
            throw new Exception("NULL stream");
          }
          as = new AudioStream(is);
          AudioPlayer.player.start(as);
        }
         catch (Exception e) {
           e.printStackTrace();
           Toolkit.getDefaultToolkit().beep();
           if(is!=null){
            try {
              is.close();
            }
            catch (IOException ex) {
            }
           }
         }
       }
      

  2.   

    AudioClip myAudio;
    myAudio.loop();