Skip to content

Instantly share code, notes, and snippets.

@yccheok
Created July 3, 2019 07:14
Show Gist options
  • Select an option

  • Save yccheok/b45a62ea77b4f7310b6a868dbe25eb66 to your computer and use it in GitHub Desktop.

Select an option

Save yccheok/b45a62ea77b4f7310b6a868dbe25eb66 to your computer and use it in GitHub Desktop.
Uri uri = Uri.fromFile(destination);
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(WeNoteApplication.instance(), uri);
String durationStr = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
long length = 0L;
try {
length = Long.parseLong(durationStr);
} catch (NumberFormatException e) {
Log.e(TAG, "", e);
}
if (length <= 0L) {
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment