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






PlayerListener.STARTED

 


import javax.microedition.lcdui.StringItem;
import javax.microedition.media.Player;
import javax.microedition.media.PlayerListener;
import javax.microedition.media.control.VolumeControl;

public class EventHandler implements PlayerListener {
  private StringItem item;

  public EventHandler(StringItem item) {
    this.item = item;
  }

  public void playerUpdate(Player player, String event, Object eventData) {
    if (event == (PlayerListener.VOLUME_CHANGED)) {
      VolumeControl vc = (VolumeControl) eventData;
      updateDisplay("Volume Changed to: " + vc.getLevel());
      if (vc.getLevel() > 60) {
        updateDisplay("Volume higher than 60 is too loud");
        vc.setLevel(60);
      }
    } else if (event == (PlayerListener.STOPPED)) {
      updateDisplay("Player paused at: " + (Long) eventData);
    } else if (event == (PlayerListener.STARTED)) {
      updateDisplay("Player started at: " + (Long) eventData);
    } else if (event == (PlayerListener.END_OF_MEDIA)) {
      updateDisplay("Player reached end of loop.");
    } else if (event == (PlayerListener.CLOSED)) {
      updateDisplay("Player closed.");
    } else if (event == (PlayerListener.ERROR)) {

      updateDisplay("Error Message: " + (String) eventData);
    }
  }

  public void updateDisplay(String text) {
    item.setText(text);
    System.err.println(text);
  }
}

   
  








Related examples in the same category

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