示例#1
0
  public void start() {
    startNotification();

    player.start();

    state = State.Playing;
    sendState();
  }
示例#2
0
  public void pause() {
    if (player.isPlaying()) {
      stopForeground(true);

      state = State.Pause;
      player.pause();
      sendState();
    }
  }
示例#3
0
  @Override
  public void onCreate() {
    super.onCreate();

    Log.d("myLog", "" + this);

    if (player == null) {
      player = MediaPlayer.create(this, R.raw.song);

      player.setOnCompletionListener(
          new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
              stopForeground(true);

              state = State.Idle;
              sendState();
            }
          });

      sendState();
    }
  }