Commit 9c18367f authored by zhuw's avatar zhuw Committed by Arne Coucheron

Fix Time bar don't update replay after trim

add start Timer callback, run during start()

Change-Id: I648d8a28c7ab9b49c8703ceab482214b992cf8de
parent db965e56
......@@ -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() {
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment