Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa00e390 authored by James Dong's avatar James Dong
Browse files

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.
parent a1b653d4
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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;