diff options
author | Marco Nelissen <marcone@google.com> | 2009-07-10 14:14:52 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2009-07-10 16:03:15 -0700 |
commit | dddeee6f350673b691b1b9001545a27f9c3d19f0 (patch) | |
tree | 5b3b1624246fbd5abf21c8ea28137f79c859e869 /core/java | |
parent | 9629e04d7a5af62b58ebb6364b53f328d90bfc0e (diff) | |
download | frameworks_base-dddeee6f350673b691b1b9001545a27f9c3d19f0.zip frameworks_base-dddeee6f350673b691b1b9001545a27f9c3d19f0.tar.gz frameworks_base-dddeee6f350673b691b1b9001545a27f9c3d19f0.tar.bz2 |
Fix a problem in VideoView that would cause it to not start playing after prepare.
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/widget/VideoView.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/core/java/android/widget/VideoView.java b/core/java/android/widget/VideoView.java index 3b722f4..5bc2507 100644 --- a/core/java/android/widget/VideoView.java +++ b/core/java/android/widget/VideoView.java @@ -193,7 +193,9 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { i.putExtra("command", "pause"); mContext.sendBroadcast(i); - release(); + // we shouldn't clear the target state, because somebody might have + // called start() previously + release(false); try { mMediaPlayer = new MediaPlayer(); mMediaPlayer.setOnPreparedListener(mPreparedListener); @@ -208,8 +210,9 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setScreenOnWhilePlaying(true); mMediaPlayer.prepareAsync(); + // we don't set the target state here either, but preserve the + // target state that was there before. mCurrentState = STATE_PREPARING; - mTargetState = STATE_PREPARED; attachMediaController(); } catch (IOException ex) { Log.w(TAG, "Unable to open content: " + mUri, ex); @@ -438,20 +441,22 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { // after we return from this we can't use the surface any more mSurfaceHolder = null; if (mMediaController != null) mMediaController.hide(); - release(); + release(true); } }; /* * release the media player in any state */ - private void release() { + private void release(boolean cleartargetstate) { if (mMediaPlayer != null) { mMediaPlayer.reset(); mMediaPlayer.release(); mMediaPlayer = null; mCurrentState = STATE_IDLE; - mTargetState = STATE_IDLE; + if (cleartargetstate) { + mTargetState = STATE_IDLE; + } } } |