Skip to content

Commit

Permalink
Update PickerModule.java (#1494)
Browse files Browse the repository at this point in the history
Sometimes the length of the video cannot be retrieved.
  • Loading branch information
suhanmoon authored Sep 20, 2021
1 parent 540ecea commit bbd8730
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,15 @@ private Bitmap validateVideo(String path) throws Exception {
}

private static Long getVideoDuration(String path) {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(path);
try {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(path);

return Long.parseLong(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
return Long.parseLong(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
}
catch(Exception e) {
return -1L;
}
}

private void getVideo(final Activity activity, final String path, final String mime) throws Exception {
Expand Down

0 comments on commit bbd8730

Please sign in to comment.