Code example for MediaPlayer

Methods: isPlayingpauseseekTosetOnSeekCompleteListener

0
    if (D)
      Log.d(TAG, "In milliseconds from " + startTimeMS + " to " + endTimeMS);
    if (mMediaPlayer != null) {
      mRequestedMediaPlayer = 0;
      // If the audio is already playing, pause it 
      if (mMediaPlayer.isPlaying()) {
        mMediaPlayer.pause();
      } 
      // If there is a background timer waiting for the previous audio interval 
      // to finish, kill it 
      if (mListenForEndAudioInterval != null
          && !mListenForEndAudioInterval.isCancelled()) {
        mListenForEndAudioInterval.cancel(true);
        // mListenForEndAudioInterval = null; 
      } 
      mMediaPlayer.seekTo(startTimeMS);
      mMediaPlayer
          .setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() {
            public void onSeekComplete(MediaPlayer mediaPlayer) {
              if (D)
                Log.d(
                    TAG,
                    "current audio position... "