¿Cómo mostrar el arte del álbum?

Quiero saber cómo mostrar la carátula de los álbumes usando android.provider.MediaStore.Audio.Albums.ALBUM.Album_Art .

Estoy extrayendo metadatos de la ruta usando el siguiente código que funciona bien para las canciones, pero no sé cómo mostrar la carátula de los álbumes / artistas en general.

 MediaMetadataRetriever mmr = new MediaMetadataRetriever(); byte[] rawArt = null; float ht_px = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 200, getResources().getDisplayMetrics()); float wt_px = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 200, getResources().getDisplayMetrics()); BitmapFactory.Options bfo=new BitmapFactory.Options(); try { mmr.setDataSource(songdetails.get(swapnumber).Path); StackBlurManager _stackBlurManager; rawArt = mmr.getEmbeddedPicture(); if ( rawArt != null) { bitmap2 = BitmapFactory.decodeByteArray(rawArt, 0, rawArt.length, bfo); bitmap3 = Bitmap.createScaledBitmap(bitmap2, (int) ht_px, (int) wt_px, true); //... 

En primer lugar, recomendaría echar un vistazo a:

  • Base de datos SQLite de Android y proveedor de contenido
  • Cargadores y gestor de cargador de fondo

Este fragmento de código puede ayudarle a ir en la dirección correcta.

 // Query URI Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; // Columns String[] select = { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.ALBUM_ID, MediaStore.Audio.Media.DURATION }; // Where String where = MediaStore.Audio.Media.IS_MUSIC + "=1"; // Perform the query Cursor cursor = context.getContentResolver().query(uri, cursor_cols, where, null, null); if (cursor.moveToFirst()) { while (!cursor.isAfterLast()) { long albumId = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID)); String artist = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST)); String album = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM)); String track = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE)); String data = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA)); int duration = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION)); final Uri ART_CONTENT_URI = Uri.parse("content://media/external/audio/albumart"); Uri albumArtUri = ContentUris.withAppendedId(ART_CONTENT_URI, albumId); Bitmap bitmap = null; try { bitmap = MediaStore.Images.Media.getBitmap(context.getContentResolver(), albumArtUri); } catch (Exception exception) { // log error } cursor.moveToNext(); } } 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.