Пример #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();
    }
  }