Skip to content

Instantly share code, notes, and snippets.

@mohanrajsambath
Last active October 21, 2020 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohanrajsambath/3100d8efde3d8bbe41ee8848d3593bec to your computer and use it in GitHub Desktop.
Save mohanrajsambath/3100d8efde3d8bbe41ee8848d3593bec to your computer and use it in GitHub Desktop.
MediaMetadataReteriver in Android api-30 returns null
private void getMediaDuration(String filePathforPlayback){
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
try {
retriever.setDataSource(getActivityContext, Uri.fromFile(new File(filePathforPlayback)));
String fileDuration = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
Log.i("MyActivity", "fileDuration---=>" + fileDuration);
retriever.release();
}catch (Exception ex){ex.printStackTrace();}finally {
retriever=null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment