Strange issue on Android mediastore and artwork

Issue #138 invalid
Akash Popat created an issue

Upon adding my tags and committing them to the audiofile I do a media scan so Android gets all the meta data I added but it never can see the new artwork I added. If I transfer the audio file to any other device the Google Music in that phone can see the image. I tried refreshing the media store by clearing all the data, re scanning again, clearing the cache and even moving the file in bytes and creating a new file but it still couldn't see the image. Apps like PowerAmp can see the image because they use their on media scanners. All other devices can see the artwork but not device I added the tag in.

Comments (13)

  1. IJabz repo owner

    This sounds like an issue with your device, if metadata added by jaudiotagger can be viewed okay outside of jaudiotagger then I dont see that there is an issue.

  2. Akash Popat reporter

    @ijabz It's not one device specific issue. The issue is either a taggging issue or a media store issue. Because all other tags are updated by the media store refresh but no the image.

  3. IJabz repo owner

    Its not a tagging issue as okay on other devices, maybe a media store issue but this is outside of this project there is no android specific code

  4. Sergey Chuprin

    I have app developed with help of the jaudiotagger and faced with such problem. To force android mediastore to fetch new artwork try to delete old artwork file from the disk. If your mp3 not corrupted, this must help.

  5. Akash Popat reporter

    @Сергей How would that refresh the artwork in the mp3 ? Could you show the snippet you used ?

  6. Sergey Chuprin

    @akashpopat,

    public static void deleteAlbumArtFile(final Context context, final int id) {
            context.getContentResolver().delete(ContentUris.withAppendedId(Uri.parse("content://media/external/audio/albumart"), (long) id), null, null);
    
  7. Akash Popat reporter

    @creati8e Thanks that's actually a great way to do it. If you don't mind could u also give the way u got the album id from the mp3. What query did u use for that ?

  8. Sergey Chuprin

    @akashpopat

    private int getAlbumId(int songId) {
            int albumId = -1;
            String[] projection = {MediaStore.Audio.Media.ALBUM_ID};
            String selection = MediaStore.Audio.Media._ID + "=?";
            String[] selectionArgs = {String.valueOf(songId)};
            Cursor cursor = mContext.getContentResolver().query(
                            MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                            projection,
                            selection,
                            selectionArgs,
                            null);
            if (cursor != null && cursor.moveToFirst()) {
                albumId = cursor.getInt(0);
                cursor.close();
            }
            return albumId;
        }
    
  9. Akash Popat reporter

    @creati8e I did this but it still didn't show the album art.

    private void deleteAlbumArtFile(File file) {
            long albumID;
    
            Cursor cursor = getContentResolver().query(
                    MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                    new String[]{MediaStore.Audio.Media.ALBUM_ID},
                    MediaStore.Audio.Media.DATA+ "=?",
                    new String[]{file.getAbsolutePath()},
                    null);
            cursor.moveToFirst();
            Log.d("hey","file data count: " +cursor.getCount());
            albumID = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
    
            Log.d("hey","deleted: " + getContentResolver().delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media.ALBUM_ID+"=?", new String[]{String.valueOf(albumID)}));
    
        }
    
  10. Sergey Chuprin

    @akashpopat show your code where you set artwork with jaudiotagger and then scan with mediaScanner. Note that some mp3 might be corrupted and android media scanner can't fetch artwork.

  11. Akash Popat reporter

    @creati8e Okay I found the problem. Android uses images per album and I didn't have the album information and thats why no image was showing. Thanks a ton ! :)

  12. Log in to comment