From 7cb43bba65d8f518d92de76a57e743d652124cb5 Mon Sep 17 00:00:00 2001 From: David Talbot <17692467+dctalbot@users.noreply.github.com> Date: Tue, 30 Apr 2024 06:14:04 -0400 Subject: [PATCH] docs(guides): add an Expo guide #2296 --- docs/docs/basics/installation.mdx | 7 +--- docs/docs/guides/with-expo.md | 70 +++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 docs/docs/guides/with-expo.md diff --git a/docs/docs/basics/installation.mdx b/docs/docs/basics/installation.mdx index 92014df8b..722000fa3 100644 --- a/docs/docs/basics/installation.mdx +++ b/docs/docs/basics/installation.mdx @@ -101,9 +101,4 @@ You can now use React Native Track Player with Expo. 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. -To get started, create a [custom development client](https://docs.expo.dev/clients/getting-started/) for your Expo app and then install React Native Track Player. - -Here is the configuration required for audio playback in background: - -- [iOS: Enable audio playback in background via your app.json](https://docs.expo.dev/versions/latest/sdk/audio/#playing-or-recording-audio-in-background) -- [Android: Stop playback when the app is closed](./background-mode.md/#android) +For more information, see [Developing with Expo](../guides/with-expo.md). diff --git a/docs/docs/guides/with-expo.md b/docs/docs/guides/with-expo.md new file mode 100644 index 000000000..ec759eb34 --- /dev/null +++ b/docs/docs/guides/with-expo.md @@ -0,0 +1,70 @@ +--- +sidebar_position: 98 +--- + + +# 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](https://docs.expo.dev/more/glossary-of-terms/#dev-clients) is required in order to use this package (Expo Go is not supported). + +To get started, create a [development build](https://docs.expo.dev/clients/getting-started/) 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](https://docs.expo.dev/more/glossary-of-terms/#entry-point), you will need to [create a custom entry point](https://docs.expo.dev/guides/monorepos/#change-default-entrypoint) 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: + +1. Copy the default one + +``` +cp node_modules/expo/AppEntry.js AppEntry.js +``` + +2. Update the `"main"` field of `package.json` to reference the new file e.g. `"AppEntry.js"` +3. Edit the new file to have it import your app code, and configure the Playback Service. + + +## 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](https://docs.expo.dev/versions/latest/sdk/build-properties). + +``` +expo install expo-build-properties +``` + +Then add this configuration in `app.json`: + +```json +... + "plugins": [ + [ + "expo-build-properties", + { + "android": { + "usesCleartextTraffic": true + } + } + ] + ] +... +``` + +## Background Audio + +Here is the configuration required for audio playback in background: + +- [iOS: Enable audio playback in background via your app.json](https://docs.expo.dev/versions/latest/sdk/audio/#playing-or-recording-audio-in-background) +- [Android: Stop playback when the app is closed](../basics/background-mode.md/#android) + +