diff options
author | zhuw <zhuw@codeaurora.org> | 2018-04-04 10:46:00 +0800 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2018-04-17 00:29:02 +0200 |
commit | 9c18367fd8ad788028ebd90c432f8b9111cd378c (patch) | |
tree | c354b97072d9142b9e34f1264b326b13b89687ea | |
parent | db965e56549540b29141778c2610bfa834459866 (diff) | |
download | android_packages_apps_Gallery2-9c18367fd8ad788028ebd90c432f8b9111cd378c.tar.gz android_packages_apps_Gallery2-9c18367fd8ad788028ebd90c432f8b9111cd378c.tar.bz2 android_packages_apps_Gallery2-9c18367fd8ad788028ebd90c432f8b9111cd378c.zip |
Fix Time bar don't update replay after trim
add start Timer callback, run during start()
Change-Id: I648d8a28c7ab9b49c8703ceab482214b992cf8de
-rwxr-xr-x | src/com/android/gallery3d/app/MoviePlayer.java | 16 | ||||
-rw-r--r-- | src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java | 13 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index 132003dda..54f1fc772 100755 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -67,6 +67,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.util.HashMap; import java.util.Map; +import java.util.Timer; public class MoviePlayer implements MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener, @@ -194,6 +195,18 @@ public class MoviePlayer implements } }; + public interface TimerProgress { + void startTimer(); + } + + private TimerProgress mTimerController = new TimerProgress() { + @Override + public void startTimer() { + mHandler.removeCallbacks(mProgressChecker); + mHandler.post(mProgressChecker); + } + }; + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -236,6 +249,7 @@ public class MoviePlayer implements mVideoView.setOnErrorListener(this); mVideoView.setOnCompletionListener(this); + mVideoView.setTimerProgress(mTimerController); if (mVirtualizer != null) { mVirtualizer.release(); @@ -516,7 +530,7 @@ public class MoviePlayer implements mHandler.postDelayed(mPlayingChecker, 250); } - mHandler.post(mProgressChecker); + mTimerController.startTimer(); } private void pauseVideoMoreThanThreeMinutes() { diff --git a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java index 4c608f28f..8e829fb97 100644 --- a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java +++ b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java @@ -27,6 +27,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.widget.MediaController; import android.widget.MediaController.MediaPlayerControl; +import com.android.gallery3d.app.MoviePlayer; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.ApiHelper.Metadata; @@ -84,6 +85,7 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr private MediaPlayer.OnVideoSizeChangedListener mVideoSizeListener; private MediaPlayer.OnPreparedListener mPreparedListener; private ScreenModeManager mScreenManager; + private MoviePlayer.TimerProgress mTimerController; private int mCurrentBufferPercentage; private OnErrorListener mOnErrorListener; private OnInfoListener mOnInfoListener; @@ -619,6 +621,16 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr mOnInfoListener = l; } + /** + * Register a callback to start Timer for time progress bar + * occurs during this.start() + * + * @param c The callback that will be run + */ + public void setTimerProgress(MoviePlayer.TimerProgress c) { + mTimerController = c; + } + SurfaceHolder.Callback mSHCallback = new SurfaceHolder.Callback() { public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { @@ -770,6 +782,7 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr if (mIsShowDialog) return; if (isInPlaybackState()) { mMediaPlayer.start(); + mTimerController.startTimer(); mCurrentState = STATE_PLAYING; } mTargetState = STATE_PLAYING; |