@@ -4,4 +4,124 @@ sidebar_label: Audio API Expo plugin
44sidebar_position : 3
55---
66
7- # 🚧 Audio API Expo plugin 🚧
7+ # Audio API Expo plugin
8+
9+ ## What is Audio API Expo plugin
10+
11+ The Audio API Expo plugin allows to set certain permissions and
12+ background audio related settings in developer friendly way.
13+
14+ <details >
15+ <summary >Type definitions</summary >
16+
17+ ``` typescript
18+ interface Options {
19+ iosBackgroundMode: boolean ;
20+ androidPermissions: string [];
21+ androidForegroundService: boolean ;
22+ androidFSTypes: string [];
23+ }
24+ ```
25+
26+ </details >
27+
28+ ## How to use it?
29+
30+ Add ` react-native-audio-api ` expo plugin to your ` app.json ` or ` app.config.js ` .
31+
32+ <details >
33+ <summary >app.json</summary >
34+ ``` javascript
35+ {
36+ " plugins" : [
37+ [
38+ " react-native-audio-api" ,
39+ {
40+ " iosBackgroundMode" : true ,
41+ " androidPermissions" : [
42+ " android.permission.MODIFY_AUDIO_SETTINGS" ,
43+ " android.permission.FOREGROUND_SERVICE" ,
44+ " android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"
45+ ],
46+ " androidForegroundService" : true ,
47+ " androidFSTypes" : [
48+ " mediaPlayback"
49+ ]
50+ }
51+ ]
52+ ]
53+ }
54+ ```
55+ </details >
56+
57+ <details >
58+ <summary >app.config.js</summary >
59+ ``` javascript
60+ export default {
61+ ...
62+ " plugins" : [
63+ [
64+ " react-native-audio-api" ,
65+ {
66+ " iosBackgroundMode" : true ,
67+ " androidPermissions" : [
68+ " android.permission.MODIFY_AUDIO_SETTINGS" ,
69+ " android.permission.FOREGROUND_SERVICE" ,
70+ " android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"
71+ ],
72+ " androidForegroundService" : true ,
73+ " androidFSTypes" : [
74+ " mediaPlayback"
75+ ]
76+ }
77+ ]
78+ ]
79+ };
80+ ```
81+ </details >
82+
83+ ## Options
84+
85+ ### iosBackgroundMode
86+
87+ Defaults to ` true ` .
88+
89+ Allows app to play audio in the background on iOS.
90+
91+ ### androidPermissions
92+
93+ Defaults to
94+
95+ ```
96+ [
97+ 'android.permission.FOREGROUND_SERVICE',
98+ 'android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK'
99+ ]
100+ ```
101+
102+ Allows to specify certain android app permissions to apply.
103+
104+ ##### Permissions:
105+
106+ - ` android.permission.FOREGROUND_SERVICE ` - Allows an app to run a Foreground Service
107+
108+ - ` android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK ` - Allows an app to run a Foreground Service specifically for playing audio or video.
109+
110+ - ` android.permission.MODIFY_AUDIO_SETTINGS ` - Allows an app to modify global audio settings.
111+
112+ - ` android.permission.INTERNET ` - Allows applications to open network sockets.
113+
114+ ### androidForegroundService
115+
116+ Defaults to true
117+
118+ Allows app to use Foreground Service options specified by user,
119+ it permits app to play audio in the background on Android.
120+
121+ ### androidFSTypes
122+
123+ Allows user to specify appropriate Foreground Service type.
124+
125+ ##### Types description
126+
127+ - ` mediaPlayback ` - Continue audio or video playback from the background.
0 commit comments