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

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

Merge "Support full screen back to back playing using javascript"

parents 00db1f52 96fae5e0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -198,6 +198,10 @@ public class HTML5VideoFullScreen extends HTML5VideoView
        // Call into the native to ask for the state, if still in play mode,
        // this will trigger the video to play.
        mProxy.dispatchOnRestoreState();

        if (getStartWhenPrepared()) {
            mPlayer.start();
        }
    }

    public boolean fullScreenExited() {
+31 −13
Original line number Diff line number Diff line
@@ -194,20 +194,9 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
        mPlayer.setOnInfoListener(proxy);
    }

    // Normally called immediately after setVideoURI. But for full screen,
    // this should be after surface holder created
    public void prepareDataAndDisplayMode(HTML5VideoViewProxy proxy) {
        // SurfaceTexture will be created lazily here for inline mode
        decideDisplayMode();

        setOnCompletionListener(proxy);
        setOnPreparedListener(proxy);
        setOnErrorListener(proxy);
        setOnInfoListener(proxy);
        // When there is exception, we could just bail out silently.
        // No Video will be played though. Write the stack for debug
    public void prepareDataCommon(HTML5VideoViewProxy proxy) {
        try {
            mPlayer.setDataSource(mProxy.getContext(), mUri, mHeaders);
            mPlayer.setDataSource(proxy.getContext(), mUri, mHeaders);
            mPlayer.prepareAsync();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
@@ -219,6 +208,25 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
        mCurrentState = STATE_NOTPREPARED;
    }

    public void reprepareData(HTML5VideoViewProxy proxy) {
        mPlayer.reset();
        prepareDataCommon(proxy);
    }

    // Normally called immediately after setVideoURI. But for full screen,
    // this should be after surface holder created
    public void prepareDataAndDisplayMode(HTML5VideoViewProxy proxy) {
        // SurfaceTexture will be created lazily here for inline mode
        decideDisplayMode();

        setOnCompletionListener(proxy);
        setOnPreparedListener(proxy);
        setOnErrorListener(proxy);
        setOnInfoListener(proxy);

        prepareDataCommon(proxy);
    }


    // Common code
    public int getVideoLayerId() {
@@ -324,4 +332,14 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
        return false;
    }

    private boolean m_startWhenPrepared = false;

    public void setStartWhenPrepared(boolean willPlay) {
        m_startWhenPrepared  = willPlay;
    }

    public boolean getStartWhenPrepared() {
        return m_startWhenPrepared;
    }

}
+15 −0
Original line number Diff line number Diff line
@@ -182,6 +182,21 @@ class HTML5VideoViewProxy extends Handler
            if (mHTML5VideoView != null) {
                currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
                backFromFullScreenMode = mHTML5VideoView.fullScreenExited();

                // When playing video back to back in full screen mode,
                // javascript will switch the src and call play.
                // In this case, we can just reuse the same full screen view,
                // and play the video after prepared.
                if (mHTML5VideoView.isFullScreenMode()
                    && !backFromFullScreenMode
                    && currentVideoLayerId != videoLayerId
                    && mCurrentProxy != proxy) {
                    mCurrentProxy = proxy;
                    mHTML5VideoView.setStartWhenPrepared(true);
                    mHTML5VideoView.setVideoURI(url, proxy);
                    mHTML5VideoView.reprepareData(proxy);
                    return;
                }
            }

            if (backFromFullScreenMode