media-widget/src/main/java/androidx/media/widget/impl/VideoView2ImplBase.java
@SuppressWarnings("deprecation")
    private void resetPlayer() {
        if (mMediaPlayer != null) {
            final MediaPlayer2 player = mMediaPlayer;
            new AsyncTask<MediaPlayer2, Void, Void>() {
                @Override
                protected Void doInBackground(MediaPlayer2... players) {
                    // TODO: Fix NPE while MediaPlayer2.close()
                    //players[0].close();
                    return null;
                }
            }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, player);
            mMediaPlayer = null;
            mTextureView.setMediaPlayer(null);
            mSurfaceView.setMediaPlayer(null);
            mCurrentState = STATE_IDLE;
            mTargetState = STATE_IDLE;
            if (mAudioFocusType != AudioManager.AUDIOFOCUS_NONE) {
                mAudioManager.abandonAudioFocus(null);
            }
        }
        mVideoWidth = 0;
        mVideoHeight = 0;
    }
/*
     * Reset the media player in any state
     */
Reset the media player in any state
Reset the media player in any state
@SuppressWarnings("deprecation")
    private void resetPlayer() {
        if (mMediaPlayer != null) {
            final MediaPlayer2 player = mMediaPlayer;
            new AsyncTask<MediaPlayer2, Void, Void>() {
                @Override
                protected Void doInBackground(MediaPlayer2... players) {
                    return null;
                }
            }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, player);
            mMediaPlayer = null;
            mTextureView.setMediaPlayer(null);
            mSurfaceView.setMediaPlayer(null);
            mCurrentState = STATE_IDLE;
            mTargetState = STATE_IDLE;
            if (mAudioFocusType != AudioManager.AUDIOFOCUS_NONE) {
                mAudioManager.abandonAudioFocus(null);
            }
        }
        mVideoWidth = 0;
        mVideoHeight = 0;
    }
@ SuppressWarnings ( "deprecation" ) private void resetPlayer ( ) { if ( mMediaPlayer != null ) { final MediaPlayer2 player = mMediaPlayer ; new AsyncTask < MediaPlayer2 , Void , Void > ( ) { @ Override protected Void doInBackground ( MediaPlayer2 ... players ) { return null ; } } . executeOnExecutor ( AsyncTask . SERIAL_EXECUTOR , player ) ; mMediaPlayer = null ; mTextureView . setMediaPlayer ( null ) ; mSurfaceView . setMediaPlayer ( null ) ; mCurrentState = STATE_IDLE ; mTargetState = STATE_IDLE ; if ( mAudioFocusType != AudioManager . AUDIOFOCUS_NONE ) { mAudioManager . abandonAudioFocus ( null ) ; } } mVideoWidth = 0 ; mVideoHeight = 0 ; }
Reset the media player in any state
Reset the media player in any state
// TODO: Fix NPE while MediaPlayer2.close() //players[0].close();