/** 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 task thread 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();
      SurfaceHolder holder = mSurfaceView.getHolder();
      Surface surface = holder.getSurface();

      // Don't leave the last frame of the previous video hanging on the screen.
      // Looks weird if the aspect ratio changes.
      clearSurface(surface);

      MoviePlayer player = null;
      try {
        player =
            new MoviePlayer(
                new File(getFilesDir(), mMovieFiles[mSelectedMovie]), surface, callback);
      } catch (IOException ioe) {
        Log.e(TAG, "Unable to play movie", ioe);
        surface.release();
        return;
      }

      AspectFrameLayout layout = (AspectFrameLayout) findViewById(R.id.playMovie_afl);
      int width = player.getVideoWidth();
      int height = player.getVideoHeight();
      layout.setAspectRatio((double) width / height);
      // holder.setFixedSize(width, height);

      mPlayTask = new MoviePlayer.PlayTask(player, this);

      mShowStopLabel = true;
      updateControls();
      mPlayTask.execute();
    }
  }