Skip to content

Commit 4c822d1

Browse files
maciejmakowski2003Maciej Makowskimdydek
authored
docs: added info note about plugin (#472)
* docs: added info note plugin * fix: naming * docs: removed info about connecting to only node from web audio api coverage * fix: small fix --------- Co-authored-by: Maciej Makowski <[email protected]> Co-authored-by: michal <[email protected]>
1 parent c2e2a44 commit 4c822d1

File tree

4 files changed

+73
-11
lines changed

4 files changed

+73
-11
lines changed

packages/audiodocs/docs/fundamentals/getting-started.mdx

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,64 @@ Install the `react-native-audio-api` package from npm:
3535
</TabItem>
3636
</Tabs>
3737

38-
### Step 2: Wrap metro config with Audio API wrapper
38+
### Step 2: Add Audio API expo plugin (optional)
39+
40+
Add `react-native-audio-api` expo plugin to your `app.json` or `app.config.js`.
41+
42+
<details>
43+
<summary>app.json</summary>
44+
```javascript
45+
{
46+
"plugins": [
47+
[
48+
"react-native-audio-api",
49+
{
50+
"iosBackgroundMode": true,
51+
"androidPermissions" : [
52+
"android.permission.MODIFY_AUDIO_SETTINGS",
53+
"android.permission.FOREGROUND_SERVICE",
54+
"android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"
55+
],
56+
"androidForegroundService": true,
57+
"androidFSTypes": [
58+
"mediaPlayback"
59+
]
60+
}
61+
]
62+
]
63+
}
64+
```
65+
</details>
66+
67+
<details>
68+
<summary>app.config.js</summary>
69+
```javascript
70+
export default {
71+
...
72+
"plugins": [
73+
[
74+
"react-native-audio-api",
75+
{
76+
"iosBackgroundMode": true,
77+
"androidPermissions" : [
78+
"android.permission.MODIFY_AUDIO_SETTINGS",
79+
"android.permission.FOREGROUND_SERVICE",
80+
"android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"
81+
],
82+
"androidForegroundService": true,
83+
"androidFSTypes": [
84+
"mediaPlayback"
85+
]
86+
}
87+
]
88+
]
89+
};
90+
```
91+
</details>
92+
93+
Read more about plugin [here](/other/audio-api-plugin)!
94+
95+
### Step 3: Wrap metro config with Audio API wrapper (recommended)
3996

4097
Wrap your existing Metro configuration in the `metro.config.js` file with the `wrapWithAudioAPIMetroConfig` function:
4198

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
id: audio-api-plugin
3+
sidebar_label: Audio API Expo plugin
4+
sidebar_position: 3
5+
---
6+
7+
# 🚧 Audio API Expo plugin 🚧

packages/audiodocs/docs/other/web-audio-api-coverage.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ sidebar_position: 2
1414
| AudioBuffer ||
1515
| AudioBufferSourceNode ||
1616
| AudioDestinationNode ||
17-
| AudioNode || `connect` to `AudioNode` is only possible |
17+
| AudioNode ||
1818
| AudioParam ||
1919
| AudioScheduledSourceNode ||
2020
| BiquadFilterNode ||

packages/react-native-audio-api/src/plugin/withAudioAPI.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ const pkg = require('react-native-audio-api/package.json');
99

1010
interface Options {
1111
iosBackgroundMode: boolean;
12+
androidPermissions: string[];
1213
androidForegroundService: boolean;
13-
androidFSPermissions: string[];
1414
androidFSTypes: string[];
1515
}
1616

1717
const withDefaultOptions = (options: Partial<Options>): Options => {
1818
return {
1919
iosBackgroundMode: true,
20-
androidForegroundService: true,
21-
androidFSPermissions: [
20+
androidPermissions: [
2221
'android.permission.FOREGROUND_SERVICE',
2322
'android.permission.WAKE_LOCK',
2423
],
24+
androidForegroundService: true,
2525
androidFSTypes: ['mediaPlayback'],
2626
...options,
2727
};
@@ -41,12 +41,9 @@ const withBackgroundAudio: ConfigPlugin = (config) => {
4141

4242
const withAndroidPermissions: ConfigPlugin<Options> = (
4343
config,
44-
{ androidFSPermissions }: Options
44+
{ androidPermissions }: Options
4545
) => {
46-
return AndroidConfig.Permissions.withPermissions(
47-
config,
48-
androidFSPermissions
49-
);
46+
return AndroidConfig.Permissions.withPermissions(config, androidPermissions);
5047
};
5148

5249
const withForegroundService: ConfigPlugin<Options> = (
@@ -87,8 +84,9 @@ const withAudioAPI: ConfigPlugin<Options> = (config, optionsIn) => {
8784
config = withBackgroundAudio(config);
8885
}
8986

87+
config = withAndroidPermissions(config, options);
88+
9089
if (options.androidForegroundService) {
91-
config = withAndroidPermissions(config, options);
9290
config = withForegroundService(config, options);
9391
}
9492

0 commit comments

Comments
 (0)