package sound;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import java.io.*;
public class SoundMIDlet extends MIDlet {
private Player player = null;
/** Constructor */
public SoundMIDlet() {
try{
InputStream is = this.getClass().getResourceAsStream("/sword2008.wav");
player = Manager.createPlayer(is,"audio/x-wav");
}catch(IOException e){
System.out.println("1:" + e);
}catch(MediaException e){
System.out.println("2:" + e);
}catch(Exception e){
System.out.println("3:" + e);
}
}
/** Main method */
public void startApp() {
if(player != null){
try{
player.start();
}catch(MediaException e){
System.out.println("4:" + e);
}
}
}
/** Handle pausing the MIDlet */
public void pauseApp() {
}
/** Handle destroying the MIDlet */
public void destroyApp(boolean unconditional) {
}
}
评论