URL url = this.getClass().getResource(“/musics/gamemusic.wav”);
    AudioClip ac = Applet._newAudioClip
    (url);
    ac.play();

    1.SoundPool
    _/*
    音乐播放的线程类
    */
    _public class SoundPool extends Thread{

    1. public static final String _BG_MUSIC_="game_music.wav";<br /> public static final String _SHOOT_="bullet.wav";<br /> public static final String _BOOM_="enemy0_down.wav";<br /> AudioClip ac;<br /> public SoundPool(String path){<br /> URL url = this.getClass().getResource("/musics/"+path);<br /> ac = Applet._newAudioClip_(url);<br /> }
    2. public void play(){<br /> ac.play();<br /> }<br /> public void stopAc(){<br /> ac.stop();<br /> }<br /> public void loop(){<br /> ac.loop();<br /> }
    3. @Override<br /> public void run() {<br /> play();<br /> }

    }

    SoundPool bgSoundPool;
    SoundPool shootSoundPool;
    private void startGameTask() {
    bgRoll = new BgRoll();
    shootTask = new ShootTask();
    enemyTask = new EnemyTask();
    hitTask = new HitTask();
    timer.schedule(bgRoll, 0, 50);
    timer.schedule(shootTask, 0, 200);
    timer.schedule(enemyTask, 0, 1000);
    timer.schedule(hitTask, 0, 50);
    bgSoundPool = new SoundPool(SoundPool.BG_MUSIC);
    bgSoundPool.loop();
    shootSoundPool = new SoundPool(SoundPool.SHOOT);
    shootSoundPool.loop();
    }

    private void pauseGameTask() {
    bgRoll.cancel();
    shootTask.cancel();
    enemyTask.cancel();
    hitTask.cancel();
    bgSoundPool.stopAc();
    shootSoundPool.stopAc();
    }

    // 判断敌机血槽是否已空
    if (enemyAirplane.getBlood() == 0) {
    enemy.setDead(true);
    //播放销毁音效
    new SoundPool(SoundPool.BOOM).play();
    hero.setScore(hero.getScore()+enemyAirplane.getScore());
    }