I have an app which allows user to import media (videos, photos, audio) which will then be managed by the application (as evidence). I've found that some audio recording apps will save audio in .3gp format (specifically Whats App messenger). If i get the mime type using the following code:
MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
it will come back as video/3gp which my app takes to mean it is of the type "video" and tries to make thumbnails and what not (I use the first part of the mime type to determine what type my app categorizes it as). However it is audio so certain things I expect to work will not work (such as creating a thumbnail for the video). Are there any libraries or anything available by android which would allow me to tell if the file is a video audio only? I suppose I can try to make a thumbnail and if that fails assume the file is audio, but that's a bit of a stretch given a number of other problems could go wrong in making a thumbnail. Any ideas?
METADATA_KEY_HAS_VIDEO
I figured out a way to do this:
So to figure out if a media file has video you can use this.. Probably not the most efficient way to do it but for something done rarely in your application it seems like a reasonable solution.
I have tested Alessandro Roaro's solution and it works for me. I use it currently in my app.
I quote:
I have not tested this solution, but you could try to get a thumbnail for the video.
If the
thumbnail
isnull
then it's audio, otherwise it's video.