catch all RuntimeExceptions when using MetadataRetriever

This commit is contained in:
Daniel Gultsch 2017-11-12 19:20:35 +01:00
parent a6d1559755
commit 7e93f4519a

View file

@ -485,7 +485,7 @@ public class FileBackend {
frame = metadataRetriever.getFrameAtTime(0);
metadataRetriever.release();
frame = resize(frame, size);
} catch(IllegalArgumentException | NullPointerException e) {
} catch(RuntimeException e) {
frame = Bitmap.createBitmap(size,size, Bitmap.Config.ARGB_8888);
frame.eraseColor(0xff000000);
}
@ -819,7 +819,7 @@ public class FileBackend {
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.setDataSource(file.toString());
return Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
} catch (IllegalArgumentException e) {
} catch (RuntimeException e) {
return 0;
}
}
@ -839,7 +839,7 @@ public class FileBackend {
MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
try {
metadataRetriever.setDataSource(file.getAbsolutePath());
} catch (Exception e) {
} catch (RuntimeException e) {
throw new NotAVideoFile(e);
}
return getVideoDimensions(metadataRetriever);
@ -847,7 +847,11 @@ public class FileBackend {
private static Dimensions getVideoDimensions(Context context, Uri uri) throws NotAVideoFile {
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
try {
mediaMetadataRetriever.setDataSource(context, uri);
} catch (RuntimeException e) {
throw new NotAVideoFile(e);
}
return getVideoDimensions(mediaMetadataRetriever);
}