diff --git a/docs/docs/basics/installation.mdx b/docs/docs/basics/installation.mdx index 722000fa3..3825fdb37 100644 --- a/docs/docs/basics/installation.mdx +++ b/docs/docs/basics/installation.mdx @@ -48,7 +48,11 @@ iOS requires a few extra steps that are _not_ required for Android/Web. ### Enable Swift Modules -Because the iOS module uses Swift, if the user is using a standard react-native application they'll need to add support for Swift in the project. This can be easily by adding a swift file to the Xcode project -- could be called `dummy.swift` and saying yes when prompted if you'd like to generate a bridging header. +Because the iOS module uses Swift, if the user is using a standard react-native +application they'll need to add support for Swift in the project. This can be +easily by adding a swift file to the Xcode project -- could be called +`dummy.swift` and saying yes when prompted if you'd like to generate a bridging +header. ![Importing Swift](https://i.imgur.com/CBqBcWs.png) @@ -97,8 +101,10 @@ if you're using HLS streams with MPEG2-TS content. ## Expo -You can now use React Native Track Player with Expo. +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. +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. 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 index ec759eb34..7cfbfe626 100644 --- a/docs/docs/guides/with-expo.md +++ b/docs/docs/guides/with-expo.md @@ -7,35 +7,73 @@ sidebar_position: 98 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. - +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). +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. +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. +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: +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 +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. +## Web + +Expo web [does not currently support dynamic imports](https://github.com/doublesymmetry/react-native-track-player/pull/2299#issuecomment-2462566794) +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 + +```tsx +// 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. +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). @@ -66,5 +104,3 @@ 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) - - diff --git a/web/TrackPlayer/Player.ts b/web/TrackPlayer/Player.ts index e537c2aeb..8926c2f25 100644 --- a/web/TrackPlayer/Player.ts +++ b/web/TrackPlayer/Player.ts @@ -43,7 +43,7 @@ export class Player { } // @ts-ignore - const shaka = await import('shaka-player/dist/shaka-player.ui'); + const shaka = (await import('shaka-player/dist/shaka-player.ui')).default; // Install built-in polyfills to patch browser incompatibilities. shaka.polyfill.installAll(); // Check to see if the browser supports the basic APIs Shaka needs.