androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide Option to read unsynced lyrics using Metadata or ID3Tags

pawaom opened this issue · comments

Replace the content in the sections below.

[REQUIRED] Use case description

Provide Option to read unsynced lyrics using Metadata or ID3Tags

Currently I Am trying to read unsynced lyrics

Using the below code

override fun onTracksChanged(tracks: Tracks) {
                    //https://github.com/androidx/media/issues/922
                    //https://github.com/androidx/media/issues/1305
                    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 CommentFrame) {
                                            println("${it.id} ${it.text}") // COMM <value>
                                        }
                                        if (it is BinaryFrame) {
                                            Log.e(
                                                "Metadata",
                                                "id3 BinaryFrame key: " + it.id + " data: " + it.data.size
                                            )
                                            if ("USLT".equals(
                                                    it.id,
                                                    ignoreCase = true
                                                )
                                            ) {
                                                Log.e(
                                                    "Metadata",
                                                    "id3 UNSYNCEDLYRICS onTracksChanged: " + String(
                                                        it.data
                                                    )
                                                )
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }


                }

This code is able to read synced Lyrics like below

Screenshot 2024-06-09 142733

How ever when we try to read unsynced Lyrics it is not able to read them like below

Screenshot 2024-06-09 142814

Proposed solution

It would be better if we are able to read it as metadata using

override fun onMediaMetadataChanged(mediaMetadata: MediaMetadata) {
                   super.onMediaMetadataChanged(mediaMetadata)
                   mediaMetadata.title?.let( { println(it) } )

               }

Which provides various options like Title, composer , Artist , Album etc

Alternatives considered

there are options to use Third party alternativos like .

jaudiotagger

Or mp3agic

How ever they can be unreliable and an inbuilt solution will be helpful.

This looks like a duplicate of #922