tags:

views:

1004

answers:

4

Hi all, I am developing a sort of media player for android. The question is how can i get the cover art of audio file on android. For example the default android media player shows album covers when listing albums, how can i get this artworks.

A: 

Android only recognizes files named "AlbumArt.jpg" as Album Covers. Just put the pictures with that name in the album folder and you'll be fine..

Nick
Sorry maybe the question was little confusing. I am developing an application and i want to get the album art from my application.
Mojo Risin
+1  A: 

I don't know if you read that google is making Stackoverflow the official Android app development Q&A medium but for beginner questions... Now, I know nothing about developing in andriod, but a quick search of the Android Developers site, I found this:

MediaStore.Audio.AlbumColumns

Hopefully it'll help.

fudgey
Yes i also notice that there is MediaStore.Audio.AudioColumns.ALBUM_ART but it doesn't exist actually.ContentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,null, null, null, null); - returns cursor with all columns and ALBUM_ART is not there.
Mojo Risin
There are only ALBUM,ALBUM_ID,ALBUM_KEY columns in the cursor but no ALBUM_ART
Mojo Risin
+1  A: 

Based on your comments to others, it seems like your question is less about Android and more about how to get album art in general. Perhaps this article on retrieving album art from Amazon will be helpful. Once you have a local copy and store it as Nick has suggested, I believe you should be able to retrieve it the way Fudgey suggested.

Tim Kryger
No i don't want to get the album art in general. There is optional filed in ID3v2 tags for cover art. Android is parsing most of the ID3v2 field and the question is how to get the embedded covert art in ID3v2 tag not using amazon or some other web services
Mojo Risin
Maybe the question is little confusing, maybe the correct one will be extracting "Attached picture" from ID3v2 tag on android. http://www.id3.org/id3v2.3.0 for more info about attached picture
Mojo Risin
+4  A: 
Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
Uri uri = ContentUris.withAppendedId(sArtworkUri, album_id);
ContentResolver res = context.getContentResolver();
InputStream in = res.openInputStream(uri);
Bitmap artwork = BitmapFactory.decodeStream(in);

More complete sample code can be found in Android Music player source here http://www.google.com/codesearch/p?hl=en#kYM2IxnT114/src/com/android/music/MusicUtils.java&q=getArtwork&exact_package=git://android.git.kernel.org/platform/packages/apps/Music.git&sa=N&cd=1&ct=rc&l=25 method getArtwork.

Fedor