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

<iOS> Background player still exists after destroying track-player

Open sarykemmoun opened this issue 6 years ago • 7 comments

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. File Do you have any idea why does it happen? Thanks.

sarykemmoun avatar Mar 24 '20 13:03 sarykemmoun

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?

dustinbahr avatar Apr 15 '20 12:04 dustinbahr

Related:

https://github.com/react-native-kit/react-native-track-player/issues/825

https://github.com/jorgenhenrichsen/SwiftAudio/issues/83

dustinbahr avatar Apr 26 '20 12:04 dustinbahr

I can confirm this bug. Destroying the player doesn't destroy the external notification player.

marioot avatar May 13 '20 12:05 marioot

Calling TrackPlayer.reset() before destroying fixes the issue. At least it's a workaround for now.

marioot avatar May 13 '20 12:05 marioot

@marioot If you are viewing the lock screen when calling reset() and destroy(), does the notification go away?

dustinbahr avatar May 14 '20 16:05 dustinbahr

@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?

waheedakhtar694 avatar Dec 23 '20 09:12 waheedakhtar694

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()

nickmcmillan avatar Jan 22 '21 01:01 nickmcmillan