Developing with Expo
Expo is a popular development platform in the react-native ecosystem.
Please be aware that while many people are using React Native Track Player with Expo successfully, the current maintainers of this project do not use Expo and their ability to resolve issues involving Expo is limited.
Development Build
A Dev Client is required in order to use this package (Expo Go is not supported).
To get started, create a development build for your Expo app and then install React Native Track Player.
Custom Entry Point
In order to configure the Playback Service within the entry point,
you will need to create a custom entry point
and adjust the package.json
configuration.
By default, Expo points to an entry point in the node_modules
folder. The path
for this is configured in the "main"
field of package.json
. To create a new
entry point:
- Copy the default one
cp node_modules/expo/AppEntry.js AppEntry.js
- Update the
"main"
field ofpackage.json
to reference the new file e.g."AppEntry.js"
- Edit the new file to have it import your app code, and configure the Playback Service.
Web
Expo web does not currently support dynamic imports which are leveraged in the web package to support SSR. If you'd like to use the web version via Expo the recommendation is to:
1. Install @expo/metro-runtime
npm install --save @expo/metro-runtime
yarn add @expo/metro-runtime
2. Import @expo/metro-runtime
in your App root
// App.tsx
import '@expo/metro-runtime';
...
Streaming HTTP
On newer versions of Android, HTTP streaming is disallowed by default (HTTPS is OK). However, it is only disallowed in production builds which can make this issue hard to diagnose.
To allow HTTP, you must first install the expo-build-properties
package.
expo install expo-build-properties
Then add this configuration in app.json
:
...
"plugins": [
[
"expo-build-properties",
{
"android": {
"usesCleartextTraffic": true
}
}
]
]
...
Background Audio
Here is the configuration required for audio playback in background: