diff options
author | Chih-Chung Chang <chihchung@google.com> | 2011-09-06 15:36:53 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2011-09-06 15:56:17 +0800 |
commit | 28ed3cbafa7ac82032e3e7bcf77607eff5e677e5 (patch) | |
tree | ad66e22ea3097e41ec7e2e9eca58ee2bbbcbd4da /src | |
parent | 7705dcd14a0249aeb340c3d2466a38bbb7cf281c (diff) | |
download | VideoEditor-28ed3cbafa7ac82032e3e7bcf77607eff5e677e5.tar.gz |
Fix 4601568: video playback pauses after orientation change.
There are several problems:
(1) We might not have a chance restart playing before saving the playing
state and finishing (because we need to wait for surfaceCreated()). So
when saving the playing state, we need to check mRestartPreview as well.
(2) We still need to stop preview even if the activity is being shutdown.
(3) Post mProcessQueueRunnable when mThreadHandler is created, otherwise
the runnable may be posted after the thread itself is gone.
Change-Id: I44794ac40daec9376d238a63fbe254aeece45f10
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/videoeditor/VideoEditorActivity.java | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/com/android/videoeditor/VideoEditorActivity.java b/src/com/android/videoeditor/VideoEditorActivity.java index bf7e785..d904c3d 100755 --- a/src/com/android/videoeditor/VideoEditorActivity.java +++ b/src/com/android/videoeditor/VideoEditorActivity.java @@ -453,7 +453,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity super.onSaveInstanceState(outState); outState.putString(STATE_INSERT_AFTER_MEDIA_ITEM_ID, mInsertMediaItemAfterMediaItemId); - outState.putBoolean(STATE_PLAYING, isPreviewPlaying()); + outState.putBoolean(STATE_PLAYING, isPreviewPlaying() || mRestartPreview); outState.putParcelable(STATE_CAPTURE_URI, mCaptureMediaUri); outState.putInt(STATE_SELECTED_POS_ID, mMediaLayout.getSelectedViewPos()); } @@ -1874,7 +1874,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity // This exception may occur when trying to play frames // at the end of the timeline // (e.g. when fromMs == clip duration) - logd("Cannot start preview at: " + fromMs + "\n" + ex); + Log.w(TAG, "Cannot start preview at: " + fromMs + "\n" + ex); mMainHandler.post(new Runnable() { @Override @@ -1939,12 +1939,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity mMainHandler.postDelayed(new Runnable() { @Override public void run() { - if (isFinishing() || isChangingConfigurations()) { - // The activity is shutting down. Force stopping now. - logd("stopPreviewPlayback: Activity is shutting down"); - mPreviewState = PREVIEW_STATE_STARTED; - previewStopped(true); - } else if (mPreviewState == PREVIEW_STATE_STARTED) { + if (mPreviewState == PREVIEW_STATE_STARTED) { logd("stopPreviewPlayback: Now PREVIEW_STATE_STARTED"); previewStopped(false); } else if (mPreviewState == PREVIEW_STATE_STOPPING) { @@ -2062,13 +2057,7 @@ public class VideoEditorActivity extends VideoEditorBaseActivity mThreadHandler = new Handler(); // Ensure that the queued items are processed - mMainHandler.post(new Runnable() { - @Override - public void run() { - // Start processing the queue of runnables - mThreadHandler.post(mProcessQueueRunnable); - } - }); + mThreadHandler.post(mProcessQueueRunnable); // Run the loop Looper.loop(); |