implements PlayerListener : PlayerListener « javax.microedition.media « Java by API






implements PlayerListener

 
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);
  }
}

   
  








Related examples in the same category

1.PlayerListener.CLOSED
2.PlayerListener.END_OF_MEDIA
3.PlayerListener.STARTED
4.PlayerListener.STOPPED