I have a extension-less file, named for the sake of this post MyAudioFile
, I know that this audio file's extension is aac
format(I have analysed it with a program named GSpot
), but since the file doesn't have any extension, I am unable to use any of the methods available in Android for determining MIME
type of that file.
Is there any inbuilt utility method in Android
that I am unaware of and which lets me read the header information of an audio file and spit out the extension or the MIME
type of the file?
I have already tried MediaMetaDataRetriever
and MimeTypeMap
unsuccessfully, did I miss any other class which can be used here?
Is it possible using any other external libraries excluding SOX
and FFMPeg
?
I'm not sure I understand what the problem is here. MediaMetaDataRetriever
is the class to use to determine the metadata (including MIME type) of an arbitrary media file. Are you perhaps using it wrong?
MediaMetaDataRetriever retriever = new MediaMetaDataRetriever();
retriever.setDataSource("file:///sdcard/fileThatIsAACButDoesntHaveExtension");
String mimeType = retriever.extractMetadata(MediaMetaDataRetriever.METADATA_KEY_MIMETYPE);
How exactly are you trying to use this file? You shouldn't need its MIME type to use it (and you admittedly already know its MIME type - audio/mp4
)