52 |
--------------------------------------------------------------------------------
/docs/docs/guides/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Guides",
3 | "position": 4
4 | }
5 |
--------------------------------------------------------------------------------
/docs/docs/guides/offline-playback.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # Offline Playback
6 |
7 | There are two general use-cases for offline playback:
8 |
9 | 1. An "Offline Only" case where all the audio is bundled with your App itself.
10 | 2. A "Hybrid Offline/Network" case where some of the time you're playing from a
11 | network and sometime you're playing offline.
12 |
13 | Both of these can be achieved by with this project. The only practical
14 | difference between the two is in the 2nd you'll need another package to
15 | download your audio while your App is running instead of loading into the App's
16 | source at build time.
17 |
18 | After that, you simply send a `Track` object to the player with a **local file
19 | path** to your audio.
20 |
21 | ## Offline Only
22 |
23 | This case is simple, just stick your audio files in your repository with your
24 | source code and use the file paths to them when adding Tracks.
25 |
26 | :warning: Please take into consideration that this approach will increase
27 | the size of your App based on how much audio you want the user to be able to
28 | play. If you're doing anything substantial, it's recommended that you use
29 | the [Hybrid Offline/Network](#hybrid-offline-network) approach.
30 |
31 | ## Hybrid Offline/Network
32 |
33 | To do this you'll first need to install a package like:
34 |
35 | - [react-native-fs](https://github.com/itinance/react-native-fs/)
36 | - [rn-fetch-blob](https://github.com/joltup/rn-fetch-blob)
37 | - [expo-file-system](https://www.npmjs.com/package/expo-file-system)
38 |
39 | The typical approach is to then create a download button in your app, which,
40 | once clicked, uses one of the above packages to download your audio to a local
41 | file. Then voila! Simply play the local file after download.
42 |
--------------------------------------------------------------------------------
/docs/docs/guides/saving-progress.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Saving Progress
6 |
7 | A common use-case is to store the users progress on a particular `Track`
8 | somewhere so that when they leave and come back, they can pick up right where
9 | they left off. To do this you need to listen for progress updates and then
10 | store the progress somewhere. There are two high level ways of getting this
11 | done.
12 |
13 | ## Naive Approach
14 |
15 | One approach could be to use the progress events/updates that the `useProgress`
16 | hook provides. This isn't a very good idea and here's why:
17 |
18 | Users can listen to audio both "in-App" and "Remotely". In-App would be defined
19 | as playback while the user has the app opened on screen. However, whenever
20 | audio is being played in the background/remotely. For example: playback on the
21 | lockscreen, carplay, etc. In these situations **the UI is not mounted**, meaning
22 | the `useProgress` hook, or really any event listeners that are registered
23 | inside of your App UI tree (anything called as a result of
24 | `AppRegistry.registerComponent(appName, () => App);` in your `index.js` file)
25 | **WILL NOT EXECUTE**.
26 |
27 | In a nutshell, if you do this, you're progress **will not** update when the user
28 | is playing back in Remote contexts and therefore your app will seem buggy.
29 |
30 | ## Recommended Approach
31 |
32 | The correct way to handle this is to track progress in the
33 | [Playback Service](../basics/playback-service.md), based on the
34 | `Event.PlaybackProgressUpdated` event. These events fire all the time, including
35 | when your app is playing back remotely.
36 |
--------------------------------------------------------------------------------
/docs/docs/guides/sleeptimers.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Sleeptimers
6 |
7 | This guide has very similar principles and implementation to
8 | [Saving Progress](./saving-progress.md). First please read through that guide
9 | to understand the concept of "remote" playback and why coupling playback events
10 | to the UI is a bad idea.
11 |
12 | Once you've understood that concept, this concept is nearly identical. You would
13 | leverage the same `Event.PlaybackProgressUpdated` event in this scenario too.
14 |
15 | Here's how you would use an event to implement a sleep timer:
16 |
17 | 1. The user configures a sleep timer in the UI.
18 | 2. Persist the time they configure in a store as a timestamp.
19 | 3. Each time the progress event fires you check your persisted sleep timer timestamp.
20 | - IF `sleeptime !== null && sleeptime <= now` THEN pause.
21 |
--------------------------------------------------------------------------------
/docs/docs/sponsors.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 11
3 | ---
4 |
5 | # Sponsors ❤️
6 |
7 | Thanks to our backers and sponsors for their generous support!
8 |
9 | ## Backers
10 |
11 | Support us with a monthly donation and help us continue our activities. [[Become a backer](https://github.com/sponsors/doublesymmetry)]
12 |
13 |
14 |
15 |
16 |
17 | ## Sponsors
18 |
19 | Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://github.com/sponsors/doublesymmetry)]
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/docs/docs/v3.1.0-migration.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 7
3 | ---
4 |
5 | # Migrating from v3.1.0 to v3.2.0
6 |
7 | ### `stoppingAppPausesPlayback` is deprecated
8 |
9 | ```diff
10 | await TrackPlayer.updateOptions({
11 | + android: {
12 | + appKilledPlaybackBehavior: AppKilledPlaybackBehavior.ContinuePlayback
13 | + },
14 | // This flag is now deprecated. Please use the above to define playback mode.
15 | - stoppingAppPausesPlayback: true,
16 | }
17 | ```
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "docs",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "docusaurus": "docusaurus",
7 | "start": "docusaurus start",
8 | "build": "docusaurus build",
9 | "swizzle": "docusaurus swizzle",
10 | "deploy": "docusaurus deploy",
11 | "clear": "docusaurus clear",
12 | "serve": "docusaurus serve",
13 | "write-translations": "docusaurus write-translations",
14 | "write-heading-ids": "docusaurus write-heading-ids",
15 | "typecheck": "tsc"
16 | },
17 | "dependencies": {
18 | "@docusaurus/core": "2.0.0-beta.18",
19 | "@docusaurus/preset-classic": "2.0.0-beta.18",
20 | "@mdx-js/react": "^1.6.22",
21 | "clsx": "^1.1.1",
22 | "prism-react-renderer": "^1.3.1",
23 | "react": "^17.0.2",
24 | "react-dom": "^17.0.2"
25 | },
26 | "devDependencies": {
27 | "@docusaurus/module-type-aliases": "2.0.0-beta.18",
28 | "@tsconfig/docusaurus": "^1.0.5",
29 | "typescript": "^4.6.3"
30 | },
31 | "browserslist": {
32 | "production": [
33 | ">0.5%",
34 | "not dead",
35 | "not op_mini all"
36 | ],
37 | "development": [
38 | "last 1 chrome version",
39 | "last 1 firefox version",
40 | "last 1 safari version"
41 | ]
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/docs/sidebars.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Creating a sidebar enables you to:
3 | - create an ordered group of docs
4 | - render a sidebar for each doc of that group
5 | - provide next/previous navigation
6 |
7 | The sidebars can be generated from the filesystem, or explicitly defined here.
8 |
9 | Create as many sidebars as you want.
10 | */
11 |
12 | // @ts-check
13 |
14 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
15 | const sidebars = {
16 | // By default, Docusaurus generates a sidebar from the docs folder structure
17 | app: [{type: 'autogenerated', dirName: '.'}],
18 |
19 | // But you can create a sidebar manually
20 | /*
21 | tutorialSidebar: [
22 | {
23 | type: 'category',
24 | label: 'Tutorial',
25 | items: ['hello'],
26 | },
27 | ],
28 | */
29 | };
30 |
31 | module.exports = sidebars;
32 |
--------------------------------------------------------------------------------
/docs/src/components/HomepageFeatures/styles.module.css:
--------------------------------------------------------------------------------
1 | .features {
2 | display: flex;
3 | align-items: center;
4 | padding: 2rem 0;
5 | width: 100%;
6 | }
7 |
8 | .featureSvg {
9 | height: 200px;
10 | width: 200px;
11 | }
12 |
--------------------------------------------------------------------------------
/docs/src/pages/index.module.css:
--------------------------------------------------------------------------------
1 | /**
2 | * CSS files with the .module.css suffix will be treated as CSS modules
3 | * and scoped locally.
4 | */
5 |
6 | .heroBanner {
7 | padding: 4rem 0;
8 | text-align: center;
9 | position: relative;
10 | overflow: hidden;
11 | }
12 |
13 | @media screen and (max-width: 996px) {
14 | .heroBanner {
15 | padding: 2rem;
16 | }
17 | }
18 |
19 | .buttons {
20 | display: flex;
21 | align-items: center;
22 | justify-content: center;
23 | }
24 |
--------------------------------------------------------------------------------
/docs/static/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/.nojekyll
--------------------------------------------------------------------------------
/docs/static/CNAME:
--------------------------------------------------------------------------------
1 | react-native-track-player.js.org
2 |
--------------------------------------------------------------------------------
/docs/static/example/Longing.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/Longing.jpeg
--------------------------------------------------------------------------------
/docs/static/example/Longing.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/Longing.mp3
--------------------------------------------------------------------------------
/docs/static/example/Lullaby (Demo).jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/Lullaby (Demo).jpeg
--------------------------------------------------------------------------------
/docs/static/example/Lullaby (Demo).mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/Lullaby (Demo).mp3
--------------------------------------------------------------------------------
/docs/static/example/Rhythm City (Demo).jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/Rhythm City (Demo).jpeg
--------------------------------------------------------------------------------
/docs/static/example/Rhythm City (Demo).mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/Rhythm City (Demo).mp3
--------------------------------------------------------------------------------
/docs/static/example/Soul Searching.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/Soul Searching.jpeg
--------------------------------------------------------------------------------
/docs/static/example/Soul Searching.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/Soul Searching.mp3
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file0.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file0.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file1.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file1.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file10.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file10.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file11.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file11.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file12.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file12.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file13.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file13.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file14.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file14.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file15.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file15.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file16.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file16.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file17.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file17.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file18.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file18.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file19.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file19.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file2.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file2.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file20.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file20.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file21.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file21.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file22.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file22.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file23.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file23.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file3.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file3.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file4.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file4.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file5.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file5.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file6.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file6.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file7.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file7.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file8.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file8.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/file9.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/file9.m4a
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/playlist.m3u8:
--------------------------------------------------------------------------------
1 | #EXTM3U
2 | #EXT-X-VERSION:3
3 | #EXT-X-MEDIA-SEQUENCE:0
4 | #EXT-X-ALLOW-CACHE:YES
5 | #EXT-X-TARGETDURATION:8
6 | #EXTINF:7.012433,
7 | file0.m4a
8 | #EXTINF:6.989200,
9 | file1.m4a
10 | #EXTINF:7.012433,
11 | file2.m4a
12 | #EXTINF:6.989200,
13 | file3.m4a
14 | #EXTINF:7.012433,
15 | file4.m4a
16 | #EXTINF:6.989211,
17 | file5.m4a
18 | #EXTINF:7.012433,
19 | file6.m4a
20 | #EXTINF:6.989211,
21 | file7.m4a
22 | #EXTINF:7.012433,
23 | file8.m4a
24 | #EXTINF:6.989211,
25 | file9.m4a
26 | #EXTINF:7.012422,
27 | file10.m4a
28 | #EXTINF:6.989211,
29 | file11.m4a
30 | #EXTINF:7.012422,
31 | file12.m4a
32 | #EXTINF:6.989211,
33 | file13.m4a
34 | #EXTINF:6.989211,
35 | file14.m4a
36 | #EXTINF:7.012433,
37 | file15.m4a
38 | #EXTINF:6.989200,
39 | file16.m4a
40 | #EXTINF:7.012433,
41 | file17.m4a
42 | #EXTINF:6.989200,
43 | file18.m4a
44 | #EXTINF:7.012433,
45 | file19.m4a
46 | #EXTINF:6.989200,
47 | file20.m4a
48 | #EXTINF:7.012433,
49 | file21.m4a
50 | #EXTINF:6.989200,
51 | file22.m4a
52 | #EXTINF:3.300133,
53 | file23.m4a
54 | #EXT-X-ENDLIST
55 |
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/whip.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/whip.jpeg
--------------------------------------------------------------------------------
/docs/static/example/hls/whip/whip.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/hls/whip/whip.mp3
--------------------------------------------------------------------------------
/docs/static/example/smooth-jazz-24-7.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/example/smooth-jazz-24-7.jpeg
--------------------------------------------------------------------------------
/docs/static/img/debugging/debug-ios-rntp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/img/debugging/debug-ios-rntp.png
--------------------------------------------------------------------------------
/docs/static/img/debugging/debug-ios-swift-audio-ex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/img/debugging/debug-ios-swift-audio-ex.png
--------------------------------------------------------------------------------
/docs/static/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/docs/static/img/logo.png
--------------------------------------------------------------------------------
/docs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | // This file is not used in compilation. It is here just for a nice editor experience.
3 | "extends": "@tsconfig/docusaurus/tsconfig.json",
4 | "compilerOptions": {
5 | "baseUrl": "."
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "API Reference",
3 | "position": 3
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/constants/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Constants",
3 | "position": 4
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/constants/capability.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Capability
6 |
7 | All Capability types are made available through the named export `Capability`:
8 |
9 | ```ts
10 | import { Capability } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Play` | Capability indicating the ability to play |
16 | | `PlayFromId` | Capability indicating the ability to play from a track id (Required for Android Auto) |
17 | | `PlayFromSearch` | Capability indicating the ability to play from a text/voice search (Required for Android Auto) |
18 | | `Pause` | Capability indicating the ability to pause |
19 | | `Stop` | Capability indicating the ability to stop |
20 | | `SeekTo` | Capability indicating the ability to seek to a position in the timeline |
21 | | `Skip` | Capability indicating the ability to skip to any song in the queue |
22 | | `SkipToNext` | Capability indicating the ability to skip to the next track |
23 | | `SkipToPrevious` | Capability indicating the ability to skip to the previous track |
24 | | `SetRating` | Capability indicating the ability to set the rating value based on the rating type |
25 | | `JumpForward` | Capability indicating the ability to jump forward by the amount of seconds specified in the options |
26 | | `JumpBackward` | Capability indicating the ability to jump backward by the amount of seconds specified in the options |
27 | | `Like` | (ios-only) Capability indicating the ability to like from control center |
28 | | `Dislike` | (ios-only) Capability indicating the ability to dislike from control center |
29 | | `Bookmark` | (ios-only) Capability indicating the ability to bookmark from control center |
30 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/constants/pitch-algorithm.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 5
3 | ---
4 |
5 | # Pitch Algorithm (ios-only)
6 |
7 | All PitchAlgorithm types are made available through the named export `PitchAlgorithm`:
8 |
9 | ```ts
10 | import { PitchAlgorithm } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Linear` | An algorithm suitable for general use. |
16 | | `Music` | An algorithm suitable for music. |
17 | | `Voice` | An algorithm suitable for voice. |
18 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/constants/rating.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Rating
6 |
7 | All RatingType types are made available through the named export `RatingType`:
8 |
9 | ```ts
10 | import { RatingType } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Heart` | Rating type indicating "with heart" or "without heart", its value is a `boolean`. |
16 | | `ThumbsUpDown` | Rating type indicating "thumbs up" or "thumbs down", its value is a `boolean`. |
17 | | `ThreeStars` | Rating type indicating 0 to 3 stars, its value is a `number` of stars. |
18 | | `FourStars` | Rating type indicating 0 to 4 stars, its value is a `number` of stars. |
19 | | `FiveStars` | Rating type indicating 0 to 5 stars, its value is a `number` of stars. |
20 | | `Percentage` | Rating type indicating percentage, its value is a `number`. |
21 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/constants/repeat-mode.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 4
3 | ---
4 |
5 | # Repeat Mode
6 |
7 | All RepeatMode types are made available through the named export `RepeatMode`:
8 |
9 | ```ts
10 | import { RepeatMode } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Off` | Doesn't repeat. |
16 | | `Track` | Loops the current track. |
17 | | `Queue` | Repeats the whole queue. |
18 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/constants/state.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # State
6 |
7 | All State types are made available through the named export `State`:
8 |
9 | ```ts
10 | import { State } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `None` | State indicating that no media is currently loaded |
16 | | `Ready` | State indicating that the player is ready to start playing |
17 | | `Playing` | State indicating that the player is currently playing |
18 | | `Paused` | State indicating that the player is currently paused |
19 | | `Stopped` | State indicating that the player is currently stopped |
20 | | `Buffering` | State indicating that the player is currently buffering (in "play" state) |
21 | | `Connecting` | State indicating that the player is currently buffering (in "pause" state) |
22 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/functions/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Functions",
3 | "position": 1
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/objects/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Objects",
3 | "position": 5
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/objects/feedback.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Feedback
6 |
7 | Controls the rendering of the control center item.
8 |
9 | | Param | Type | Description |
10 | | -------------- | --------------------------- | ------------ |
11 | | isActive | `boolean` | Marks wether the option should be marked as active or "done" |
12 | | title | `boolean` | The title to give the action (relevant for iOS) |
13 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/api/objects/resource.md:
--------------------------------------------------------------------------------
1 | # Resource
2 |
3 | Resource objects are the result of `require`/`import` for files.
4 |
5 | For more information about Resource Objects, read the [Images](https://reactnative.dev/docs/images) section of the React Native documentation
6 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/basics/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "The Basics",
3 | "position": 2
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/basics/build-preferences.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 6
3 | ---
4 |
5 | # Build Preferences
6 |
7 | You can optionally configure a few options for how the Track Player module is built in your app. Add a JSON file named `track-player.json` to the root folder of your app (the same folder where `index.android.js` and `node_modules` are stored) and set one or more of the following properties:
8 |
9 | ```json
10 | {
11 | "dash": false,
12 | "hls": false,
13 | "smoothstreaming": false
14 | }
15 | ```
16 |
17 | ## `dash` (Android)
18 |
19 | Whether it will add support for [DASH](https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP) streams. This option adds an extension for handling DASH streams, which changes the app size. Defaults to `false`.
20 |
21 | ## `hls` (Android)
22 |
23 | Whether it will add support for [Smooth Streaming](https://en.wikipedia.org/wiki/Adaptive_bitrate_streaming#Microsoft_Smooth_Streaming) streams. This option adds an extension for handling SmoothStreaming streams, which changes the app size. Defaults to `false`.
24 |
25 | ## `smoothstreaming` (Android)
26 |
27 | Whether it will add support for SmoothStreaming streams. This option adds an extension for handling SmoothStreaming streams, which changes the app size.
28 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/basics/playback-service.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Playback Service
6 |
7 | The playback service keeps running even when the app is in the background. It will start when the player is set up and will only stop when the player is destroyed. It is a good idea to put any code in there that needs to be directly tied to the player state. For example, if you want to be able to track what is being played for analytics purposes, the playback service would be the place to do so.
8 |
9 | ## Remote Events
10 |
11 | [Remote events](../api/events.md#media-controls) are sent from places outside of our user interface that we can react to. For example if the user presses the pause media control in the IOS lockscreen / Android notification or from their Bluetooth headset, we want to have TrackPlayer pause the audio.
12 |
13 | If you create a listener to a remote event like `remote-pause` in the context of a React component, there is a chance the UI will be unmounted automatically when the app is in the background, causing it to be missed. For this reason it is best to place remote listeners in the playback service, since it will keep running even when the app is in the background.
14 |
15 | ## Example
16 | ```typescript
17 | // This needs to go right after you register the main component of your app
18 | // AppRegistry.registerComponent(...)
19 | TrackPlayer.registerPlaybackService(() => require('./service'));
20 | ```
21 |
22 | ```javascript
23 | // service.js
24 | module.exports = async function() {
25 |
26 | TrackPlayer.addEventListener('remote-play', () => TrackPlayer.play());
27 |
28 | TrackPlayer.addEventListener('remote-pause', () => TrackPlayer.pause());
29 |
30 | TrackPlayer.addEventListener('remote-stop', () => TrackPlayer.destroy());
31 |
32 | // ...
33 |
34 | };
35 | ```
36 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/core-team.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 8
3 | ---
4 |
5 | # Core Team ✨
6 |
7 |
52 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/guides/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Guides",
3 | "position": 4
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/guides/offline-playback.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # Offline Playback
6 |
7 | There are two general use-cases for offline playback:
8 |
9 | 1. An "Offline Only" case where all the audio is bundled with your App itself.
10 | 2. A "Hybrid Offline/Network" case where some of the time you're playing from a
11 | network and sometime you're playing offline.
12 |
13 | Both of these can be achieved by with this project. The only practical
14 | difference between the two is in the 2nd you'll need another package to
15 | download your audio while your App is running instead of loading into the App's
16 | source at build time.
17 |
18 | After that, you simply send a `Track` object to the player with a **local file
19 | path** to your audio.
20 |
21 | ## Offline Only
22 |
23 | This case is simple, just stick your audio files in your repository with your
24 | source code and use the file paths to them when adding Tracks.
25 |
26 | :warning: Please take into consideration that this approach will increase
27 | the size of your App based on how much audio you want the user to be able to
28 | play. If you're doing anything substantial, it's recommended that you use
29 | the [Hybrid Offline/Network](#hybrid-offline-network) approach.
30 |
31 | ## Hybrid Offline/Network
32 |
33 | To do this you'll first need to install a package like:
34 |
35 | - [react-native-fs](https://github.com/itinance/react-native-fs/)
36 | - [rn-fetch-blob](https://github.com/joltup/rn-fetch-blob)
37 | - [expo-file-system](https://www.npmjs.com/package/expo-file-system)
38 |
39 | The typical approach is to then create a download button in your app, which,
40 | once clicked, uses one of the above packages to download your audio to a local
41 | file. Then voila! Simply play the local file after download.
42 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-2.1/sponsors.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 7
3 | ---
4 |
5 | # Sponsors ❤️
6 |
7 | Thanks to our backers and sponsors for their generous support!
8 |
9 | ## Backers
10 |
11 | Support us with a monthly donation and help us continue our activities. [[Become a backer](https://github.com/sponsors/doublesymmetry)]
12 |
13 |
14 |
15 |
16 |
17 | ## Sponsors
18 |
19 | Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://github.com/sponsors/doublesymmetry)]
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "API Reference",
3 | "position": 3
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/constants/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Constants",
3 | "position": 4
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/constants/capability.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Capability
6 |
7 | All Capability types are made available through the named export `Capability`:
8 |
9 | ```ts
10 | import { Capability } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Play` | Capability indicating the ability to play |
16 | | `PlayFromId` | Capability indicating the ability to play from a track id (Required for Android Auto) |
17 | | `PlayFromSearch` | Capability indicating the ability to play from a text/voice search (Required for Android Auto) |
18 | | `Pause` | Capability indicating the ability to pause |
19 | | `Stop` | Capability indicating the ability to stop |
20 | | `SeekTo` | Capability indicating the ability to seek to a position in the timeline |
21 | | `Skip` | Capability indicating the ability to skip to any song in the queue |
22 | | `SkipToNext` | Capability indicating the ability to skip to the next track |
23 | | `SkipToPrevious` | Capability indicating the ability to skip to the previous track |
24 | | `SetRating` | Capability indicating the ability to set the rating value based on the rating type |
25 | | `JumpForward` | Capability indicating the ability to jump forward by the amount of seconds specified in the options |
26 | | `JumpBackward` | Capability indicating the ability to jump backward by the amount of seconds specified in the options |
27 | | `Like` | (ios-only) Capability indicating the ability to like from control center |
28 | | `Dislike` | (ios-only) Capability indicating the ability to dislike from control center |
29 | | `Bookmark` | (ios-only) Capability indicating the ability to bookmark from control center |
30 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/constants/pitch-algorithm.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 5
3 | ---
4 |
5 | # Pitch Algorithm (ios-only)
6 |
7 | All PitchAlgorithm types are made available through the named export `PitchAlgorithm`:
8 |
9 | ```ts
10 | import { PitchAlgorithm } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Linear` | An algorithm suitable for general use. |
16 | | `Music` | An algorithm suitable for music. |
17 | | `Voice` | An algorithm suitable for voice. |
18 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/constants/rating.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Rating
6 |
7 | All RatingType types are made available through the named export `RatingType`:
8 |
9 | ```ts
10 | import { RatingType } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Heart` | Rating type indicating "with heart" or "without heart", its value is a `boolean`. |
16 | | `ThumbsUpDown` | Rating type indicating "thumbs up" or "thumbs down", its value is a `boolean`. |
17 | | `ThreeStars` | Rating type indicating 0 to 3 stars, its value is a `number` of stars. |
18 | | `FourStars` | Rating type indicating 0 to 4 stars, its value is a `number` of stars. |
19 | | `FiveStars` | Rating type indicating 0 to 5 stars, its value is a `number` of stars. |
20 | | `Percentage` | Rating type indicating percentage, its value is a `number`. |
21 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/constants/repeat-mode.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 4
3 | ---
4 |
5 | # Repeat Mode
6 |
7 | All RepeatMode types are made available through the named export `RepeatMode`:
8 |
9 | ```ts
10 | import { RepeatMode } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Off` | Doesn't repeat. |
16 | | `Track` | Loops the current track. |
17 | | `Queue` | Repeats the whole queue. |
18 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/constants/state.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # State
6 |
7 | All State types are made available through the named export `State`:
8 |
9 | ```ts
10 | import { State } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `None` | State indicating that no media is currently loaded |
16 | | `Ready` | State indicating that the player is ready to start playing |
17 | | `Playing` | State indicating that the player is currently playing |
18 | | `Paused` | State indicating that the player is currently paused |
19 | | `Stopped` | State indicating that the player is currently stopped |
20 | | `Buffering` | State indicating that the player is currently buffering (in "play" state) |
21 | | `Connecting` | State indicating that the player is currently buffering (in "pause" state) |
22 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/functions/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Functions",
3 | "position": 1
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/objects/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Objects",
3 | "position": 5
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/objects/feedback.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Feedback
6 |
7 | Controls the rendering of the control center item.
8 |
9 | | Param | Type | Description |
10 | | -------------- | --------------------------- | ------------ |
11 | | isActive | `boolean` | Marks wether the option should be marked as active or "done" |
12 | | title | `boolean` | The title to give the action (relevant for iOS) |
13 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/api/objects/resource.md:
--------------------------------------------------------------------------------
1 | # Resource
2 |
3 | Resource objects are the result of `require`/`import` for files.
4 |
5 | For more information about Resource Objects, read the [Images](https://reactnative.dev/docs/images) section of the React Native documentation
6 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/basics/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "The Basics",
3 | "position": 2
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/core-team.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 12
3 | ---
4 |
5 | # Core Team ✨
6 |
7 |
52 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/guides/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Guides",
3 | "position": 4
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/guides/offline-playback.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # Offline Playback
6 |
7 | There are two general use-cases for offline playback:
8 |
9 | 1. An "Offline Only" case where all the audio is bundled with your App itself.
10 | 2. A "Hybrid Offline/Network" case where some of the time you're playing from a
11 | network and sometime you're playing offline.
12 |
13 | Both of these can be achieved by with this project. The only practical
14 | difference between the two is in the 2nd you'll need another package to
15 | download your audio while your App is running instead of loading into the App's
16 | source at build time.
17 |
18 | After that, you simply send a `Track` object to the player with a **local file
19 | path** to your audio.
20 |
21 | ## Offline Only
22 |
23 | This case is simple, just stick your audio files in your repository with your
24 | source code and use the file paths to them when adding Tracks.
25 |
26 | :warning: Please take into consideration that this approach will increase
27 | the size of your App based on how much audio you want the user to be able to
28 | play. If you're doing anything substantial, it's recommended that you use
29 | the [Hybrid Offline/Network](#hybrid-offline-network) approach.
30 |
31 | ## Hybrid Offline/Network
32 |
33 | To do this you'll first need to install a package like:
34 |
35 | - [react-native-fs](https://github.com/itinance/react-native-fs/)
36 | - [rn-fetch-blob](https://github.com/joltup/rn-fetch-blob)
37 | - [expo-file-system](https://www.npmjs.com/package/expo-file-system)
38 |
39 | The typical approach is to then create a download button in your app, which,
40 | once clicked, uses one of the above packages to download your audio to a local
41 | file. Then voila! Simply play the local file after download.
42 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/guides/saving-progress.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Saving Progress
6 |
7 | A common use-case is to store the users progress on a particular `Track`
8 | somewhere so that when they leave and come back, they can pick up right where
9 | they left off. To do this you need to listen for progress updates and then
10 | store the progress somewhere. There are two high level ways of getting this
11 | done.
12 |
13 | ## Naive Approach
14 |
15 | One approach could be to use the progress events/updates that the `useProgress`
16 | hook provides. This isn't a very good idea and here's why:
17 |
18 | Users can listen to audio both "in-App" and "Remotely". In-App would be defined
19 | as playback while the user has the app opened on screen. However, whenever
20 | audio is being played in the background/remotely. For example: playback on the
21 | lockscreen, carplay, etc. In these situations **the UI is not mounted**, meaning
22 | the `useProgress` hook, or really any event listeners that are registered
23 | inside of your App UI tree (anything called as a result of
24 | `AppRegistry.registerComponent(appName, () => App);` in your `index.js` file)
25 | **WILL NOT EXECUTE**.
26 |
27 | In a nutshell, if you do this, you're progress **will not** update when the user
28 | is playing back in Remote contexts and therefore your app will seem buggy.
29 |
30 | ## Recommended Approach
31 |
32 | The correct way to handle this is to track progress in the
33 | [Playback Service](../basics/playback-service.md), based on the
34 | `Event.PlaybackProgressUpdated` event. These events fire all the time, including
35 | when your app is playing back remotely.
36 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/guides/sleeptimers.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Sleeptimers
6 |
7 | This guide has very similar principles and implementation to
8 | [Saving Progress](./saving-progress.md). First please read through that guide
9 | to understand the concept of "remote" playback and why coupling playback events
10 | to the UI is a bad idea.
11 |
12 | Once you've understood that concept, this concept is nearly identical. You would
13 | leverage the same `Event.PlaybackProgressUpdated` event in this scenario too.
14 |
15 | Here's how you would use an event to implement a sleep timer:
16 |
17 | 1. The user configures a sleep timer in the UI.
18 | 2. Persist the time they configure in a store as a timestamp.
19 | 3. Each time the progress event fires you check your persisted sleep timer timestamp.
20 | - IF `sleeptime !== null && sleeptime <= now` THEN pause.
21 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.1/sponsors.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 11
3 | ---
4 |
5 | # Sponsors ❤️
6 |
7 | Thanks to our backers and sponsors for their generous support!
8 |
9 | ## Backers
10 |
11 | Support us with a monthly donation and help us continue our activities. [[Become a backer](https://github.com/sponsors/doublesymmetry)]
12 |
13 |
14 |
15 |
16 |
17 | ## Sponsors
18 |
19 | Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://github.com/sponsors/doublesymmetry)]
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "API Reference",
3 | "position": 3
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/constants/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Constants",
3 | "position": 4
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/constants/app-killed-playback-behavior.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 6
3 | ---
4 |
5 | # App Killed Playback Behavior (android-only)
6 |
7 | ```ts
8 | import { AppKilledPlaybackBehavior } from 'react-native-track-player';
9 | ```
10 |
11 | ## `ContinuePlayback` (default)
12 |
13 | This option will continue playing audio in the background when the app is
14 | removed from recents. The notification remains. This is the default.
15 |
16 | ## `PausePlayback`
17 |
18 | This option will pause playing audio in the background when the app is removed
19 | from recents. The notification remains and can be used to resume playback.
20 |
21 | ## `StopPlaybackAndRemoveNotification`
22 |
23 | This option will stop playing audio in the background when the app is removed
24 | from recents. The notification is removed and can't be used to resume playback.
25 | Users would need to open the app again to start playing audio.
26 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/constants/capability.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Capability
6 |
7 | All Capability types are made available through the named export `Capability`:
8 |
9 | ```ts
10 | import { Capability } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Play` | Capability indicating the ability to play |
16 | | `PlayFromId` | Capability indicating the ability to play from a track id (Required for Android Auto) |
17 | | `PlayFromSearch` | Capability indicating the ability to play from a text/voice search (Required for Android Auto) |
18 | | `Pause` | Capability indicating the ability to pause |
19 | | `Stop` | Capability indicating the ability to stop |
20 | | `SeekTo` | Capability indicating the ability to seek to a position in the timeline |
21 | | `Skip` | Capability indicating the ability to skip to any song in the queue |
22 | | `SkipToNext` | Capability indicating the ability to skip to the next track |
23 | | `SkipToPrevious` | Capability indicating the ability to skip to the previous track |
24 | | `SetRating` | Capability indicating the ability to set the rating value based on the rating type |
25 | | `JumpForward` | Capability indicating the ability to jump forward by the amount of seconds specified in the options |
26 | | `JumpBackward` | Capability indicating the ability to jump backward by the amount of seconds specified in the options |
27 | | `Like` | (ios-only) Capability indicating the ability to like from control center |
28 | | `Dislike` | (ios-only) Capability indicating the ability to dislike from control center |
29 | | `Bookmark` | (ios-only) Capability indicating the ability to bookmark from control center |
30 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/constants/pitch-algorithm.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 5
3 | ---
4 |
5 | # Pitch Algorithm (ios-only)
6 |
7 | All PitchAlgorithm types are made available through the named export `PitchAlgorithm`:
8 |
9 | ```ts
10 | import { PitchAlgorithm } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Linear` | An algorithm suitable for general use. |
16 | | `Music` | An algorithm suitable for music. |
17 | | `Voice` | An algorithm suitable for voice. |
18 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/constants/rating.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Rating
6 |
7 | All RatingType types are made available through the named export `RatingType`:
8 |
9 | ```ts
10 | import { RatingType } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Heart` | Rating type indicating "with heart" or "without heart", its value is a `boolean`. |
16 | | `ThumbsUpDown` | Rating type indicating "thumbs up" or "thumbs down", its value is a `boolean`. |
17 | | `ThreeStars` | Rating type indicating 0 to 3 stars, its value is a `number` of stars. |
18 | | `FourStars` | Rating type indicating 0 to 4 stars, its value is a `number` of stars. |
19 | | `FiveStars` | Rating type indicating 0 to 5 stars, its value is a `number` of stars. |
20 | | `Percentage` | Rating type indicating percentage, its value is a `number`. |
21 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/constants/repeat-mode.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 4
3 | ---
4 |
5 | # Repeat Mode
6 |
7 | All RepeatMode types are made available through the named export `RepeatMode`:
8 |
9 | ```ts
10 | import { RepeatMode } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `Off` | Doesn't repeat. |
16 | | `Track` | Loops the current track. |
17 | | `Queue` | Repeats the whole queue. |
18 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/constants/state.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # State
6 |
7 | All State types are made available through the named export `State`:
8 |
9 | ```ts
10 | import { State } from 'react-native-track-player';
11 | ```
12 |
13 | | Name | Description |
14 | |------|-------------|
15 | | `None` | State indicating that no media is currently loaded |
16 | | `Ready` | State indicating that the player is ready to start playing |
17 | | `Playing` | State indicating that the player is currently playing |
18 | | `Paused` | State indicating that the player is currently paused |
19 | | `Stopped` | State indicating that the player is currently stopped |
20 | | `Buffering` | State indicating that the player is currently buffering (in "play" state) |
21 | | `Connecting` | State indicating that the player is currently buffering (in "pause" state) |
22 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/functions/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Functions",
3 | "position": 1
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/objects/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Objects",
3 | "position": 5
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/objects/android-options.md:
--------------------------------------------------------------------------------
1 | # AndroidOptions
2 |
3 | Options available for the android player. All options are optional.
4 |
5 | | Param | Type | Default | Description |
6 | |-------|-------|---------|-------------|
7 | | `appKilledPlaybackBehavior` | [`AppKilledPlaybackBehavior`](../constants/app-killed-playback-behavior.md) | [`ContinuePlayback`](../constants/app-killed-playback-behavior#continueplayback-default.md) | Define how the audio playback should behave after removing the app from recents (killing it). |
8 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/objects/feedback.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Feedback
6 |
7 | Controls the rendering of the control center item.
8 |
9 | | Param | Type | Description |
10 | | -------------- | --------------------------- | ------------ |
11 | | isActive | `boolean` | Marks wether the option should be marked as active or "done" |
12 | | title | `boolean` | The title to give the action (relevant for iOS) |
13 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/api/objects/resource.md:
--------------------------------------------------------------------------------
1 | # Resource
2 |
3 | Resource objects are the result of `require`/`import` for files.
4 |
5 | For more information about Resource Objects, read the [Images](https://reactnative.dev/docs/images) section of the React Native documentation
6 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/basics/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "The Basics",
3 | "position": 2
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/core-team.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 12
3 | ---
4 |
5 | # Core Team ✨
6 |
7 |
52 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/guides/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "Guides",
3 | "position": 4
4 | }
5 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/guides/offline-playback.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 1
3 | ---
4 |
5 | # Offline Playback
6 |
7 | There are two general use-cases for offline playback:
8 |
9 | 1. An "Offline Only" case where all the audio is bundled with your App itself.
10 | 2. A "Hybrid Offline/Network" case where some of the time you're playing from a
11 | network and sometime you're playing offline.
12 |
13 | Both of these can be achieved by with this project. The only practical
14 | difference between the two is in the 2nd you'll need another package to
15 | download your audio while your App is running instead of loading into the App's
16 | source at build time.
17 |
18 | After that, you simply send a `Track` object to the player with a **local file
19 | path** to your audio.
20 |
21 | ## Offline Only
22 |
23 | This case is simple, just stick your audio files in your repository with your
24 | source code and use the file paths to them when adding Tracks.
25 |
26 | :warning: Please take into consideration that this approach will increase
27 | the size of your App based on how much audio you want the user to be able to
28 | play. If you're doing anything substantial, it's recommended that you use
29 | the [Hybrid Offline/Network](#hybrid-offline-network) approach.
30 |
31 | ## Hybrid Offline/Network
32 |
33 | To do this you'll first need to install a package like:
34 |
35 | - [react-native-fs](https://github.com/itinance/react-native-fs/)
36 | - [rn-fetch-blob](https://github.com/joltup/rn-fetch-blob)
37 | - [expo-file-system](https://www.npmjs.com/package/expo-file-system)
38 |
39 | The typical approach is to then create a download button in your app, which,
40 | once clicked, uses one of the above packages to download your audio to a local
41 | file. Then voila! Simply play the local file after download.
42 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/guides/saving-progress.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 2
3 | ---
4 |
5 | # Saving Progress
6 |
7 | A common use-case is to store the users progress on a particular `Track`
8 | somewhere so that when they leave and come back, they can pick up right where
9 | they left off. To do this you need to listen for progress updates and then
10 | store the progress somewhere. There are two high level ways of getting this
11 | done.
12 |
13 | ## Naive Approach
14 |
15 | One approach could be to use the progress events/updates that the `useProgress`
16 | hook provides. This isn't a very good idea and here's why:
17 |
18 | Users can listen to audio both "in-App" and "Remotely". In-App would be defined
19 | as playback while the user has the app opened on screen. However, whenever
20 | audio is being played in the background/remotely. For example: playback on the
21 | lockscreen, carplay, etc. In these situations **the UI is not mounted**, meaning
22 | the `useProgress` hook, or really any event listeners that are registered
23 | inside of your App UI tree (anything called as a result of
24 | `AppRegistry.registerComponent(appName, () => App);` in your `index.js` file)
25 | **WILL NOT EXECUTE**.
26 |
27 | In a nutshell, if you do this, you're progress **will not** update when the user
28 | is playing back in Remote contexts and therefore your app will seem buggy.
29 |
30 | ## Recommended Approach
31 |
32 | The correct way to handle this is to track progress in the
33 | [Playback Service](../basics/playback-service.md), based on the
34 | `Event.PlaybackProgressUpdated` event. These events fire all the time, including
35 | when your app is playing back remotely.
36 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/guides/sleeptimers.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 3
3 | ---
4 |
5 | # Sleeptimers
6 |
7 | This guide has very similar principles and implementation to
8 | [Saving Progress](./saving-progress.md). First please read through that guide
9 | to understand the concept of "remote" playback and why coupling playback events
10 | to the UI is a bad idea.
11 |
12 | Once you've understood that concept, this concept is nearly identical. You would
13 | leverage the same `Event.PlaybackProgressUpdated` event in this scenario too.
14 |
15 | Here's how you would use an event to implement a sleep timer:
16 |
17 | 1. The user configures a sleep timer in the UI.
18 | 2. Persist the time they configure in a store as a timestamp.
19 | 3. Each time the progress event fires you check your persisted sleep timer timestamp.
20 | - IF `sleeptime !== null && sleeptime <= now` THEN pause.
21 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/sponsors.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 11
3 | ---
4 |
5 | # Sponsors ❤️
6 |
7 | Thanks to our backers and sponsors for their generous support!
8 |
9 | ## Backers
10 |
11 | Support us with a monthly donation and help us continue our activities. [[Become a backer](https://github.com/sponsors/doublesymmetry)]
12 |
13 |
14 |
15 |
16 |
17 | ## Sponsors
18 |
19 | Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://github.com/sponsors/doublesymmetry)]
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/docs/versioned_docs/version-3.2/v3.1.0-migration.md:
--------------------------------------------------------------------------------
1 | ---
2 | sidebar_position: 7
3 | ---
4 |
5 | # Migrating from v3.1.0 to v3.2.0
6 |
7 | ### `stoppingAppPausesPlayback` is deprecated
8 |
9 | ```diff
10 | await TrackPlayer.updateOptions({
11 | + android: {
12 | + appKilledPlaybackBehavior: AppKilledPlaybackBehavior.ContinuePlayback
13 | + },
14 | // This flag is now deprecated. Please use the above to define playback mode.
15 | - stoppingAppPausesPlayback: true,
16 | }
17 | ```
--------------------------------------------------------------------------------
/docs/versioned_sidebars/version-2.1-sidebars.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": [
3 | {
4 | "type": "autogenerated",
5 | "dirName": "."
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/docs/versioned_sidebars/version-3.1-sidebars.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": [
3 | {
4 | "type": "autogenerated",
5 | "dirName": "."
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/docs/versioned_sidebars/version-3.2-sidebars.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": [
3 | {
4 | "type": "autogenerated",
5 | "dirName": "."
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/docs/versions.json:
--------------------------------------------------------------------------------
1 | [
2 | "3.2",
3 | "3.1",
4 | "2.1"
5 | ]
6 |
--------------------------------------------------------------------------------
/example/.buckconfig:
--------------------------------------------------------------------------------
1 |
2 | [android]
3 | target = Google Inc.:Google APIs:23
4 |
5 | [maven_repositories]
6 | central = https://repo1.maven.org/maven2
7 |
--------------------------------------------------------------------------------
/example/.bundle/config:
--------------------------------------------------------------------------------
1 | BUNDLE_PATH: "vendor/bundle"
2 | BUNDLE_FORCE_RUBY_PLATFORM: 1
3 |
--------------------------------------------------------------------------------
/example/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | parser: '@typescript-eslint/parser', // Specifies the ESLint parser
4 | extends: [
5 | 'eslint:recommended',
6 | 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
7 | 'plugin:react-hooks/recommended',
8 | ],
9 | parserOptions: {
10 | ecmaVersion: 2017, // Allows for the parsing of modern ECMAScript features
11 | sourceType: 'module', // Allows for the use of imports
12 | },
13 | rules: {
14 | // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 |
24 | # Android/IntelliJ
25 | #
26 | build/
27 | .idea
28 | .gradle
29 | local.properties
30 | *.iml
31 |
32 | # node.js
33 | #
34 | node_modules/
35 | npm-debug.log
36 | yarn-error.log
37 |
38 | # BUCK
39 | buck-out/
40 | \.buckd/
41 | *.keystore
42 | !debug.keystore
43 |
44 | # fastlane
45 | #
46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47 | # screenshots whenever they are needed.
48 | # For more information about the recommended setup visit:
49 | # https://docs.fastlane.tools/best-practices/source-control/
50 |
51 | */fastlane/report.xml
52 | */fastlane/Preview.html
53 | */fastlane/screenshots
54 |
55 | # Bundle artifact
56 | *.jsbundle
57 |
58 | # CocoaPods
59 | /ios/Pods/
60 |
61 | # Gemfile
62 | ios/vendor/
63 | vendor/
64 |
--------------------------------------------------------------------------------
/example/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | singleQuote: true,
3 | }
4 |
--------------------------------------------------------------------------------
/example/.ruby-version:
--------------------------------------------------------------------------------
1 | 2.7.4
2 |
--------------------------------------------------------------------------------
/example/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/example/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4 | ruby '3.0.5'
5 |
6 | gem 'cocoapods', '~> 1.11', '>= 1.11.2'
7 | gem 'rexml'
--------------------------------------------------------------------------------
/example/__tests__/App-test.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import React from 'react'
6 | import 'react-native'
7 | import App from '../src/App'
8 |
9 | // Note: test renderer must be required after react-native.
10 | import renderer from 'react-test-renderer'
11 |
12 | it('renders correctly', () => {
13 | renderer.create()
14 | })
15 |
--------------------------------------------------------------------------------
/example/android/app/_BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12 |
13 | lib_deps = []
14 |
15 | create_aar_targets(glob(["libs/*.aar"]))
16 |
17 | create_jar_targets(glob(["libs/*.jar"]))
18 |
19 | android_library(
20 | name = "all-libs",
21 | exported_deps = lib_deps,
22 | )
23 |
24 | android_library(
25 | name = "app-code",
26 | srcs = glob([
27 | "src/main/java/**/*.java",
28 | ]),
29 | deps = [
30 | ":all-libs",
31 | ":build_config",
32 | ":res",
33 | ],
34 | )
35 |
36 | android_build_config(
37 | name = "build_config",
38 | package = "com.example",
39 | )
40 |
41 | android_resource(
42 | name = "res",
43 | package = "com.example",
44 | res = "src/main/res",
45 | )
46 |
47 | android_binary(
48 | name = "app",
49 | keystore = "//android/keystores:debug",
50 | manifest = "src/main/AndroidManifest.xml",
51 | package_type = "debug",
52 | deps = [
53 | ":app-code",
54 | ],
55 | )
56 |
--------------------------------------------------------------------------------
/example/android/app/build_defs.bzl:
--------------------------------------------------------------------------------
1 | """Helper definitions to glob .aar and .jar targets"""
2 |
3 | def create_aar_targets(aarfiles):
4 | for aarfile in aarfiles:
5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6 | lib_deps.append(":" + name)
7 | android_prebuilt_aar(
8 | name = name,
9 | aar = aarfile,
10 | )
11 |
12 | def create_jar_targets(jarfiles):
13 | for jarfile in jarfiles:
14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15 | lib_deps.append(":" + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
--------------------------------------------------------------------------------
/example/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whitehorse21/react-native-track-player/8b0cb1089409eff451fa252f2ba68b3c09f638eb/example/android/app/debug.keystore
--------------------------------------------------------------------------------
/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.facebook.react.ReactActivity;
6 | import com.facebook.react.ReactActivityDelegate;
7 | import com.facebook.react.ReactRootView;
8 |
9 | public class MainActivity extends ReactActivity {
10 |
11 | /**
12 | * Returns the name of the main component registered from JavaScript. This is used to schedule
13 | * rendering of the component.
14 | */
15 | @Override
16 | protected String getMainComponentName() {
17 | return "example";
18 | }
19 |
20 | /**
21 | * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
22 | * you can specify the rendered you wish to use (Fabric or the older renderer).
23 | */
24 | @Override
25 | protected ReactActivityDelegate createReactActivityDelegate() {
26 | return new MainActivityDelegate(this, getMainComponentName());
27 | }
28 |
29 | public static class MainActivityDelegate extends ReactActivityDelegate {
30 | public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
31 | super(activity, mainComponentName);
32 | }
33 |
34 | @Override
35 | protected ReactRootView createRootView() {
36 | ReactRootView reactRootView = new ReactRootView(getContext());
37 | // If you opted-in for the New Architecture, we enable the Fabric Renderer.
38 | reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
39 | return reactRootView;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/newarchitecture/components/MainComponentsRegistry.java:
--------------------------------------------------------------------------------
1 | package com.example.newarchitecture.components;
2 |
3 | import com.facebook.jni.HybridData;
4 | import com.facebook.proguard.annotations.DoNotStrip;
5 | import com.facebook.react.fabric.ComponentFactory;
6 | import com.facebook.soloader.SoLoader;
7 |
8 | /**
9 | * Class responsible to load the custom Fabric Components. This class has native methods and needs a
10 | * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
11 | * folder for you).
12 | *
13 | *