/** * Show the controller on screen. It will go away automatically after 'timeout' milliseconds of * inactivity. * * @param timeInMilliSeconds The timeout in milliseconds. Use 0 to show the controller until * hide() is called. */ @Override public void show(final int timeInMilliSeconds) { if (!mShowing) { showBottomArea(); setProgress(); if (mPauseButton != null) { mPauseButton.requestFocus(); } mShowing = true; setVisibility(View.VISIBLE); } updatePausePlay(); // cause the progress bar to be updated even if mShowing // was already true. This happens, for example, if we're // paused with the progress bar showing the user hits play. mHandler.sendEmptyMessage(SHOW_PROGRESS); Message msg = mHandler.obtainMessage(FADE_OUT); if (timeInMilliSeconds != 0) { mHandler.removeMessages(FADE_OUT); mHandler.sendMessageDelayed(msg, timeInMilliSeconds); } if (visibilityListener != null) { visibilityListener.onControlsVisibilityChange(true); } }
/** Remove the controller from the screen. */ @Override public void hide() { if (!mDragging) { if (mShowing) { try { mHandler.removeMessages(SHOW_PROGRESS); setVisibility(View.INVISIBLE); } catch (final IllegalArgumentException ex) { Log.w("MediaController", "already removed"); } mShowing = false; } if (visibilityListener != null) { visibilityListener.onControlsVisibilityChange(false); } } }