Loading core/java/android/webkit/HTML5VideoInline.java +0 −15 Original line number Original line Diff line number Diff line Loading @@ -17,24 +17,15 @@ public class HTML5VideoInline extends HTML5VideoView{ private static SurfaceTexture mSurfaceTexture = null; private static SurfaceTexture mSurfaceTexture = null; private static int[] mTextureNames; 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: // Video control FUNCTIONS: @Override @Override public void start() { public void start() { super.start(); super.start(); if (mCurrentState == STATE_PREPARED) { mReadyToUseSurfTex = true; } } } HTML5VideoInline(int videoLayerId, int position, HTML5VideoInline(int videoLayerId, int position, boolean autoStart) { boolean autoStart) { init(videoLayerId, position, autoStart); init(videoLayerId, position, autoStart); mReadyToUseSurfTex = false; } } @Override @Override Loading @@ -54,7 +45,6 @@ public class HTML5VideoInline extends HTML5VideoView{ @Override @Override public void pauseAndDispatch(HTML5VideoViewProxy proxy) { public void pauseAndDispatch(HTML5VideoViewProxy proxy) { super.pauseAndDispatch(proxy); super.pauseAndDispatch(proxy); mReadyToUseSurfTex = false; } } // Inline Video specific FUNCTIONS: // Inline Video specific FUNCTIONS: Loading Loading @@ -87,11 +77,6 @@ public class HTML5VideoInline extends HTML5VideoView{ return mTextureNames[0]; return mTextureNames[0]; } } @Override public boolean getReadyToUseSurfTex() { return mReadyToUseSurfTex; } private void setFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener l) { private void setFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener l) { mSurfaceTexture.setOnFrameAvailableListener(l); mSurfaceTexture.setOnFrameAvailableListener(l); } } Loading core/java/android/webkit/HTML5VideoView.java +17 −4 Original line number Original line Diff line number Diff line Loading @@ -27,9 +27,12 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ // prepared and not prepared. // prepared and not prepared. // When the video is not prepared, we will have to save the seekTo time, // When the video is not prepared, we will have to save the seekTo time, // and use it when prepared to play. // and use it when prepared to play. protected static final int STATE_NOTPREPARED = 0; // NOTE: these values are in sync with VideoLayerAndroid.h in webkit side. protected static final int STATE_PREPARED = 1; // 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 int mCurrentState; protected HTML5VideoViewProxy mProxy; protected HTML5VideoViewProxy mProxy; Loading Loading @@ -121,7 +124,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ // Every time we start a new Video, we create a VideoView and a MediaPlayer // Every time we start a new Video, we create a VideoView and a MediaPlayer public void init(int videoLayerId, int position, boolean autoStart) { public void init(int videoLayerId, int position, boolean autoStart) { mPlayer = new MediaPlayer(); mPlayer = new MediaPlayer(); mCurrentState = STATE_NOTPREPARED; mCurrentState = STATE_INITIALIZED; mProxy = null; mProxy = null; mVideoLayerId = videoLayerId; mVideoLayerId = videoLayerId; mSaveSeekTime = position; mSaveSeekTime = position; Loading Loading @@ -190,6 +193,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ } catch (IOException e) { } catch (IOException e) { e.printStackTrace(); e.printStackTrace(); } } mCurrentState = STATE_NOTPREPARED; } } Loading @@ -198,6 +202,15 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ return mVideoLayerId; return mVideoLayerId; } } public int getCurrentState() { if (mPlayer.isPlaying()) { return STATE_PLAYING; } else { return mCurrentState; } } private static final class TimeupdateTask extends TimerTask { private static final class TimeupdateTask extends TimerTask { private HTML5VideoViewProxy mProxy; private HTML5VideoViewProxy mProxy; Loading core/java/android/webkit/HTML5VideoViewProxy.java +8 −5 Original line number Original line Diff line number Diff line Loading @@ -105,12 +105,12 @@ class HTML5VideoViewProxy extends Handler int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) { if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) { boolean readyToUseSurfTex = int playerState = mHTML5VideoView.getCurrentState(); mHTML5VideoView.getReadyToUseSurfTex(); boolean foundInTree = nativeSendSurfaceTexture(surfTexture, boolean foundInTree = nativeSendSurfaceTexture(surfTexture, layer, currentVideoLayerId, textureName, layer, currentVideoLayerId, textureName, readyToUseSurfTex); playerState); if (readyToUseSurfTex && !foundInTree) { if (playerState == HTML5VideoView.STATE_PREPARED && !foundInTree) { mHTML5VideoView.pauseAndDispatch(mCurrentProxy); mHTML5VideoView.pauseAndDispatch(mCurrentProxy); mHTML5VideoView.deleteSurfaceTexture(); mHTML5VideoView.deleteSurfaceTexture(); } } Loading Loading @@ -228,6 +228,9 @@ class HTML5VideoViewProxy extends Handler mHTML5VideoView.isFullScreenMode() && mHTML5VideoView.isFullScreenMode() && mHTML5VideoView.getAutostart() ) mHTML5VideoView.getAutostart() ) mHTML5VideoView.start(); mHTML5VideoView.start(); if (mBaseLayer != 0) { setBaseLayer(mBaseLayer); } } } public static void end() { public static void end() { Loading Loading @@ -668,5 +671,5 @@ class HTML5VideoViewProxy extends Handler private native void nativeOnTimeupdate(int position, int nativePointer); private native void nativeOnTimeupdate(int position, int nativePointer); private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture, private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture, int baseLayer, int videoLayerId, int textureName, int baseLayer, int videoLayerId, int textureName, boolean updateTexture); int playerState); } } Loading
core/java/android/webkit/HTML5VideoInline.java +0 −15 Original line number Original line Diff line number Diff line Loading @@ -17,24 +17,15 @@ public class HTML5VideoInline extends HTML5VideoView{ private static SurfaceTexture mSurfaceTexture = null; private static SurfaceTexture mSurfaceTexture = null; private static int[] mTextureNames; 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: // Video control FUNCTIONS: @Override @Override public void start() { public void start() { super.start(); super.start(); if (mCurrentState == STATE_PREPARED) { mReadyToUseSurfTex = true; } } } HTML5VideoInline(int videoLayerId, int position, HTML5VideoInline(int videoLayerId, int position, boolean autoStart) { boolean autoStart) { init(videoLayerId, position, autoStart); init(videoLayerId, position, autoStart); mReadyToUseSurfTex = false; } } @Override @Override Loading @@ -54,7 +45,6 @@ public class HTML5VideoInline extends HTML5VideoView{ @Override @Override public void pauseAndDispatch(HTML5VideoViewProxy proxy) { public void pauseAndDispatch(HTML5VideoViewProxy proxy) { super.pauseAndDispatch(proxy); super.pauseAndDispatch(proxy); mReadyToUseSurfTex = false; } } // Inline Video specific FUNCTIONS: // Inline Video specific FUNCTIONS: Loading Loading @@ -87,11 +77,6 @@ public class HTML5VideoInline extends HTML5VideoView{ return mTextureNames[0]; return mTextureNames[0]; } } @Override public boolean getReadyToUseSurfTex() { return mReadyToUseSurfTex; } private void setFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener l) { private void setFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener l) { mSurfaceTexture.setOnFrameAvailableListener(l); mSurfaceTexture.setOnFrameAvailableListener(l); } } Loading
core/java/android/webkit/HTML5VideoView.java +17 −4 Original line number Original line Diff line number Diff line Loading @@ -27,9 +27,12 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ // prepared and not prepared. // prepared and not prepared. // When the video is not prepared, we will have to save the seekTo time, // When the video is not prepared, we will have to save the seekTo time, // and use it when prepared to play. // and use it when prepared to play. protected static final int STATE_NOTPREPARED = 0; // NOTE: these values are in sync with VideoLayerAndroid.h in webkit side. protected static final int STATE_PREPARED = 1; // 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 int mCurrentState; protected HTML5VideoViewProxy mProxy; protected HTML5VideoViewProxy mProxy; Loading Loading @@ -121,7 +124,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ // Every time we start a new Video, we create a VideoView and a MediaPlayer // Every time we start a new Video, we create a VideoView and a MediaPlayer public void init(int videoLayerId, int position, boolean autoStart) { public void init(int videoLayerId, int position, boolean autoStart) { mPlayer = new MediaPlayer(); mPlayer = new MediaPlayer(); mCurrentState = STATE_NOTPREPARED; mCurrentState = STATE_INITIALIZED; mProxy = null; mProxy = null; mVideoLayerId = videoLayerId; mVideoLayerId = videoLayerId; mSaveSeekTime = position; mSaveSeekTime = position; Loading Loading @@ -190,6 +193,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ } catch (IOException e) { } catch (IOException e) { e.printStackTrace(); e.printStackTrace(); } } mCurrentState = STATE_NOTPREPARED; } } Loading @@ -198,6 +202,15 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ return mVideoLayerId; return mVideoLayerId; } } public int getCurrentState() { if (mPlayer.isPlaying()) { return STATE_PLAYING; } else { return mCurrentState; } } private static final class TimeupdateTask extends TimerTask { private static final class TimeupdateTask extends TimerTask { private HTML5VideoViewProxy mProxy; private HTML5VideoViewProxy mProxy; Loading
core/java/android/webkit/HTML5VideoViewProxy.java +8 −5 Original line number Original line Diff line number Diff line Loading @@ -105,12 +105,12 @@ class HTML5VideoViewProxy extends Handler int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) { if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) { boolean readyToUseSurfTex = int playerState = mHTML5VideoView.getCurrentState(); mHTML5VideoView.getReadyToUseSurfTex(); boolean foundInTree = nativeSendSurfaceTexture(surfTexture, boolean foundInTree = nativeSendSurfaceTexture(surfTexture, layer, currentVideoLayerId, textureName, layer, currentVideoLayerId, textureName, readyToUseSurfTex); playerState); if (readyToUseSurfTex && !foundInTree) { if (playerState == HTML5VideoView.STATE_PREPARED && !foundInTree) { mHTML5VideoView.pauseAndDispatch(mCurrentProxy); mHTML5VideoView.pauseAndDispatch(mCurrentProxy); mHTML5VideoView.deleteSurfaceTexture(); mHTML5VideoView.deleteSurfaceTexture(); } } Loading Loading @@ -228,6 +228,9 @@ class HTML5VideoViewProxy extends Handler mHTML5VideoView.isFullScreenMode() && mHTML5VideoView.isFullScreenMode() && mHTML5VideoView.getAutostart() ) mHTML5VideoView.getAutostart() ) mHTML5VideoView.start(); mHTML5VideoView.start(); if (mBaseLayer != 0) { setBaseLayer(mBaseLayer); } } } public static void end() { public static void end() { Loading Loading @@ -668,5 +671,5 @@ class HTML5VideoViewProxy extends Handler private native void nativeOnTimeupdate(int position, int nativePointer); private native void nativeOnTimeupdate(int position, int nativePointer); private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture, private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture, int baseLayer, int videoLayerId, int textureName, int baseLayer, int videoLayerId, int textureName, boolean updateTexture); int playerState); } }