Search code examples
androidandroid-mediaplayerandroid-alarmsandroid-cursorandroid-music-player

How to display the album art for a particular song?


I'm creating a music player and now I am stuck on displaying the album art for particular songs.

Please help me.


Solution

  • Use this code to get the album art for particular song.

    ContentResolver res = getContentResolver();
                Uri smusicUri = android.provider.MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI;
                Cursor music =res.query(smusicUri,null,null, null, null);
    
                music.moveToFirst();
                int x=music.getColumnIndex(android.provider.MediaStore.Audio.Albums.ALBUM_ART);
                    String albumArt = music.getString(x);
                Bitmap bm= BitmapFactory.decodeFile(albumArt);
                    ImageView image=(ImageView)findViewById(R.id.IValbumArt);