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

Commit 5294630b authored by Rajshekar Eashwarappa's avatar Rajshekar Eashwarappa Committed by Steve Kondik
Browse files

webkit: Manage video playing state properly when browser goes to background

Issue: Browser App Video streaming not pausing while pressing home Button

Fix : When the Browser goes to the background while the video is playing
      in the fullscreen, the fullscreen mode is exited. While exiting
      the full screen mode the video state is handled properly. So that
      there is no playback in the background.

CRs-Fixed: 509225

Change-Id: I32c306923d2638731d34d216cf006050ce4ad825
parent 903eee45
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -98,6 +98,17 @@ class HTML5VideoViewProxy extends Handler

        private static boolean isVideoSelfEnded = false;

        // Define states for when browser has exited fullscreen.
        // These are used to determine whether to resume video playback
        // after exiting fullscreen.
        static final int EXIT_FULLSCREEN_STATE_NONE = 0;
        // Video exited fullscreen mode in playing state
        static final int EXIT_FULLSCREEN_STATE_PLAYING = 1;
        // Video exited fullscreen mode in playing state but was paused
        // before it resumed in inline mode.
        static final int EXIT_FULLSCREEN_STATE_PAUSED = 2;
        private static int mExitFullscreenState = EXIT_FULLSCREEN_STATE_NONE;

        private static void setPlayerBuffering(boolean playerBuffering) {
            mHTML5VideoView.setPlayerBuffering(playerBuffering);
        }
@@ -133,6 +144,9 @@ class HTML5VideoViewProxy extends Handler
        // When a WebView is paused, we also want to pause the video in it. (won't be used any more, use suspendAndDispatch())
        public static void pauseAndDispatch() {
            if (mHTML5VideoView != null) {
                // Check if video was paused after it exited fullscreen in playing state
                if (mExitFullscreenState == VideoPlayer.EXIT_FULLSCREEN_STATE_PLAYING)
                    mExitFullscreenState = VideoPlayer.EXIT_FULLSCREEN_STATE_PAUSED;
                mHTML5VideoView.pauseAndDispatch(mCurrentProxy);
            }
        }
@@ -293,9 +307,14 @@ class HTML5VideoViewProxy extends Handler
        }

        public static void onPrepared() {
            if (!mHTML5VideoView.isFullScreenMode()) {
            // Start the video playback only if the video was not paused
            // while exiting fullscreen mode
            if (!mHTML5VideoView.isFullScreenMode() &&
                mExitFullscreenState != VideoPlayer.EXIT_FULLSCREEN_STATE_PAUSED) {
                mHTML5VideoView.start();
            }
            // Reset the exit fullscreen state after media is prepared
            mExitFullscreenState = VideoPlayer.EXIT_FULLSCREEN_STATE_NONE;
        }

        public static void end() {
@@ -363,6 +382,9 @@ class HTML5VideoViewProxy extends Handler

    public void dispatchOnStopFullScreen(boolean stillPlaying) {
        Message msg = Message.obtain(mWebCoreHandler, STOPFULLSCREEN);
        VideoPlayer.mExitFullscreenState = stillPlaying ?
                VideoPlayer.EXIT_FULLSCREEN_STATE_PLAYING :
                VideoPlayer.EXIT_FULLSCREEN_STATE_NONE;
        msg.arg1 = stillPlaying ? 1 : 0;
        mWebCoreHandler.sendMessage(msg);
    }