react-native-media 2.5.5
A react-native library to:
- play audio
- record audio
- get system directories
- handle device behavior
- proximity events
- keep awake
- handle voip incoming call
Getting started
$ npm install react-native-media --save
#or
$ yarn add react-native-media
Automatic installation
$ react-native link react-native-media
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-media
and addRNReactNativeMedia.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNReactNativeMedia.a
to your project'sBuild Phases
➜Link Binary With Libraries
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add the following packages to the imports at the top of the file
import com.media.module.MediaPackage;
- Add the follow lines to the list returned by the
getPackages()
method
new MediaPackage()
- Append the following lines to
android/settings.gradle
:
include ':react-native-media'
project(':react-native-media').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-media/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:
compile project(':react-native-media')
Don't forget
iOS
- Built with AVAudioPlayer and AVAudioRecorder.
- Add
mute.caf
from the library to your project bundle- Project Navigator > [YOUR PROJECT NAME] > Build Phases > Copy Bundle Resources
- Add in
info.plist
the following configuration:- Key: Privacy - Microphone Usage Description.
- Type: String.
- Value: This sample uses the microphone to record your speech and convert it to text.
The Components
AudioManager
Use to play audio, stop, pause, track time and others. See complete documentation here
DeviceManager
Use to manage the device and OS resources. See complete documentation here
DirectoryManager
Use to get the available OS directories paths. See complete documentation here
RecorderManager
Use to record external audio using the microphone. See complete documentation here
CallManager
Use to handle incoming call: See complete documentation here