I’ve carefully followed the documentation for react-native-track player:
Install it with yarn
Add “audio” to my UIBackgroundModes list in app.json (it works)
Run eas build to install it to my dev client.
In my App.tsx, register a background service as shown in the docs.
The problem seems to be with #4. Audio has no problem continuing to play in the background (screen locked and everything), but the background service doesn’t receive any of the remote- events (play, pause, etc).
I also tried putting remote listeners inside a React component and that didnt work either. This may be a clue. The non-remote events work fine.
There’s another thing in the docs that might be a hint. In the playback service section, it shows:
// This needs to go right after you register the main component of your app
// AppRegistry.registerComponent(...)
TrackPlayer.registerPlaybackService(() => require('./service'));
Since expo handles app registry automatically, there may be some issue with the timing of registration. I tried but couldn’t figure out how to use expo’s registerRootComponent to manually register it.
edit Got registerRootComponent working, and made sure to register the playback service immediately after – didnt help
hey @pastel I tried following your configs but I keep getting the same error
TypeError: null is not an object (evaluating ‘TrackPlayer.RATING_HEART’)
Invariant Violation: “main” has not been registered. This can happen if:
*** Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.**
*** A module failed to load due to an error and AppRegistry.registerComponent wasn’t called.**
It looks like TrackPlayer wasn’t installed properly. I’m using Expo v42 with a managed workflow – not sure if that makes a difference in your case. Are you sure that you installed it, as in yarn install react-native-track-player?
Assuming you did, the first thing I’d try is deleting node_modules then running yarn install again. There’s nothing special I did when I installed it.