Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b127bf2e authored by Gloria Wang's avatar Gloria Wang Committed by Android (Google) Code Review
Browse files

Merge "Release MediaPlayer if suspend() returns false."

parents f298a027 047212fd
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
    private static final int STATE_PLAYBACK_COMPLETED = 5;
    private static final int STATE_SUSPEND            = 6;
    private static final int STATE_RESUME             = 7;
    private static final int STATE_SUSPEND_UNSUPPORTED = 8;

    // mCurrentState is a VideoView object's current state.
    // mTargetState is the state that a method caller intends to reach.
@@ -586,8 +587,9 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
                mCurrentState = STATE_SUSPEND;
                mTargetState = STATE_SUSPEND;
            } else {
                Log.w(TAG, "Unable to suspend video");
                mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
                release(false);
                mCurrentState = STATE_SUSPEND_UNSUPPORTED;
                Log.w(TAG, "Unable to suspend video. Release MediaPlayer.");
            }
        }
    }
@@ -603,8 +605,11 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
                mTargetState = mStateWhenSuspended;
            } else {
                Log.w(TAG, "Unable to resume video");
                mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
            }
            return;
        }
        if (mCurrentState == STATE_SUSPEND_UNSUPPORTED) {
            openVideo();
        }
    }