I'm trying to get the album art of a MP3 file. I thought the best and cleanest way to do this is use the MediaMetadataRetriever class. But for some reason calling the getEmbeddedPicture method doesn't work. The image isn't showing, LogCat shows an error:
04-29 18:36:19.520: E/MediaMetadataRetrieverJNI(25661): getEmbeddedPicture: Call to getEmbeddedPicture failed.
This is the code that doesn't seem to work:
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
MediaMetadataRetriever mmdr = new MediaMetadataRetriever();
mmdr.setDataSource(path); //path of the MP3 file on SD Card
bites = mmdr.getEmbeddedPicture();
if(bites != null)
artBM = BitmapFactory.decodeByteArray(bites, 0, bites.length);
return null;
}
I'm running it on a device with Android 4.2, so there shouldn't be any issue with the MediaMetadataRetriever(requires api lvl 10). The files I tested show an image in Windows explorer, so there seems to be art embedded. Anyone have any thoughts on this?