mirror of
https://github.com/status-im/react-native-cameraroll.git
synced 2025-01-27 09:55:50 +00:00
Handling exceptions in video player
Reviewed By: furdei Differential Revision: D5958119 fbshipit-source-id: 79b431a8422d60134890d44e99c358a07a5adc5b
This commit is contained in:
parent
97869e22d7
commit
bef0b637c3
@ -420,6 +420,7 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
|
||||
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
||||
retriever.setDataSource(photoDescriptor.getFileDescriptor());
|
||||
|
||||
try {
|
||||
if (width <= 0 || height <= 0) {
|
||||
width =
|
||||
Integer.parseInt(
|
||||
@ -433,8 +434,17 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
|
||||
retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
|
||||
int playableDuration = timeInMillisec / 1000;
|
||||
image.putInt("playableDuration", playableDuration);
|
||||
} catch (NumberFormatException e) {
|
||||
FLog.e(
|
||||
ReactConstants.TAG,
|
||||
"Number format exception occurred while trying to fetch video metadata for "
|
||||
+ photoUri.toString(),
|
||||
e);
|
||||
return false;
|
||||
} finally {
|
||||
retriever.release();
|
||||
photoDescriptor.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
FLog.e(ReactConstants.TAG, "Could not get video metadata for " + photoUri.toString(), e);
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user