Link

Background Mode

Android

The background support works right out of the box, and it will keep playing even after the app is closed. If that is not the desired behavior and you only want to play when the app is open, you can disable it with the stopWithApp property in updateOptions:

TrackPlayer.updateOptions({
    stopWithApp: true
});

While your app is in background, the UI might unmount, but you can still handle the events through the playback service.

Notification

The notification will be visible as long as the playback service runs. Your app will be opened when it is clicked, you can implement a custom initialization (e.g.: opening directly the player UI) by using the Linking API looking for the trackplayer://notification.click URI.

iOS

The background support requires you to activate the background capability in Xcode. Without activating it, the audio will only play when the app is in foreground.

Xcode Background Capability

Windows

The background support requires you to add the background capability in the app manifest, as documented by Microsoft

<Capabilities>
    <uap3:Capability Name="backgroundMediaPlayback"/>
</Capabilities>