public void seekTo(long usec) {
    /* A seek needs to be performed in the decoding thread to execute commands in the correct
     * order. Otherwise it can happen that, after a seek in the media decoder, seeking procedure
     * starts, then a frame is decoded, and then the codec is flushed; the PTS of the decoded frame
     * then interferes the seeking procedure, the seek stops prematurely and a wrong waiting time
     * gets calculated. */

    // inform the decoder thread of an upcoming seek
    mSeekPrepare = true;
    mSeekTargetTime = Math.max(mVideoMinPTS, usec);

    // if the decoder is paused, wake it up for the seek
    if (mPlaybackThread.isPaused()) {
      mPlaybackThread.play();
      mPlaybackThread.pause();
    }
  }
 public void pause() {
   mPlaybackThread.pause();
   stayAwake(false);
 }