Code example for MediaController

Methods: setAnchorView, setEnabled, setMediaPlayer, show

0
        attachMediaController(); 
    } 
 
    private void attachMediaController() { 
        if (mMediaController != null) {
            mMediaController.setMediaPlayer(this);
            mMediaController.setAnchorView(mVideoSurfaceView);
            mMediaController.setEnabled(mHasMediaMetadata);
        } 
    } 
 
    @CalledByNative 
    public void openVideo() { 
        if (mSurfaceHolder != null) {
            if (mNativeChromeVideoView != 0) {
                nativeUpdateMediaMetadata(mNativeChromeVideoView);
            } 
            mCurrentBufferPercentage = 0;
            if (mNativeChromeVideoView != 0) {
                int renderHandle = nativeGetRenderHandle(mNativeChromeVideoView);
                if (renderHandle == 0) {
                    nativeSetSurface(mNativeChromeVideoView,
                            mSurfaceHolder.getSurface(),
                            nativeGetRouteId(mNativeChromeVideoView),
                            nativeGetPlayerId(mNativeChromeVideoView));
                    return; 
                } 
                ISandboxedProcessService service =
                    SandboxedProcessLauncher.getSandboxedService(renderHandle);
                if (service == null) {
                    Log.e(TAG, "Unable to get SandboxedProcessService from pid.");
                    return; 
                } 
                try { 
                    service.setSurface(
                            SET_VIDEO_SURFACE_TEXTURE,
                            mSurfaceHolder.getSurface(),
                            nativeGetRouteId(mNativeChromeVideoView),
                            nativeGetPlayerId(mNativeChromeVideoView));
                } catch (RemoteException e) {
                    Log.e(TAG, "Unable to call setSurfaceTexture: " + e);
                    return; 
                } 
            } 
            requestLayout(); 
            invalidate(); 
            setMediaController(new MediaController(getChromeActivity()));
 
            if (mMediaController != null) {
                mMediaController.show();
            } 
        } 
    } 
 
    private Handler getEventHandler() {