diff options
Diffstat (limited to 'src/com/android/gallery3d/app/TrimVideo.java')
-rw-r--r-- | src/com/android/gallery3d/app/TrimVideo.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/app/TrimVideo.java b/src/com/android/gallery3d/app/TrimVideo.java index b0ed8e635..a52c25606 100644 --- a/src/com/android/gallery3d/app/TrimVideo.java +++ b/src/com/android/gallery3d/app/TrimVideo.java @@ -57,6 +57,7 @@ public class TrimVideo extends Activity implements private int mTrimStartTime = 0; private int mTrimEndTime = 0; + private boolean mCheckTrimStartTime; private int mVideoPosition = 0; public static final String KEY_TRIM_START = "trim_start"; public static final String KEY_TRIM_END = "trim_end"; @@ -177,10 +178,11 @@ public class TrimVideo extends Activity implements mVideoPosition = mVideoView.getCurrentPosition(); // If the video position is smaller than the starting point of trimming, // correct it. - if (mVideoPosition < mTrimStartTime) { + if (mCheckTrimStartTime && (mVideoPosition < mTrimStartTime)) { mVideoView.seekTo(mTrimStartTime); mVideoPosition = mTrimStartTime; } + mCheckTrimStartTime = false; // If the position is bigger than the end point of trimming, show the // replay button and pause. if (mVideoPosition >= mTrimEndTime && mTrimEndTime > 0) { @@ -204,6 +206,7 @@ public class TrimVideo extends Activity implements private void playVideo() { mVideoView.start(); + mCheckTrimStartTime = true; mController.showPlaying(); setProgress(); } @@ -237,6 +240,7 @@ public class TrimVideo extends Activity implements new Thread(new Runnable() { @Override public void run() { + boolean hasError = false; try { VideoUtils.startTrim(mSrcFile, mDstFileInfo.mFile, mTrimStartTime, mTrimEndTime); @@ -244,7 +248,28 @@ public class TrimVideo extends Activity implements SaveVideoFileUtils.insertContent(mDstFileInfo, getContentResolver(), mUri); } catch (IOException e) { + hasError = true; e.printStackTrace(); + } catch (IllegalStateException e) { + hasError = true; + e.printStackTrace(); + } + //If the exception happens,just notify the UI and avoid the crash. + if (hasError){ + mHandler.post(new Runnable(){ + @Override + public void run(){ + Toast.makeText(getApplicationContext(), + getString(R.string.fail_trim), + Toast.LENGTH_SHORT) + .show(); + if (mProgress != null) { + mProgress.dismiss(); + mProgress = null; + } + } + }); + return; } // After trimming is done, trigger the UI changed. mHandler.post(new Runnable() { @@ -320,6 +345,12 @@ public class TrimVideo extends Activity implements } @Override + public boolean onIsRTSP() { + // TODO Auto-generated method stub + return false; + } + + @Override public void onReplay() { mVideoView.seekTo(mTrimStartTime); playVideo(); |