So, i'm using this simple lines of code:
public static boolean checkIfAudioFileIsValid(String filePath) {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
long duration;
try {
retriever.setDataSource(filePath);
duration = Long.parseLong(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
} catch (Exception e ) {
return false;
}
return duration > 1000;
}
So i'm checking if file is valid and it's duration is more than one seconds. For the most part it's working right, BUT if file is empty or it's duration is below 400ms i'm getting same contant value 1520
Is there someone expirenced this issue and found how to solve it?