diff options
| author | Teng-Hui Zhu <ztenghui@google.com> | 2011-03-22 11:39:23 -0700 |
|---|---|---|
| committer | Teng-Hui Zhu <ztenghui@google.com> | 2011-03-22 12:02:11 -0700 |
| commit | 158fbdb29b8fdda57f942ec2056d908714c326be (patch) | |
| tree | d0241bb3e525181036c3860f8680206981b8ce08 /core/java/android/webkit/HTML5VideoView.java | |
| parent | 8483073ec21b5e2332deaad914eba1d087b1d1e3 (diff) | |
fix for pause when loading
bug:4148903
Change-Id: Ib0b59c8c36eb5df8c6755156a5d2753f84ad9677
Diffstat (limited to 'core/java/android/webkit/HTML5VideoView.java')
| -rw-r--r-- | core/java/android/webkit/HTML5VideoView.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/core/java/android/webkit/HTML5VideoView.java b/core/java/android/webkit/HTML5VideoView.java index cd2264c41342..8ea73b50d4fb 100644 --- a/core/java/android/webkit/HTML5VideoView.java +++ b/core/java/android/webkit/HTML5VideoView.java @@ -65,6 +65,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ // The spec says the timer should fire every 250 ms or less. private static final int TIMEUPDATE_PERIOD = 250; // ms + protected boolean mPauseDuringPreparing; // common Video control FUNCTIONS: public void start() { if (mCurrentState == STATE_PREPARED) { @@ -83,8 +84,9 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ public void pause() { if (mCurrentState == STATE_PREPARED && mPlayer.isPlaying()) { mPlayer.pause(); + } else if (mCurrentState == STATE_NOTPREPARED) { + mPauseDuringPreparing = true; } - // Delete the Timer to stop it since there is no stop call. if (mTimer != null) { mTimer.purge(); @@ -133,6 +135,10 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ return mAutostart; } + public boolean getPauseDuringPreparing() { + return mPauseDuringPreparing; + } + // 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(); @@ -142,6 +148,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ mSaveSeekTime = position; mAutostart = autoStart; mTimer = null; + mPauseDuringPreparing = false; } protected HTML5VideoView() { @@ -242,15 +249,17 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{ if (mProxy != null) { mProxy.onPrepared(mp); } + if (mPauseDuringPreparing) { + pauseAndDispatch(mProxy); + mPauseDuringPreparing = false; + } } // Pause the play and update the play/pause button public void pauseAndDispatch(HTML5VideoViewProxy proxy) { - if (isPlaying()) { - pause(); - if (proxy != null) { - proxy.dispatchOnPaused(); - } + pause(); + if (proxy != null) { + proxy.dispatchOnPaused(); } } |
