@@ -304,6 +304,8 @@ private void handleEncodeIntent(Intent intent)
304
304
int tmpAudioBitrateK = intent .getIntExtra ("audioBitrateK" , -1 );
305
305
final Integer audioBitrateK = tmpAudioBitrateK != -1 ? tmpAudioBitrateK : null ;
306
306
307
+ boolean skipDialog = intent .getBooleanExtra ("skipDialog" , false );
308
+
307
309
List <Triplet <Object , Integer , String >> nullChecks = new LinkedList <>();
308
310
nullChecks .add (new Triplet <>((Object )inputFilePath , R .string .fieldMissingError , "inputFilePath" ));
309
311
nullChecks .add (new Triplet <>((Object )destinationFilePath , R .string .fieldMissingError , "outputFilePath" ));
@@ -338,6 +340,32 @@ private void handleEncodeIntent(Intent intent)
338
340
339
341
String message = String .format (getString (R .string .encodeStartConfirmation ), inputFilePath , destinationFilePath );
340
342
343
+ DialogInterface .OnClickListener positiveButtonListener = new DialogInterface .OnClickListener ()
344
+ {
345
+ public void onClick (final DialogInterface dialog , int which )
346
+ {
347
+ FFmpegUtil .getMediaDetails (new File (inputFilePath ), new ResultCallbackHandler <MediaInfo >()
348
+ {
349
+ @ Override
350
+ public void onResult (MediaInfo result )
351
+ {
352
+ if (result != null )
353
+ {
354
+ startEncode (inputFilePath , 0 , (int )(result .durationMs /1000 ), container , videoCodec , videoBitrateK ,
355
+ resolution , fps , audioCodec , audioSampleRate , audioChannel , audioBitrateK , destinationFilePath );
356
+ }
357
+ else
358
+ {
359
+ String message = String .format (getString (R .string .transcodeFailed ), getString (R .string .couldNotFindFileSubmsg ));
360
+ Toast .makeText (MainActivity .this , message , Toast .LENGTH_LONG ).show ();
361
+ finish ();
362
+ dialog .dismiss ();
363
+ }
364
+ }
365
+ });
366
+ }
367
+ };
368
+
341
369
AlertDialog dialog = new AlertDialog .Builder (this )
342
370
.setMessage (message )
343
371
.setCancelable (false )
@@ -350,33 +378,15 @@ public void onClick(DialogInterface dialog, int which)
350
378
dialog .dismiss ();
351
379
}
352
380
})
353
- .setPositiveButton (R .string .encode , new DialogInterface .OnClickListener ()
354
- {
355
- public void onClick (final DialogInterface dialog , int which )
356
- {
357
- FFmpegUtil .getMediaDetails (new File (inputFilePath ), new ResultCallbackHandler <MediaInfo >()
358
- {
359
- @ Override
360
- public void onResult (MediaInfo result )
361
- {
362
- if (result != null )
363
- {
364
- startEncode (inputFilePath , 0 , (int )(result .durationMs /1000 ), container , videoCodec , videoBitrateK ,
365
- resolution , fps , audioCodec , audioSampleRate , audioChannel , audioBitrateK , destinationFilePath );
366
- }
367
- else
368
- {
369
- String message = String .format (getString (R .string .transcodeFailed ), getString (R .string .couldNotFindFileSubmsg ));
370
- Toast .makeText (MainActivity .this , message , Toast .LENGTH_LONG ).show ();
371
- finish ();
372
- dialog .dismiss ();
373
- }
374
- }
375
- });
376
- }
377
- }).create ();
381
+ .setPositiveButton (R .string .encode , positiveButtonListener ).create ();
378
382
379
383
dialog .show ();
384
+
385
+ if (skipDialog )
386
+ {
387
+ positiveButtonListener .onClick (dialog , 0 );
388
+ dialog .dismiss ();
389
+ }
380
390
}
381
391
382
392
private void showUnsupportedExceptionDialog ()
@@ -1278,6 +1288,16 @@ private void showEncodeCompleteDialog(final MainActivity mainActivity, final boo
1278
1288
{
1279
1289
Log .d (TAG , "Encode result: " + result );
1280
1290
1291
+ Intent intent = mainActivity .getIntent ();
1292
+ final String action = intent .getAction ();
1293
+ boolean skipDialog = intent .getBooleanExtra ("skipDialog" , false );
1294
+
1295
+ if (skipDialog )
1296
+ {
1297
+ mainActivity .finish ();
1298
+ return ;
1299
+ }
1300
+
1281
1301
String message ;
1282
1302
1283
1303
if (result )
0 commit comments