androidx / androidx/media

Add support for ID3 USLT unsynced lyrics tag

Open
#922 2 comments 0 reactions 1 assignee View on GitHub

@icbaker is already working on this.

Since Dec 29, 2023.

enhancement low priority
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Hey, when I read the tag in the audio with MetadataRetriever, it works well in FLAC, but it cannot read the contents of the UNSYNCEDLYRICS tag in MP3, it is classified into BinaryFrame and cannot parse the data inside. Does it have no support for this?

The following is example code and sample file:

  private static class DirectExecutor implements Executor {
    public void execute(Runnable r) {
      r.run();
    }
  }
  public static void getMetadata(Context context, String uri) {
    ListenableFuture<TrackGroupArray> trackGroupsFuture = MetadataRetriever.retrieveMetadata(context, MediaItem.fromUri(uri));
    Futures.addCallback(trackGroupsFuture, new FutureCallback<>() {
      @Override
      public void onSuccess(TrackGroupArray trackGroups) {
        Log.d("Metadata", "trackGroups length: " + trackGroups.length);
        for (int i = 0; i < trackGroups.length; i++) {
          Log.d("Metadata", "index: " + i + " format length: " + trackGroups.get(i).length);
          Metadata metadata = trackGroups.get(i).getFormat(0).metadata;
          if (metadata == null) continue;
          Log.d("Metadata", "index: " + i + " metadata length: " + metadata.length());
          for(int i2 = 0; i2 < metadata.length(); i2++) {
            Metadata.Entry entry = metadata.get(i2);
            if ((entry instanceof ApicFrame pic)) {
              Log.d("Metadata", "id3 ApicFrame pictureType: " + pic.pictureType + " pictureData: " + pic.pictureData.length);
            } else if (entry instanceof TextInformationFrame id3) {
              Log.d("Metadata", "id3 TextInformationFrame key: " + id3.id.toUpperCase() + " value: " + id3.values.get(0));
            } else if (entry instanceof BinaryFrame binaryFrame) {
              Log.d("Metadata", "id3 BinaryFrame key: " + binaryFrame.id + " data: " + binaryFrame.data.length);
              if ("USLT".equalsIgnoreCase(binaryFrame.id)) Log.d("Metadata", "id3 UNSYNCEDLYRICS: " + new String(binaryFrame.data, StandardCharsets.UTF_8));
            }
          }
        }
      }
      @Override
      public void onFailure(@NonNull Throwable t) {
        Log.d("Metadata", "error: " + t);
      }
    }, new DirectExecutor());
  }

test-audio.zip

Output log:

image
pic2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.