diff options
| author | James Dong <jdong@google.com> | 2009-07-02 16:26:39 -0700 |
|---|---|---|
| committer | James Dong <jdong@google.com> | 2009-07-06 11:30:29 -0700 |
| commit | aa00e390c191f9b4eaee8ecade88c74571b2b3f3 (patch) | |
| tree | bacdd86175d1511303e87b9753e94451d0cb3e8a /core | |
| parent | a1b653d41df9a7999e1dba2a508295671ff6771d (diff) | |
| download | frameworks_base-aa00e390c191f9b4eaee8ecade88c74571b2b3f3.zip frameworks_base-aa00e390c191f9b4eaee8ecade88c74571b2b3f3.tar.gz frameworks_base-aa00e390c191f9b4eaee8ecade88c74571b2b3f3.tar.bz2 | |
Fix bug (#1947162)
The bug (1947162) is caused by the fact that sometimes, surfaceChanged() is called after onCompletion().
In surfaceChanged(), start() is called automatically. The fix is to use a flag is avoid calling start()
when onCompletion() has been called already.
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/widget/VideoView.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/core/java/android/widget/VideoView.java b/core/java/android/widget/VideoView.java index 6d3a2d3..20dd8a6 100644 --- a/core/java/android/widget/VideoView.java +++ b/core/java/android/widget/VideoView.java @@ -55,6 +55,7 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { private SurfaceHolder mSurfaceHolder = null; private MediaPlayer mMediaPlayer = null; private boolean mIsPrepared; + private boolean mIsPlaybackCompleted; private int mVideoWidth; private int mVideoHeight; private int mSurfaceWidth; @@ -260,7 +261,7 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { mSeekWhenPrepared = 0; } if (mStartWhenPrepared) { - mMediaPlayer.start(); + start(); mStartWhenPrepared = false; if (mMediaController != null) { mMediaController.show(); @@ -281,7 +282,7 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { mSeekWhenPrepared = 0; } if (mStartWhenPrepared) { - mMediaPlayer.start(); + start(); mStartWhenPrepared = false; } } @@ -291,6 +292,7 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { private MediaPlayer.OnCompletionListener mCompletionListener = new MediaPlayer.OnCompletionListener() { public void onCompletion(MediaPlayer mp) { + mIsPlaybackCompleted = true; if (mMediaController != null) { mMediaController.hide(); } @@ -405,7 +407,9 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { mMediaPlayer.seekTo(mSeekWhenPrepared); mSeekWhenPrepared = 0; } - mMediaPlayer.start(); + if (!mIsPlaybackCompleted) { + start(); + } if (mMediaController != null) { mMediaController.show(); } @@ -490,6 +494,7 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { } public void start() { + mIsPlaybackCompleted = false; if (mMediaPlayer != null && mIsPrepared) { mMediaPlayer.start(); mStartWhenPrepared = false; |
