react-native-track-player
react-native-track-player copied to clipboard
PlaybackError event doesn't trigger on iOS when connection is lost
Describe the Bug On Android, if the connection is lost, the "playback-error" event is triggered with code "playback-source". You could then use that to handle auto-reconnecting.
But on iOS this doesn't happen. I get a "playback-state" event with the state "paused" and then that's it. The "paused" state makes little sense, particularly for live streams.
If you want to handle reconnecting on iOS, you have to listen for the "paused" event, then check if there's a connection using a package like @react-native-community/netinfo
, and then start attempting to reconnect.
This was previously mentioned in issue #421, but it was closed without a fix.
@gavrichards what version of the library are you using?
@jspizziri 2.1.2
@gavrichards thanks! After taking a quick look I'm guessing that this is actually a bug in SwiftAudioEx as this package simply observes state and failure events from the player provided by that package.
With that said, it definitely sounds like something that needs to be fixed. With that in mind, I have a few questions:
- Can you create a list of reproducible steps that most easily create the issue to help us resolve it?
- If possible could you create a fork of this project and create a repro in the
example
project? - Do you have the ability (with help from contributors) to take a crack at digging into the native side and trying to fix it?
- You can use this library's
useTrackPlayerEvents
hook and check for anevent.type
ofEvent.PlaybackError
. You'll see that if you lose connection while playing, this is only triggered on Android. - I'm afraid I'm not in a position to do that at the moment unfortunately.
- I don't know anything about native code I'm afraid so I won't be much help there.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Same issue on 3.0.0 but android too
Looking through the SwiftAudioEx source code, I am unable to spot a bug.
RNTP will emit an playback-error
whenever the
underlying AVPlayer code encounters AVPlayer.Status.failed
- https://developer.apple.com/documentation/avfoundation/avplayer/status/failed
The playback state observing implementation follows this example code to the T: https://developer.apple.com/documentation/avfoundation/media_playback/observing_playback_state
I do however see mentions of this issue with AVPlayer on old SO posts, so this might be an AVPlayer bug: https://stackoverflow.com/questions/27556521/avplayer-connection-loss-restarting
@TheTarasik @gavrichards can either of you create a reproduction of this based on the example project?
@gavrichards @TheTarasik pinging you here.
Closing until a repro is provided.