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

Commit f82e5a2c authored by Teng-Hui Zhu's avatar Teng-Hui Zhu Committed by Android Git Automerger
Browse files

am 0b933c02: Merge "Support loading image and paused image for inline video" into honeycomb-mr1

* commit '0b933c02':
  Support loading image and paused image for inline video
parents 38cf000a 0b933c02
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -17,24 +17,15 @@ public class HTML5VideoInline extends HTML5VideoView{
    private static SurfaceTexture mSurfaceTexture = null;
    private static int[] mTextureNames;

    // Only when the video is prepared, we render using SurfaceTexture.
    // This in fact is used to avoid showing the obsolete content when
    // switching videos.
    private static boolean mReadyToUseSurfTex = false;

    // Video control FUNCTIONS:
    @Override
    public void start() {
        super.start();
        if (mCurrentState == STATE_PREPARED) {
            mReadyToUseSurfTex = true;
        }
    }

    HTML5VideoInline(int videoLayerId, int position,
            boolean autoStart) {
        init(videoLayerId, position, autoStart);
        mReadyToUseSurfTex = false;
    }

    @Override
@@ -54,7 +45,6 @@ public class HTML5VideoInline extends HTML5VideoView{
    @Override
    public void pauseAndDispatch(HTML5VideoViewProxy proxy) {
        super.pauseAndDispatch(proxy);
        mReadyToUseSurfTex = false;
    }

    // Inline Video specific FUNCTIONS:
@@ -87,11 +77,6 @@ public class HTML5VideoInline extends HTML5VideoView{
        return mTextureNames[0];
    }

    @Override
    public boolean getReadyToUseSurfTex() {
        return mReadyToUseSurfTex;
    }

    private void setFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener l) {
        mSurfaceTexture.setOnFrameAvailableListener(l);
    }
+17 −4
Original line number Diff line number Diff line
@@ -27,9 +27,12 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
    // prepared and not prepared.
    // When the video is not prepared, we will have to save the seekTo time,
    // and use it when prepared to play.
    protected static final int STATE_NOTPREPARED        = 0;
    protected static final int STATE_PREPARED           = 1;

    // NOTE: these values are in sync with VideoLayerAndroid.h in webkit side.
    // Please keep them in sync when changed.
    static final int STATE_INITIALIZED        = 0;
    static final int STATE_NOTPREPARED        = 1;
    static final int STATE_PREPARED           = 2;
    static final int STATE_PLAYING            = 3;
    protected int mCurrentState;

    protected HTML5VideoViewProxy mProxy;
@@ -121,7 +124,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
    // Every time we start a new Video, we create a VideoView and a MediaPlayer
    public void init(int videoLayerId, int position, boolean autoStart) {
        mPlayer = new MediaPlayer();
        mCurrentState = STATE_NOTPREPARED;
        mCurrentState = STATE_INITIALIZED;
        mProxy = null;
        mVideoLayerId = videoLayerId;
        mSaveSeekTime = position;
@@ -190,6 +193,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
        } catch (IOException e) {
            e.printStackTrace();
        }
        mCurrentState = STATE_NOTPREPARED;
    }


@@ -198,6 +202,15 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
        return mVideoLayerId;
    }


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

    private static final class TimeupdateTask extends TimerTask {
        private HTML5VideoViewProxy mProxy;

+8 −5
Original line number Diff line number Diff line
@@ -105,12 +105,12 @@ class HTML5VideoViewProxy extends Handler

                int currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
                if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) {
                    boolean readyToUseSurfTex =
                        mHTML5VideoView.getReadyToUseSurfTex();
                    int playerState = mHTML5VideoView.getCurrentState();
                    boolean foundInTree = nativeSendSurfaceTexture(surfTexture,
                            layer, currentVideoLayerId, textureName,
                            readyToUseSurfTex);
                    if (readyToUseSurfTex && !foundInTree) {
                            playerState);
                    if (playerState == HTML5VideoView.STATE_PREPARED
                            && !foundInTree) {
                        mHTML5VideoView.pauseAndDispatch(mCurrentProxy);
                        mHTML5VideoView.deleteSurfaceTexture();
                    }
@@ -228,6 +228,9 @@ class HTML5VideoViewProxy extends Handler
                    mHTML5VideoView.isFullScreenMode() &&
                    mHTML5VideoView.getAutostart() )
                mHTML5VideoView.start();
            if (mBaseLayer != 0) {
                setBaseLayer(mBaseLayer);
            }
        }

        public static void end() {
@@ -668,5 +671,5 @@ class HTML5VideoViewProxy extends Handler
    private native void nativeOnTimeupdate(int position, int nativePointer);
    private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture,
            int baseLayer, int videoLayerId, int textureName,
            boolean updateTexture);
            int playerState);
}