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

Commit f17bd971 authored by Teng-Hui Zhu's avatar Teng-Hui Zhu Committed by Android (Google) Code Review
Browse files

Merge "Release the media player when exiting the full screen"

parents 091b2485 b1c2c1e3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ public class HTML5VideoFullScreen extends HTML5VideoView
            // After we return from this we can't use the surface any more.
            // The current Video View will be destroy when we play a new video.
            pauseAndDispatch(mProxy);
            mPlayer.release();
            mSurfaceHolder = null;
            if (mMediaController != null) {
                mMediaController.hide();
@@ -226,6 +227,10 @@ public class HTML5VideoFullScreen extends HTML5VideoView
                mProxy.getWebView().getViewManager().showAll();

                mProxy = null;

                // Don't show the controller after exiting the full screen.
                mMediaController = null;
                mCurrentState = STATE_RELEASED;
            }
        };

+12 −4
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
    static final int STATE_NOTPREPARED        = 1;
    static final int STATE_PREPARED           = 2;
    static final int STATE_PLAYING            = 3;
    static final int STATE_RELEASED           = 4;
    protected int mCurrentState;

    protected HTML5VideoViewProxy mProxy;
@@ -84,7 +85,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
    }

    public void pause() {
        if (mCurrentState == STATE_PREPARED && mPlayer.isPlaying()) {
        if (isPlaying()) {
            mPlayer.pause();
        } else if (mCurrentState == STATE_NOTPREPARED) {
            mPauseDuringPreparing = true;
@@ -120,12 +121,19 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
    }

    public boolean isPlaying() {
        if (mCurrentState == STATE_PREPARED) {
            return mPlayer.isPlaying();
        } else {
            return false;
        }
    }

    public void release() {
        if (mCurrentState != STATE_RELEASED) {
            mPlayer.release();
        }
        mCurrentState = STATE_RELEASED;
    }

    public void stopPlayback() {
        if (mCurrentState == STATE_PREPARED) {
@@ -228,7 +236,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {


    public int getCurrentState() {
        if (mPlayer.isPlaying()) {
        if (isPlaying()) {
            return STATE_PLAYING;
        } else {
            return mCurrentState;