The Audio playback notification is still visible when the playback stops

62 Views Asked by At

I'm using [email protected]. When I closed the application, The audio stopped but the playback notification was still visible.

Here is my track player setup code in index.js file.

const trackSetup = async () => await TrackPlayer.setupPlayer({
waitForBuffer: false}).then( async () => {
await TrackPlayer.updateOptions({
  // stoppingAppPausesPlayback: true,
  android: {
    appKilledPlaybackBehavior:
      AppKilledPlaybackBehavior.StopPlaybackAndRemoveNotification,
  },
  notificationCapabilities: [
    Capability.Play,
    Capability.Pause,
    Capability.JumpBackward,
    Capability.JumpForward,
    Capability.SeekTo,
  ],
  capabilities: [
    Capability.Play,
    Capability.Pause,
    Capability.JumpBackward,
    Capability.JumpForward,
    Capability.SeekTo,
  ],
  compactCapabilities: [Capability.Play, Capability.Pause],
});
console.log(AppState.currentState, 'Track Player Setup...');});

Kindly help/guide me to fix this issue. Every help is appreciated.

1

There are 1 best solutions below

1
On
AppKilledPlaybackBehavior.StopPlaybackAndRemoveNotification

works fine for me on the latest version (4.0.1).

Maybe update the package?

Also, in your App.js's useEffect:

useEffect(() => {
    return () => {
        TrackPlayer.reset();
    };
}, []);