Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract album cover from mp3 file in android

Tags:

android

mp3

Hello Everyone , In my media player i need to display the album cover(i dont know how it pronounced actually..I hope right) of the song. I knew for that i have to extract the image from the song itself but how? m wondering. So any help, if possible with some sorts of code. Thanks.

like image 405
Jai Android Avatar asked Apr 18 '12 12:04

Jai Android


People also ask

How do I get album artwork on my Android?

Install Album Art Grabber from the Play Store. It's a free app that scans music websites for album artwork. To install the app, open the Play Store (the multicolored triangle icon in the app drawer), then search for album art grabber .

How do I put MP3 album art on my Android?

Add Album Art to MP3 on Android Smartphone You will see the list of songs on your device, choose any song to which you want to add album art. You can tap on “Auto Search” for automatic searching of album art on the basis of the Name of song, album, and artist. Choose and add the image.


1 Answers

for api 10 and above

android.media.MediaMetadataRetriever mmr = new MediaMetadataRetriever();
        mmr.setDataSource(songsList.get(songIndex).get("songPath"));

        byte [] data = mmr.getEmbeddedPicture();
               //coverart is an Imageview object

        // convert the byte array to a bitmap
        if(data != null)
        {
            Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
            coverart.setImageBitmap(bitmap); //associated cover art in bitmap
        }
        else
        {
            coverart.setImageResource(R.drawable.fallback_cover); //any default cover resourse folder
        }

            coverart.setAdjustViewBounds(true);
            coverart.setLayoutParams(new LinearLayout.LayoutParams(500, 500));
like image 144
Nikhil Goswami Avatar answered Nov 09 '22 13:11

Nikhil Goswami