From 265db32f31a9db60d4a93d59befa07c825cbe4f2 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Fri, 18 Mar 2011 14:56:10 -0700 Subject: Support loading image and paused image for inline video bug:4142131 Change-Id: I28d82a8e30a2146a3380c63dcdcbd51228f23f56 --- core/java/android/webkit/HTML5VideoView.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'core/java/android/webkit/HTML5VideoView.java') diff --git a/core/java/android/webkit/HTML5VideoView.java b/core/java/android/webkit/HTML5VideoView.java index 663497c76c5c..b9d55e07d62b 100644 --- a/core/java/android/webkit/HTML5VideoView.java +++ b/core/java/android/webkit/HTML5VideoView.java @@ -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; -- cgit v1.2.3