0

I am working upon a music player app for android. I'm trying to use Picasso (an external library) to load the album arts efficiently. But the album arts are not getting displayed. There's no error in the code and the project compiles properly but the images are not getting displayed.
To do this, I'm fetching the album art Uri from "MediaStore.Audio.AlbumColumns.ALBUM_ART". Then I use this in my list adapter's getView() method:

Picasso.with(context).load(Uri.parse(album_art_uri)).into(myImageView);

I don't know what's wrong here? Please help me figure it out.

Anjani
  • 1,533
  • 3
  • 15
  • 26
  • You can use Android Query also, its very easy to use and most fast in response. – Pratik Dasa May 24 '14 at 11:41
  • I was using Android Query earlier but it loads the image bitmaps as they are thereby consuming lots of memory and it slows down the app too. Somebody suggested me to use Picasso that's why giving it a try. Thanks for the quick reply anyway. – Anjani May 24 '14 at 11:45
  • yah but why you downloading Bitmap for android query, you can directly load image to your ImageView Anjani, its really very good responsive then Picasso that's why I am suggesting it.If you dont have example code then let me send you. – Pratik Dasa May 24 '14 at 11:47
  • actually I had been using android query as I mentioned to fetch the Uri of the album art. And then using ImageView.setImageUri(Uri) I achieved what I wanted. But this ImageView is just 60dp*60dp. And stil the method I used loads the image of, say 500*500, as it is in this imageView which is not really required. That's why I am looking for alternatives. If you are suggesting something other than what I've understood then please let me know. – Anjani May 24 '14 at 11:56

1 Answers1

3
Uri musicUri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
    Cursor musicCursor = musicResolver.query(musicUri, null, null, null,
            null);
int album_id = musicCursor.getColumnIndex(android.provider.MediaStore.Audio.Media.ALBUM_ID);    
cursor = managedQuery(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, 
                    new String[] {MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ALBUM_ART}, 
                    MediaStore.Audio.Albums._ID+ "=?", 
                    new String[] {musicCursor.getString(album_id)}, 
                    null);
            if (cursor.moveToFirst()) {
                thisAlbumArt = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ART));
            }

Then load with picasso as follows in your getView().It worked for me but it is slow

Picasso.with(mContext)
.load(Uri.parse("file://"+thisAlbumArt))
.resize(220,220)
.noFade().centerCrop()
.error(R.drawable.music)
.placeholder(R.drawable.blank_img)
.into(yourImageView);

reference link:

How can I display Album Art using MediaStore.Audio.Albums.ALBUM_ART?

Community
  • 1
  • 1
Ravi Theja
  • 3,371
  • 1
  • 22
  • 34