/** onClick handler for "play"/"stop" button. */
  public void clickPlayStop(@SuppressWarnings("unused") View unused) {
    if (mShowStopLabel) {
      Log.d(TAG, "stopping movie");
      stopPlayback();
      // Don't update the controls here -- let the async task do it after the movie has
      // actually stopped.
      // mShowStopLabel = false;
      // updateControls();
    } else {
      if (mPlayTask != null) {
        Log.w(TAG, "movie already playing");
        return;
      }
      Log.d(TAG, "starting movie");
      SpeedControlCallback callback = new SpeedControlCallback();
      if (((CheckBox) findViewById(R.id.locked60fps_checkbox)).isChecked()) {
        callback.setFixedPlaybackRate(60);
      }
      SurfaceTexture st = mTextureView.getSurfaceTexture();
      Surface surface = new Surface(st);
      MoviePlayer player = null;
      try {
        player = new MoviePlayer(new File(getFilesDir(), mMovieFiles[mSelectedMovie]), surface);
      } catch (IOException ioe) {
        Log.e(TAG, "Unable to play movie", ioe);
        surface.release();
        return;
      }
      adjustAspectRatio(player.getVideoWidth(), player.getVideoHeight());
      mPlayTask = new PlayMovieTask(player, surface, callback);
      if (((CheckBox) findViewById(R.id.loopPlayback_checkbox)).isChecked()) {
        mPlayTask.setLoopMode(true);
      }

      mShowStopLabel = true;
      updateControls();
      mPlayTask.execute();
    }
  }
 /** Requests stoppage if a movie is currently playing. */
 private void stopPlayback() {
   if (mPlayTask != null) {
     mPlayTask.requestStop();
     mPlayTask = null;
   }
 }