Skip to content

MediaMetadata doesn't include some ID3 tags #1305

Closed

Description

@akshdeep-singh

Version

Media3 1.3.1

More version details

No response

Devices that reproduce the issue

Pixel 3a Emulator API 34

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

  1. Play any mp3 file which contains id3 tags with ids TCON, COMM, etc.
  2. Check values in onMediaMetadataChanged and onTracksChanged
override fun onTracksChanged(tracks: Tracks) {
    tracks.groups.forEach { group ->
        for (i in 0 until group.length) {
            group.mediaTrackGroup.getFormat(i).metadata?.let { metadata ->
                for (j in 0 until metadata.length()) {
                    metadata.get(j).let {
                        if (it is TextInformationFrame) {
                            println("${it.id} ${it.values}") // TCON [<value>]
                        }

                        if (it is CommentFrame) {
                            println("${it.id} ${it.text}") // COMM <value>
                        }
                    }
                }
            }
        }
    }
}

override fun onMediaMetadataChanged(mediaMetadata: MediaMetadata) {
    println("genre: ${mediaMetadata.genre}") // null
    println("description: ${mediaMetadata.description}") // null
}

Expected result

Value of MediaMetadata.genre is filled with TCON frame content
Value of MediaMetadata.description is filled with COMM frame content

Actual result

MediaMetadata values described above are null

Media

Sample MP3 link

Bug Report

Activity

  1. icbaker commented on Apr 23, 2024

    @icbaker
    Collaborator

    Please can you try listening to Player.Listener.onMetadata? That's where I would expect this to be emitted, as described here: https://developer.android.com/media/media3/exoplayer/retrieving-metadata#during-playback

  2. akshdeep-singh commented on Apr 23, 2024

    @akshdeep-singh
    Author

    onMetadata isn't getting called for me, also I would prefer MediaMetadata as I am also filling some custom info when building MediaItem, with onTracksChanged I am reading bitrate information.

  3. icbaker commented on Apr 23, 2024

    @icbaker
    Collaborator

    I played the provided link in the demo app and I see COMM and TCOM logged as part of the metadata in onTracksChanged (this logging is part of EventLogger, see https://developer.android.com/media/media3/exoplayer/debug-logging):

    tracks [eventTime=1.27, mediaPos=0.00, window=0, period=0
      group [
        [X] Track:0, id=null, mimeType=audio/mpeg, bitrate=128000, channels=2, sample_rate=44100, supported=YES
      ]
      Metadata [
        COMM: language=xxx, description=
        TCOM: description=null: values=[SikhSangeet.com]
        TCON: description=null: values=[Shabad Kirtan]
        TCOP: description=null: values=[SikhSangeet.com]
        TENC: description=null: values=[SikhSangeet.com]
        WXXX: url=http://SikhSangeet.com
        TALB: description=null: values=[Teri Bhagat Na Chhodon]
        TIT2: description=null: values=[Nindo Nindo Mauko]
        TOPE: description=null: values=[Harjinder Singh (Sri Nagar Wale)]
        TPE1: description=null: values=[Harjinder Singh (Sri Nagar Wale)]
        TRCK: description=null: values=[01]
      ]
    ]
    
  4. akshdeep-singh commented on Apr 23, 2024

    @akshdeep-singh
    Author

    yes, onTracksChanged gets called but onMetadata doesn't, but my actual point of reporting this issue was that information such as "genre" is very basic which should be filled in MediaMetadata, right?

  5. icbaker commented on Apr 24, 2024

    @icbaker
    Collaborator

    Ah gotcha, I misunderstood your original comment.

    Value of MediaMetadata.genre is filled with TCON frame content

    This makes sense, based on my reading of the definition of the TCON frame here, though we probably don't want to naively popoulate the string directly and instead optionally do the numeric resolution described there, and somewhat already implemented here (although there may be an off-by-one bug there, I'm going to dig a bit further):

    private static TextInformationFrame parseStandardGenreAttribute(ParsableByteArray data) {
    int genreCode = parseUint8AttributeValue(data);
    @Nullable
    String genreString =
    (0 < genreCode && genreCode <= STANDARD_GENRES.length)
    ? STANDARD_GENRES[genreCode - 1]
    : null;
    if (genreString != null) {
    return new TextInformationFrame(
    "TCON", /* description= */ null, ImmutableList.of(genreString));
    }
    Log.w(TAG, "Failed to parse standard genre code");
    return null;
    }


    Value of MediaMetadata.description is filled with COMM frame content

    I'm not sure sure about this. COMM is described in a very free-form way, in particular there might be more than one, so I don't think it maps very clearly to MediaMetadata.description. I'm not sure that any of these ID3 frame types really contain a 'description'.


    I'll prepare a change to map TCON to MediaMetadata.genre.

  6. icbaker commented on Apr 30, 2024

    @icbaker
    Collaborator

    This is now implemented by the commits referenced above.

  7. locked and limited conversation to collaborators on Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions