Code example for MediaController

Methods: setEnabled, show

0
 
            if (mOnPreparedListener != null) { 
                mOnPreparedListener.onPrepared(mMediaPlayer); 
            } 
            if (mMediaController != null) { 
                mMediaController.setEnabled(true); 
            } 
            mVideoWidth = mp.getVideoWidth(); 
            mVideoHeight = mp.getVideoHeight(); 
 
            int seekToPosition = mSeekWhenPrepared;  // mSeekWhenPrepared may be changed after seekTo() call 
            if (seekToPosition != 0) { 
                seekTo(seekToPosition); 
            } 
            mp.setLooping(mLooping); 
            if (mVideoWidth != 0 && mVideoHeight != 0) { 
                //Log.i("@@@@", "video size: " + mVideoWidth +"/"+ mVideoHeight); 
                getHolder().setFixedSize(mVideoWidth, mVideoHeight); 
                if (mSurfaceWidth == mVideoWidth && mSurfaceHeight == mVideoHeight) { 
                    // We didn't actually change the size (it was already at the size 
                    // we need), so we won't get a "surface changed" callback, so 
                    // start the video here instead of in the callback. 
                    if (mTargetState == STATE_PLAYING) { 
                        start(); 
                        if (mMediaController != null) { 
                            mMediaController.show(); 
                        } 
                    } else if (!isPlaying() && 
                               (seekToPosition != 0 || getCurrentPosition() > 0)) { 
                       if (mMediaController != null) { 
                           // Show the media controls when we're paused into a video and make 'em stick. 
                           mMediaController.show(0); 
                       } 
                   } 
                } 
            } else { 
                // We don't know the video size yet, but should start anyway.