From 4e2bbc410f1226c0f8b3086e793909f77d32e3ee Mon Sep 17 00:00:00 2001 From: u0u0 Date: Mon, 17 Jan 2022 14:29:32 +0800 Subject: [PATCH] android videoplayer bugfix. --- .../java/src/org/cocos2dx/lib/Cocos2dxVideoView.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java index 93ea3e3..08685e2 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java @@ -62,6 +62,7 @@ public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl */ private int mCurrentState = STATE_IDLE; private int mTargetState = STATE_IDLE; + private boolean isComplete = false; // All the stuff we need for playing and showing a video private SurfaceHolder mSurfaceHolder = null; @@ -570,7 +571,7 @@ public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { - boolean isValidState = (mTargetState == STATE_PLAYING); + boolean isValidState = (mTargetState == STATE_PLAYING) || !isComplete; boolean hasValidSize = (mVideoWidth == w && mVideoHeight == h); if (mMediaPlayer != null && isValidState && hasValidSize) { if (mSeekWhenPrepared != 0) { @@ -590,7 +591,8 @@ public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl { // after we return from this we can't use the surface any more mSurfaceHolder = null; - + isComplete = mMediaPlayer.getCurrentPosition() == mMediaPlayer.getDuration(); + mSeekWhenPrepared = mMediaPlayer.getCurrentPosition(); release(true); } };