react-native-volume-control
Control device volume for iOS and Android.
First installation step (applied for both iOS & Android)
$ npm install react-native-volume-control --save
2. Automatic installation
$ react-native link react-native-volume-control
3. Manual installation
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-volume-control
=>ios
- add
ReactNativeVolumeControl.xcodeproj
to the Libraries folder in your XCode project
- add
- In XCode, in the project navigator, select your project. Add
libReactNativeVolumeControl.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)
Android
Manual installation
- In Android Studio open
Module Settings
and add a Gradle Project. - Look for
react-native-volume-control
android folder and link with a Gradle. - Open MyApplication.java from main app and put the ReactNativeVolumeControllerPackage
@Override protected List<ReactPackage> { return Arrays.<ReactPackage>; }
Usage
This component only exposes an api to update device volume and listens for VolumeChanged
events via hardware buttons. There is no UI component included.
// Other imports... ;; Component state = volume: 0 async { this; // Add and store event listener thisvolEvent = VolumeControlEvents; } // Updates Slider UI when hardware buttons change volume { this; }; // Updates device volume { VolumeControl; } { // remove event listener thisvolEvent; } { return <Slider value=thisstatevolume onValueChange=thissliderChange // Other props /> }