Display Album Art in Android Music App
-
I'm trying to include the Album Art out of a mp3 file into my application, but it says: Call to getEmbeddedPicture failed. In my Song class I set the artwork of each song : metaDataRetriver = new MediaMetadataRetriever(); metaDataRetriver.setDataSource(path); //path = /mnt/sdcard/chan_mp3/Titel.mp3 byte[] artwork = metaDataRetriver.getEmbeddedPicture(); In my CustomAdapter I try to display the cover: // This code works perfectly fine: for each song I get artist and title textView.setText(values.get(position).getArtist() + " - " + values.get(position).getTitle()); // This code doesn't work at all byte[] artwork = values.get(position).getArtwork(); Bitmap bMap = BitmapFactory.decodeByteArray(artwork, 0, artwork.length); imageView.setImageBitmap(bMap); The question is where am I missing something? is the artwork variable not initialyzed correctly or is my request wrong? Or is there a better approach to get the Album Cover and music information?
-
Answer:
this works very well for me. Using contentResolver to retrieve album art for a given specific album name. img= (ImageView)findViewById(R.id.imageTrackView1); Context context = this; Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart"); Uri uri = ContentUris.withAppendedId(sArtworkUri, album); ContentResolver res = context.getContentResolver(); InputStream in = null; try { in = res.openInputStream(uri); final Bitmap artwork = BitmapFactory.decodeStream(in); img.setImageBitmap(artwork); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } img.setScaleType(ScaleType.FIT_XY);
Sebastian Oberste-Vorth at Stack Overflow Visit the source
Related Q & A:
- How to get the album art of mp3 file?Best solution by Stack Overflow
- How to implement app purchase in Android app?Best solution by Stack Overflow
- How to connect Android app to App engine?Best solution by groups.google.com
- Best Android Wikipedia App?Best solution by play.google.com
- How do you get the android market app on your phone?Best solution by play.google.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.