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

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

Merge "Buffering in full screen mode will show progressView"

parents a51e9fd5 f4d4e9e0
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -198,8 +198,6 @@ public class HTML5VideoFullScreen extends HTML5VideoView

        if (mProgressView != null) {
            mProgressView.setVisibility(View.GONE);
            mLayout.removeView(mProgressView);
            mProgressView = null;
        }

        mVideoWidth = mp.getVideoWidth();
@@ -321,4 +319,13 @@ public class HTML5VideoFullScreen extends HTML5VideoView
        return false;
    }

    @Override
    protected void switchProgressView(boolean playerBuffering) {
        if (playerBuffering) {
            mProgressView.setVisibility(View.VISIBLE);
        } else {
            mProgressView.setVisibility(View.GONE);
        }
        return;
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
                        TIMEUPDATE_PERIOD);
            }
            mPlayer.start();
            setPlayerBuffering(false);
        }
    }

@@ -296,4 +297,21 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
        return 0;
    }

    // This is true only when the player is buffering and paused
    public boolean mPlayerBuffering = false;

    public boolean getPlayerBuffering() {
        return mPlayerBuffering;
    }

    public void setPlayerBuffering(boolean playerBuffering) {
        mPlayerBuffering = playerBuffering;
        switchProgressView(playerBuffering);
    }


    protected void switchProgressView(boolean playerBuffering) {
        // Only used in HTML5VideoFullScreen
    }

}
+7 −7
Original line number Diff line number Diff line
@@ -95,8 +95,10 @@ class HTML5VideoViewProxy extends Handler
        // identify the exact layer on the UI thread to use the SurfaceTexture.
        private static int mBaseLayer = 0;

        // This is true only when the player is buffering and paused
        private static boolean mPlayerBuffering = false;
        private static void setPlayerBuffering(boolean playerBuffering) {
            mHTML5VideoView.setPlayerBuffering(playerBuffering);
        }

        // Every time webView setBaseLayer, this will be called.
        // When we found the Video layer, then we set the Surface Texture to it.
        // Otherwise, we may want to delete the Surface Texture to save memory.
@@ -111,7 +113,7 @@ class HTML5VideoViewProxy extends Handler
                int currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
                if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) {
                    int playerState = mHTML5VideoView.getCurrentState();
                    if (mPlayerBuffering)
                    if (mHTML5VideoView.getPlayerBuffering())
                        playerState = HTML5VideoView.STATE_NOTPREPARED;
                    boolean foundInTree = nativeSendSurfaceTexture(surfTexture,
                            layer, currentVideoLayerId, textureName,
@@ -166,7 +168,6 @@ class HTML5VideoViewProxy extends Handler
                WebChromeClient client, int videoLayerId) {
            int currentVideoLayerId = -1;
            boolean backFromFullScreenMode = false;
            mPlayerBuffering = false;
            if (mHTML5VideoView != null) {
                currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
                if (mHTML5VideoView instanceof HTML5VideoFullScreen) {
@@ -231,7 +232,6 @@ class HTML5VideoViewProxy extends Handler
        }

        public static void onPrepared() {
            mPlayerBuffering = false;
            // The VideoView will decide whether to really kick off to play.
            mHTML5VideoView.start();
            if (mBaseLayer != 0) {
@@ -350,11 +350,11 @@ class HTML5VideoViewProxy extends Handler
                break;
            }
            case BUFFERING_START: {
                VideoPlayer.mPlayerBuffering = true;
                VideoPlayer.setPlayerBuffering(true);
                break;
            }
            case BUFFERING_END: {
                VideoPlayer.mPlayerBuffering = false;
                VideoPlayer.setPlayerBuffering(false);
                break;
            }
        }