Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] provide access to all metadata #2008

Closed
heaversm opened this issue May 5, 2023 · 4 comments
Closed

[Feature Request] provide access to all metadata #2008

heaversm opened this issue May 5, 2023 · 4 comments

Comments

@heaversm
Copy link

heaversm commented May 5, 2023

What is the need and use case of this feature?

Access to the metadata of an MP3 file is currently limited to source, title, url, artist, album, date, genre. Why not just return the metadata object so users can access any metadata attribute they want? There are a lot of more progressive metadata tags available (see https://podcastnamespace.org/), including, as one other issue suggests, the incorporation of chapters, but also some potentially ground breaking abilities to rework the ability to detect how much of an mp3 file has been listened to, for things like podcasts (see https://rad.npr.org/). These would require a much more open-ended approach to accessing metadata. As it stands right now, the implementation in the track player requires you to spread the object keys of PlaybackMetadataReceived, e.g.

Event.PlaybackMetadataReceived,
    async ({title, artist, source}) => {
      //currently available: source, title, url, artist, album, date, genre
      console.log('source', source); //id3
      ...
    },

Describe the ideal solution
Would be happy to implement and PR, but I'm not an expert with native apps and modifying node modules, but essentially it'd be going into something like going into Metadata.swift (and wherever else is required in the track-player library) and, rather than:

static func update(for player: AudioPlayer, with metadata: [String: Any]) {
        
        if let title = metadata["title"] as? String {
            ret.append(MediaItemProperty.title(title))
        }
        
        if let artist = metadata["artist"] as? String {
            ret.append(MediaItemProperty.artist(artist))
        }
}

saying:



static func update(for player: AudioPlayer, with metadata: [String: Any]) {
        ret.append(MediaItemProperty.metadata(metadata))
}

or providing some method in the library to request a specific metadata property from the client side, , e.g. TrackPlayer.requestMetadataItem('chapters')

How I can Help
Let me know which files would need to be modified in order to make this happen. Have tried modifying the places where this metadata shows up in my react-native-track-player node_modules folder:

  • Utils/Metadata.swift
  • model/Track.swift
  • model/TrackAudioItem.kt

but I can't get it to compile with my modifications. Are there other files? Or is the implementation I'm trying wrong?

Also, not sure what build commands need to be run in order to incorporate changes to a node module either...e.g. npx react-native run-ios --reset-cache? Or are there other steps that need to be run to essentially recompile and process the changes made to a node module in order to test? Thanks for your help!

Can you assist by working on this feature and creating a Pull Request? Yes! Happy to (With help)

@jspizziri
Copy link
Collaborator

@heaversm you and I had a conversation about this on Discord. It seems like your work on this might've stalled out.

I'm going to close this feature request for now, however if you're still interested let me know and I can reopen.

@mrazzari
Copy link

@jspizziri Please reopen 🙏 Here's another usecase: Adswizz inserts metadata related to image ads, so they can be displayed in sync with an audio stream. Example:

{
  "metadata-list": [
    {
      "start": "0",
      "metadata": "adswizzContext=aQd9MSFsQjFefAA6NzL4MTcddTxaMDIyYTc%3D adw_ad=true durationMilliseconds=11331 adId=151460 insertionType=preroll"
    },
    {
      "start": "11331",
      "metadata": "title=\"Tears Run Dry by Abraham Alexander now playing\""
    }
  ]
}

Generally speaking it makes a lot of sense to be more open about unforeseen metadata use cases.

@jspizziri
Copy link
Collaborator

@mrazzari All feature requests that aren't actively being worked on by either the core team or a community member remain closed until someone volunteers to contribute. This prevents noise in the issue tracker. If you want to work on it I'm happy to repopen.

@dcvz
Copy link
Contributor

dcvz commented Sep 26, 2023

This was addressed with #2118 - details can be seen in the PR's description!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants