react-native-track-player icon indicating copy to clipboard operation
react-native-track-player copied to clipboard

Platform incongruities in State.Connecting & State.Buffering events

Open puckey opened this issue 3 years ago • 0 comments

According to RNTP docs we have two states for player loading: State.Connecting & State.Buffering:

  • State.Connecting indicates that the player is currently buffering (in "play" state)
  • State.Buffering indicates that the player is currently buffering (in "pause" state)

The Android implementation follows this spec. When the audio is set to play when ready, it emits the State.Buffering event, when it is set to not play when ready, it emits the State.Connecting event during loading / buffering.

On iOS however we get both events no matter the playWhenReady state of the player. State.Connecting is emitted during the initial load phase where the player is looking for a 'playable' key (some kind of magic key in the initial bits) in the resource. After this has found to be successful, the loading process is passed on to AVPlayer, which leads to the State.Buffering event.

What to do with this incongruity?

  • We force iOS to follow Android & the docs.
  • We change Android to always emit an initial State.Connecting event when starting to load an item.

(I tend to find the distinction between State.Connecting and State.Buffering events being dependent on the playWhenReady state a little confusing.)

puckey avatar Sep 14 '22 07:09 puckey