import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.media.PlayerListener;
import javax.microedition.midlet.MIDlet;
public class EchoEventsMIDlet extends MIDlet implements PlayerListener {
private StringItem stringItem = new StringItem("", null);
public void startApp() {
try {
Form form = new Form("Player State");
form.append(stringItem);
Display.getDisplay(this).setCurrent(form);
Player player = Manager.createPlayer(getClass().getResourceAsStream("/b.wav"), "audio/x-wav");
player.addPlayerListener(this);
player.start();
} catch (Exception e) {
e.printStackTrace();
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void playerUpdate(Player player, String event, Object eventData) {
stringItem.setText(event);
System.err.println(event);
}
}