<iOS> Background player still exists after destroying track-player
Configuration
react-native-track-player version: 2.0.0-rc13
Issue
I use track player to render a recording. It works really fine, But after I'm destroying the player on iOS, After locking the device the audio stream indeed stopped, but I still see the notification.
Code
const leavePlayer = async () => {
await TrackPlayer.stop();
await TrackPlayer.destroy();
}
After executing this function the player destroys, But after locking the screen - this is the result.
Do you have any idea why does it happen? Thanks.
Does this happen only if you are viewing the lock screen when your leavePlayer function is called?
Does it happen if you are in the app when the function is called, and then press power button twice to view lock screen?
Related:
https://github.com/react-native-kit/react-native-track-player/issues/825
https://github.com/jorgenhenrichsen/SwiftAudio/issues/83
I can confirm this bug. Destroying the player doesn't destroy the external notification player.
Calling TrackPlayer.reset() before destroying fixes the issue. At least it's a workaround for now.
@marioot If you are viewing the lock screen when calling reset() and destroy(), does the notification go away?
@marioot calling reset before destroy does not work for me, @curiousdustin yes after calling destroy() and reset controls still appears on the lock screen, Any update on this?
Experiencing the same issue here. In the return statement for the useEffect (the unmount) I've tried the following to no avail, the notification still persists on iOS. Android works as expected.
TrackPlayer.remove(trackId)
TrackPlayer.reset()
TrackPlayer.destroy()