/** * Disable pause or seek buttons if the stream cannot be paused or seeked. This requires the * control interface to be a MediaPlayerControlExt */ private void disableUnsupportedButtons() { try { if (mPauseButton != null && !mPlayer.canPause()) { mPauseButton.setEnabled(false); } if (mRewButton != null && !mPlayer.canSeekBackward()) { mRewButton.setEnabled(false); } if (mFfwdButton != null && !mPlayer.canSeekForward()) { mFfwdButton.setEnabled(false); } // TODO What we really should do is add a canSeek to the MediaPlayerControl interface; // this scheme can break the case when applications want to allow seek through the // progress bar but disable forward/backward buttons. // // However, currently the flags SEEK_BACKWARD_AVAILABLE, SEEK_FORWARD_AVAILABLE, // and SEEK_AVAILABLE are all (un)set together; as such the aforementioned issue // shouldn't arise in existing applications. if (mProgress != null && !mPlayer.canSeekBackward() && !mPlayer.canSeekForward()) { mProgress.setEnabled(false); } } catch (IncompatibleClassChangeError ex) { // We were given an old version of the interface, that doesn't have // the canPause/canSeekXYZ methods. This is OK, it just means we // assume the media can be paused and seeked, and so we don't disable // the buttons. } }
/** * Disable pause or seek buttons if the stream cannot be paused or seeked. This requires the * control interface to be a MediaPlayerControlExt * * @hide */ protected void disableUnsupportedButtons() { try { if (mPauseButton != null && !mPlayer.canPause()) { mPauseButton.setEnabled(false); } if (mRewButton != null && !mPlayer.canSeekBackward()) { mRewButton.setEnabled(false); } if (mFfwdButton != null && !mPlayer.canSeekForward()) { mFfwdButton.setEnabled(false); } } catch (IncompatibleClassChangeError ex) { // We were given an old version of the interface, that doesn't have // the canPause/canSeekXYZ methods. This is OK, it just means we // assume the media can be paused and seeked, and so we don't disable // the buttons. } }