@@ -394,6 +394,39 @@ public void onClick(DialogInterface dialog, int which)
394394
395395 }
396396
397+ private ResultCallbackHandler <Boolean > _transcodeResultHandler = new ResultCallbackHandler <Boolean >()
398+ {
399+ @ Override
400+ public void onResult (Boolean result )
401+ {
402+ String message ;
403+
404+ if (result )
405+ {
406+ message = getResources ().getString (R .string .transcodeSuccess , filePath );
407+ }
408+ else
409+ {
410+ message = getResources ().getString (R .string .transcodeFailed );
411+ }
412+
413+ new AlertDialog .Builder (MainActivity .this )
414+ .setMessage (message )
415+ .setCancelable (true )
416+ .setPositiveButton (R .string .ok , new DialogInterface .OnClickListener ()
417+ {
418+ public void onClick (DialogInterface dialog , int which )
419+ {
420+ dialog .dismiss ();
421+ }
422+ })
423+ .show ();
424+
425+ videoView .seekTo (stopPosition );
426+ videoView .start ();
427+ }
428+ };
429+
397430 /**
398431 * Command for cutting video
399432 */
@@ -422,10 +455,7 @@ private void executeCutVideoCommand(int startMs, int endMs)
422455
423456 final String [] complexCommand = {"-ss" , "" + startMs / 1000 , "-y" , "-i" , yourRealPath , "-t" , "" + (endMs - startMs ) / 1000 ,"-vcodec" , "mpeg4" , "-b:v" , "2097152" , "-b:a" , "48000" , "-ac" , "2" , "-ar" , "22050" , filePath };
424457
425- Intent successIntent = new Intent (MainActivity .this , PreviewActivity .class );
426- successIntent .putExtra (FILEPATH , filePath );
427-
428- FFmpegResponseHandler handler = new FFmpegResponseHandler (this , successIntent , durationMs , progressDialog );
458+ FFmpegResponseHandler handler = new FFmpegResponseHandler (this , durationMs , progressDialog , _transcodeResultHandler );
429459 FFmpegUtil .call (complexCommand , handler );
430460
431461 stopPosition = videoView .getCurrentPosition (); //stopPosition is an int
@@ -459,10 +489,7 @@ private void executeCompressCommand()
459489 filePath = dest .getAbsolutePath ();
460490 String [] complexCommand = {"-y" , "-i" , yourRealPath , "-s" , "160x120" , "-r" , "25" , "-vcodec" , "mpeg4" , "-b:v" , "150k" , "-b:a" , "48000" , "-ac" , "2" , "-ar" , "22050" , filePath };
461491
462- Intent successIntent = new Intent (MainActivity .this , PreviewActivity .class );
463- successIntent .putExtra (FILEPATH , filePath );
464- FFmpegResponseHandler handler = new FFmpegResponseHandler (this , successIntent , durationMs , progressDialog );
465-
492+ FFmpegResponseHandler handler = new FFmpegResponseHandler (this , durationMs , progressDialog , _transcodeResultHandler );
466493 FFmpegUtil .call (complexCommand , handler );
467494
468495 stopPosition = videoView .getCurrentPosition ();
@@ -508,10 +535,7 @@ private void extractImagesVideo(int startMs, int endMs)
508535
509536 String [] complexCommand = {"-y" , "-i" , yourRealPath , "-an" , "-r" , "1" , "-ss" , "" + startMs / 1000 , "-t" , "" + (endMs - startMs ) / 1000 , dest .getAbsolutePath ()};
510537
511- Intent successIntent = new Intent (MainActivity .this , PreviewImageActivity .class );
512- successIntent .putExtra (FILEPATH , filePath );
513- FFmpegResponseHandler handler = new FFmpegResponseHandler (this , successIntent , durationMs , progressDialog );
514-
538+ FFmpegResponseHandler handler = new FFmpegResponseHandler (this , durationMs , progressDialog , _transcodeResultHandler );
515539 FFmpegUtil .call (complexCommand , handler );
516540
517541 stopPosition = videoView .getCurrentPosition (); //stopPosition is an int
@@ -544,10 +568,7 @@ private void extractAudioVideo()
544568
545569 String [] complexCommand = {"-y" , "-i" , yourRealPath , "-vn" , "-ar" , "44100" , "-ac" , "2" , "-b:a" , "256k" , "-f" , "mp3" , filePath };
546570
547- Intent successIntent = new Intent (MainActivity .this , AudioPreviewActivity .class );
548- successIntent .putExtra (FILEPATH , filePath );
549- FFmpegResponseHandler handler = new FFmpegResponseHandler (this , successIntent , durationMs , progressDialog );
550-
571+ FFmpegResponseHandler handler = new FFmpegResponseHandler (this , durationMs , progressDialog , _transcodeResultHandler );
551572 FFmpegUtil .call (complexCommand , handler );
552573
553574 stopPosition = videoView .getCurrentPosition (); //stopPosition is an int
0 commit comments