doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.2k stars 984 forks source link

Issues with the new metadata events in combination with useTrackPlayerEvents #2147

Closed puckey closed 9 months ago

puckey commented 9 months ago

Until now all emitted events have been plain javascript objects. The new MetaData*Received events all are emitted as arrays. This causes issues with the useTrackPlayerEvents hook, since it adds a type property on to the received event object, in order to allow distinguishing the event types from each other (since you can subscribe to multiple events in one go).

Because the MetaData*Received events are arrays, this causes the way they are serialized to JSON te become:

{
  "type": "metadata-timed-received",
  "0": {
    "title": "Live Now - Helmets w/ Hablamos Muertos",
    "raw": [
      {
        "key": "StreamTitle",
        "commonKey": "title",
        "value": "Live Now - Helmets w/ Hablamos Muertos",
        "time": 0.6530612244897959,
        "keySpace": "icy"
      }
    ]
  }
}

A few ways we could solve this situation:

dcvz commented 9 months ago

To not break the current running apps, I'd say the second option is probably best. As it localizes the change just to these events.