// Private int gamelevel = 0 for game level control; // Private player treadsoundplayer for game music control; player backgroundmusicplayer; private int volumelevel = 100; // volume control private volumecontrol VC; private Boolean playstate = false; // (play/close) status // audio processing ///// /// // public void playerupdate (player P, string event, object eventdata) {// player listens to try {If (event = pl Ayerlistener. end_of_media) {playstate = false;} If (event = playerlistener. started) {playstate = true; // This. musicvolume () ;}} catch (exception e) {system. out. println ("error at 11:" + event + E. tostring () ;}} protected void musicstart () {// randomly generate a music try {backgroundmusicplayer = NULL; backgroundmusicplayer = createplayer ("/2C. mid "," audio/Midi "); // backgroundmusicplayer. addplayerlistener (This); // backgroundmusicplayer. setloopcount (-1); Vc = (volumecontrol) backgroundmusicplayer. getcontrol ("volumecontrol"); If (VC! = NULL) {If (gamelevel = 0) backgroundmusicplayer. setloopcount (-1); else backgroundmusicplayer. setloopcount (5); backgroundmusicplayer. start () ;}} catch (exception e) {system. out. println ("error at 20:" + backgroundmusicplayer + E. tostring () ;}} protected void musicclose () {// turn off the music try {If (backgroundmusicplayer! = NULL) {backgroundmusicplayer. close (); backgroundmusicplayer = NULL;} catch (exception e) {system. out. println ("error at 30:" + E. tostring () ;}} protected void musicpause () {// pause music try {If (backgroundmusicplayer! = NULL & playstate) pausetime = backgroundmusicplayer. getmediatime (); backgroundmusicplayer. stop ();} catch (exception e) {system. out. println ("error at 40:" + E. tostring () ;}} protected void musiccontinue () {// The music continues try {If (backgroundmusicplayer! = NULL &&! Playstate) backgroundmusicplayer. setmediatime (pausetime); backgroundmusicplayer. start ();} catch (exception e) {system. out. println ("error at 50:" + E. tostring () ;}} protected void musicvolume () // set the Music volume {If (VC! = NULL) VC. setlevel (volumelevel);} protected player createplayer (string filename, string format) {// create music player P = NULL; try {inputstream is = getclass (). getresourceasstream (filename); P = manager. createplayer (is, format); p. prefetch ();} catch (exception X) {system. out. println ("error at 60:" + filename + X. tostring ();} return P ;}