catch all RuntimeExceptions when using MetadataRetriever
This commit is contained in:
parent
a6d1559755
commit
7e93f4519a
|
@ -485,7 +485,7 @@ public class FileBackend {
|
||||||
frame = metadataRetriever.getFrameAtTime(0);
|
frame = metadataRetriever.getFrameAtTime(0);
|
||||||
metadataRetriever.release();
|
metadataRetriever.release();
|
||||||
frame = resize(frame, size);
|
frame = resize(frame, size);
|
||||||
} catch(IllegalArgumentException | NullPointerException e) {
|
} catch(RuntimeException e) {
|
||||||
frame = Bitmap.createBitmap(size,size, Bitmap.Config.ARGB_8888);
|
frame = Bitmap.createBitmap(size,size, Bitmap.Config.ARGB_8888);
|
||||||
frame.eraseColor(0xff000000);
|
frame.eraseColor(0xff000000);
|
||||||
}
|
}
|
||||||
|
@ -819,7 +819,7 @@ public class FileBackend {
|
||||||
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
||||||
mediaMetadataRetriever.setDataSource(file.toString());
|
mediaMetadataRetriever.setDataSource(file.toString());
|
||||||
return Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
|
return Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (RuntimeException e) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -839,7 +839,7 @@ public class FileBackend {
|
||||||
MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
|
MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
|
||||||
try {
|
try {
|
||||||
metadataRetriever.setDataSource(file.getAbsolutePath());
|
metadataRetriever.setDataSource(file.getAbsolutePath());
|
||||||
} catch (Exception e) {
|
} catch (RuntimeException e) {
|
||||||
throw new NotAVideoFile(e);
|
throw new NotAVideoFile(e);
|
||||||
}
|
}
|
||||||
return getVideoDimensions(metadataRetriever);
|
return getVideoDimensions(metadataRetriever);
|
||||||
|
@ -847,7 +847,11 @@ public class FileBackend {
|
||||||
|
|
||||||
private static Dimensions getVideoDimensions(Context context, Uri uri) throws NotAVideoFile {
|
private static Dimensions getVideoDimensions(Context context, Uri uri) throws NotAVideoFile {
|
||||||
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
||||||
|
try {
|
||||||
mediaMetadataRetriever.setDataSource(context, uri);
|
mediaMetadataRetriever.setDataSource(context, uri);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
throw new NotAVideoFile(e);
|
||||||
|
}
|
||||||
return getVideoDimensions(mediaMetadataRetriever);
|
return getVideoDimensions(mediaMetadataRetriever);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue