Commit 17185f87 authored by 刘阳's avatar 刘阳

Initial commit

parents
The MIT License (MIT)
Copyright (c) [2016] [Joshua Sierles]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Record audio in iOS or Android React Native apps.
## BREAKING CHANGES
For React Native >= 0.47.2, use v3.4.0 and up.
For React Native >= 0.40, use v3.1.0 up til 3.2.2.
For React Native <= 0.39, use v3.0.0 or lower.
v4.0 introduced a breaking change to the API to introduce distinct pause and resume methods.
v3.x removed playback support in favor of using more mature libraries like [react-native-sound](https://github.com/zmxv/react-native-sound). If you need to play
from the network, please submit a PR to that project or try `react-native-video`.
### Installation
Install the npm package and link it to your project:
```
npm install react-native-audio --save
react-native link react-native-audio
```
On *iOS* you need to add a usage description to `Info.plist`:
```
<key>NSMicrophoneUsageDescription</key>
<string>This sample uses the microphone to record your speech and convert it to text.</string>
```
On *Android* you need to add a permission to `AndroidManifest.xml`:
```
<uses-permission android:name="android.permission.RECORD_AUDIO" />
```
### Manual Installation
This is not necessary if you have used `react-native link`
#### Android
Edit `android/settings.gradle` to declare the project directory:
```
include ':react-native-audio'
project(':react-native-audio').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-audio/android')
```
Edit `android/app/build.gradle` to declare the project dependency:
```
dependencies {
...
compile project(':react-native-audio')
}
```
Edit `android/app/src/main/java/.../MainApplication.java` to register the native module:
```java
...
import com.rnim.rn.audio.ReactNativeAudioPackage; // <-- New
...
public class MainApplication extends Application implements ReactApplication {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeAudioPackage() // <-- New
);
}
```
#### iOS
Drag `node_modules/react-native-audio/ios/RNAudio.xcoderproj` into your project's Libraries on Xcode.
Add `libRNAudio.a` into Link Binary With Libraries from Xcode - Build Phases.
### Running the Sample App
In the `AudioExample` directory:
```
npm install
react-native run-ios
react-native run-android
```
### Usage
To record in AAC format, at 22050 KHz in low quality mono:
```
import {AudioRecorder, AudioUtils} from 'react-native-audio';
let audioPath = AudioUtils.DocumentDirectoryPath + '/test.aac';
AudioRecorder.prepareRecordingAtPath(audioPath, {
SampleRate: 22050,
Channels: 1,
AudioQuality: "Low",
AudioEncoding: "aac"
});
```
`AudioQuality` is supported on iOS. `Low`, `Medium`, and `High` will translate to `AVAudioQualityLow`, `AVAudioQualityMedium`, and `AVAudioQualityHigh` respectively.
#### Cross-platform options
```
SampleRate: int
Channels: int
AudioQuality: string
AudioEncoding: string
IncludeBase64: boolean
```
Encodings supported on iOS: `lpcm, ima4, aac, MAC3, MAC6, ulaw, alaw, mp1, mp2, alac, amr`
Encodings supported on Android: `aac, aac_eld, amr_nb, amr_wb, he_aac, vorbis`
Use the `IncludeBase64` boolean to include the `base64` encoded recording on the `AudioRecorder.onFinished` event object. Please use it with care: passing large amounts of data over the bridge, from native to Javascript, can use lots of memory and cause slow performance.
If you want to upload the audio, it might be best to do it on the native thread with a package like [React Native Fetch Blob](https://github.com/joltup/react-native-fetch-blob).
#### iOS-only fields
Use `MeteringEnabled` boolean to enable audio metering. The following values are available on the recording progress object.
| Name | Related AVAudioRecorder parameter | Description |
|------|-----------------------------------|-------------|
|currentMetering| averagePowerForChannel | The current average power, in decibels, for the sound being recorded. A return value of 0 dB indicates full scale, or maximum power; a return value of -160 dB indicates minimum power (that is, near silence). If the signal provided to the audio recorder exceeds ±full scale, then the return value may exceed 0 (that is, it may enter the positive range).|
|currentPeakMetering | peakPowerForChannel | The current peak power, in decibels, for the sound being recorded. A return value of 0 dB indicates full scale, or maximum power; a return value of -160 dB indicates minimum power (that is, near silence). If the signal provided to the audio recorder exceeds ±full scale, then the return value may exceed 0 (that is, it may enter the positive range).|
For example:
```js
AudioRecorder.onProgress = (data) => {
console.log(data.currentMetering, data.currentPeakMetering)
};
```
#### Android-only fields
AudioEncodingBitRate: int
OutputFormat: string, `mpeg_4, aac_adts, amr_nb, amr_wb, three_gpp, webm`
AudioSource: int (constants) (Possible values: AudioSource.DEFAULT, AudioSource.MIC, AudioSource.VOICE_UPLINK, AudioSource.VOICE_DOWNLINK, AudioSource.VOICE_CALL, AudioSource.CAMCORDER, AudioSource.VOICE_RECOGNITION, AudioSource.VOICE_COMMUNICATION, AudioSource.REMOTE_SUBMIX, AudioSource.UNPROCESSED)
See [the example](https://github.com/jsierles/react-native-audio/blob/master/AudioExample/index.ios.js) for more details. For playing audio check out [React Native Sound](https://github.com/zmxv/react-native-sound)
MP3 recording is *not supported* since the underlying platforms do not support it.
Thanks to Brent Vatne, Johannes Lumpe, Kureev Alexey, Matthew Hartman and Rakan Nimer for their assistance.
Progress tracking code borrowed from https://github.com/brentvatne/react-native-video.
require 'json'
Pod::Spec.new do |s|
# NPM package specification
package = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'package.json')))
s.name = 'RNAudio'
s.version = package['version']
s.license = 'MIT'
s.summary = 'Audio recorder library for React Native'
s.author = { 'Joshua Sierles' => 'joshua@diluvia.net' }
s.homepage = "https://github.com/jsierles/react-native-audio"
s.source = { :git => 'https://github.com/jsierles/react-native-audio.git', :tag => "v#{s.version}"}
s.platform = :ios, '8.0'
s.preserve_paths = '*.js'
s.frameworks = 'AVFoundation'
s.dependency 'React'
s.source_files = 'ios/AudioRecorderManager.{h,m}'
end
<?xml version="1.0" encoding="UTF-8"?>
<module external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
apply plugin: 'com.android.library'
def DEFAULT_COMPILE_SDK_VERSION = 23
def DEFAULT_BUILD_TOOLS_VERSION = "23.0.2"
def DEFAULT_TARGET_SDK_VERSION = 23
def DEFAULT_SUPPORT_LIB_VERSION = "23.1.0"
android {
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 16
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
}
def supportVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:+"
implementation 'com.facebook.react:react-native:+'
}
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":react-native-audio" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/../../../android" external.system.id="GRADLE" external.system.module.group="reactNativeAudioTest" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":react-native-audio" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
<option name="LIBRARY_PROJECT" value="true" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="okio-1.9.0" level="project" />
<orderEntry type="library" exported="" name="imagepipeline-0.11.0" level="project" />
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" name="imagepipeline-base-0.11.0" level="project" />
<orderEntry type="library" exported="" name="fresco-0.11.0" level="project" />
<orderEntry type="library" exported="" name="drawee-0.11.0" level="project" />
<orderEntry type="library" exported="" name="soloader-0.1.0" level="project" />
<orderEntry type="library" exported="" name="jsr305-3.0.0" level="project" />
<orderEntry type="library" exported="" name="jackson-core-2.2.3" level="project" />
<orderEntry type="library" exported="" name="bolts-tasks-1.4.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="okhttp-urlconnection-3.4.1" level="project" />
<orderEntry type="library" exported="" name="okhttp-ws-3.4.1" level="project" />
<orderEntry type="library" exported="" name="android-jsc-r174650" level="project" />
<orderEntry type="library" exported="" name="okhttp-3.4.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.2.1" level="project" />
<orderEntry type="library" exported="" name="imagepipeline-okhttp3-0.11.0" level="project" />
<orderEntry type="library" exported="" name="react-native-0.32.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.2.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="fbcore-0.11.0" level="project" />
</component>
</module>
\ No newline at end of file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rnim.rn.audio">
</manifest>
package com.rnim.rn.audio;
import android.Manifest;
import android.content.Context;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Environment;
import android.media.MediaRecorder;
import android.media.AudioManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.Base64;
import android.util.Log;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import java.io.FileInputStream;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.lang.IllegalAccessException;
import java.lang.NoSuchMethodException;
class AudioRecorderManager extends ReactContextBaseJavaModule {
private static final String TAG = "ReactNativeAudio";
private static final String DocumentDirectoryPath = "DocumentDirectoryPath";
private static final String PicturesDirectoryPath = "PicturesDirectoryPath";
private static final String MainBundlePath = "MainBundlePath";
private static final String CachesDirectoryPath = "CachesDirectoryPath";
private static final String LibraryDirectoryPath = "LibraryDirectoryPath";
private static final String MusicDirectoryPath = "MusicDirectoryPath";
private static final String DownloadsDirectoryPath = "DownloadsDirectoryPath";
private Context context;
private MediaRecorder recorder;
private String currentOutputFile;
private boolean isRecording = false;
private boolean isPaused = false;
private boolean includeBase64 = false;
private Timer timer;
private StopWatch stopWatch;
private boolean isPauseResumeCapable = false;
private Method pauseMethod = null;
private Method resumeMethod = null;
public AudioRecorderManager(ReactApplicationContext reactContext) {
super(reactContext);
this.context = reactContext;
stopWatch = new StopWatch();
isPauseResumeCapable = Build.VERSION.SDK_INT > Build.VERSION_CODES.M;
if (isPauseResumeCapable) {
try {
pauseMethod = MediaRecorder.class.getMethod("pause");
resumeMethod = MediaRecorder.class.getMethod("resume");
} catch (NoSuchMethodException e) {
Log.d("ERROR", "Failed to get a reference to pause and/or resume method");
}
}
}
@Override
public Map<String, Object> getConstants() {
Map<String, Object> constants = new HashMap<>();
constants.put(DocumentDirectoryPath, this.getReactApplicationContext().getFilesDir().getAbsolutePath());
constants.put(PicturesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
constants.put(MainBundlePath, "");
constants.put(CachesDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath());
constants.put(LibraryDirectoryPath, "");
constants.put(MusicDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath());
constants.put(DownloadsDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath());
return constants;
}
@Override
public String getName() {
return "AudioRecorderManager";
}
@ReactMethod
public void checkAuthorizationStatus(Promise promise) {
int permissionCheck = ContextCompat.checkSelfPermission(getCurrentActivity(),
Manifest.permission.RECORD_AUDIO);
boolean permissionGranted = permissionCheck == PackageManager.PERMISSION_GRANTED;
promise.resolve(permissionGranted);
}
@ReactMethod
public void prepareRecordingAtPath(String recordingPath, ReadableMap recordingSettings, Promise promise) {
if (isRecording){
logAndRejectPromise(promise, "INVALID_STATE", "Please call stopRecording before starting recording");
}
File destFile = new File(recordingPath);
if (destFile.getParentFile() != null) {
destFile.getParentFile().mkdirs();
}
recorder = new MediaRecorder();
try {
recorder.setAudioSource(recordingSettings.getInt("AudioSource"));
int outputFormat = getOutputFormatFromString(recordingSettings.getString("OutputFormat"));
recorder.setOutputFormat(outputFormat);
int audioEncoder = getAudioEncoderFromString(recordingSettings.getString("AudioEncoding"));
recorder.setAudioEncoder(audioEncoder);
recorder.setAudioSamplingRate(recordingSettings.getInt("SampleRate"));
recorder.setAudioChannels(recordingSettings.getInt("Channels"));
recorder.setAudioEncodingBitRate(recordingSettings.getInt("AudioEncodingBitRate"));
recorder.setOutputFile(destFile.getPath());
includeBase64 = recordingSettings.getBoolean("IncludeBase64");
}
catch(final Exception e) {
logAndRejectPromise(promise, "COULDNT_CONFIGURE_MEDIA_RECORDER" , "Make sure you've added RECORD_AUDIO permission to your AndroidManifest.xml file "+e.getMessage());
return;
}
currentOutputFile = recordingPath;
try {
recorder.prepare();
promise.resolve(currentOutputFile);
} catch (final Exception e) {
logAndRejectPromise(promise, "COULDNT_PREPARE_RECORDING_AT_PATH "+recordingPath, e.getMessage());
}
}
private int getAudioEncoderFromString(String audioEncoder) {
switch (audioEncoder) {
case "aac":
return MediaRecorder.AudioEncoder.AAC;
case "aac_eld":
return MediaRecorder.AudioEncoder.AAC_ELD;
case "amr_nb":
return MediaRecorder.AudioEncoder.AMR_NB;
case "amr_wb":
return MediaRecorder.AudioEncoder.AMR_WB;
case "he_aac":
return MediaRecorder.AudioEncoder.HE_AAC;
case "vorbis":
return MediaRecorder.AudioEncoder.VORBIS;
default:
Log.d("INVALID_AUDIO_ENCODER", "USING MediaRecorder.AudioEncoder.DEFAULT instead of "+audioEncoder+": "+MediaRecorder.AudioEncoder.DEFAULT);
return MediaRecorder.AudioEncoder.DEFAULT;
}
}
private int getOutputFormatFromString(String outputFormat) {
switch (outputFormat) {
case "mpeg_4":
return MediaRecorder.OutputFormat.MPEG_4;
case "aac_adts":
return MediaRecorder.OutputFormat.AAC_ADTS;
case "amr_nb":
return MediaRecorder.OutputFormat.AMR_NB;
case "amr_wb":
return MediaRecorder.OutputFormat.AMR_WB;
case "three_gpp":
return MediaRecorder.OutputFormat.THREE_GPP;
case "webm":
return MediaRecorder.OutputFormat.WEBM;
default:
Log.d("INVALID_OUPUT_FORMAT", "USING MediaRecorder.OutputFormat.DEFAULT : "+MediaRecorder.OutputFormat.DEFAULT);
return MediaRecorder.OutputFormat.DEFAULT;
}
}
@ReactMethod
public void startRecording(Promise promise){
if (recorder == null){
logAndRejectPromise(promise, "RECORDING_NOT_PREPARED", "Please call prepareRecordingAtPath before starting recording");
return;
}
if (isRecording){
logAndRejectPromise(promise, "INVALID_STATE", "Please call stopRecording before starting recording");
return;
}
recorder.start();
stopWatch.reset();
stopWatch.start();
isRecording = true;
isPaused = false;
startTimer();
promise.resolve(currentOutputFile);
}
@ReactMethod
public void stopRecording(Promise promise){
if (!isRecording){
logAndRejectPromise(promise, "INVALID_STATE", "Please call startRecording before stopping recording");
return;
}
stopTimer();
isRecording = false;
isPaused = false;
try {
recorder.stop();
recorder.release();
stopWatch.stop();
}
catch (final RuntimeException e) {
// https://developer.android.com/reference/android/media/MediaRecorder.html#stop()
logAndRejectPromise(promise, "RUNTIME_EXCEPTION", "No valid audio data received. You may be using a device that can't record audio.");
return;
}
finally {
recorder = null;
}
promise.resolve(currentOutputFile);
WritableMap result = Arguments.createMap();
result.putString("status", "OK");
result.putString("audioFileURL", "file://" + currentOutputFile);
String base64 = "";
if (includeBase64) {
try {
InputStream inputStream = new FileInputStream(currentOutputFile);
byte[] bytes;
byte[] buffer = new byte[8192];
int bytesRead;
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
while ((bytesRead = inputStream.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
} catch (IOException e) {
Log.e(TAG, "FAILED TO PARSE FILE");
}
bytes = output.toByteArray();
base64 = Base64.encodeToString(bytes, Base64.DEFAULT);
} catch(FileNotFoundException e) {
Log.e(TAG, "FAILED TO FIND FILE");
}
}
result.putString("base64", base64);
sendEvent("recordingFinished", result);
}
@ReactMethod
public void pauseRecording(Promise promise) {
if (!isPauseResumeCapable || pauseMethod==null) {
logAndRejectPromise(promise, "RUNTIME_EXCEPTION", "Method not available on this version of Android.");
return;
}
if (!isPaused) {
try {
pauseMethod.invoke(recorder);
stopWatch.stop();
} catch (InvocationTargetException | RuntimeException | IllegalAccessException e) {
e.printStackTrace();
logAndRejectPromise(promise, "RUNTIME_EXCEPTION", "Method not available on this version of Android.");
return;
}
}
isPaused = true;
promise.resolve(null);
}
@ReactMethod
public void resumeRecording(Promise promise) {
if (!isPauseResumeCapable || resumeMethod == null) {
logAndRejectPromise(promise, "RUNTIME_EXCEPTION", "Method not available on this version of Android.");
return;
}
if (isPaused) {
try {
resumeMethod.invoke(recorder);
stopWatch.start();
} catch (InvocationTargetException | RuntimeException | IllegalAccessException e) {
e.printStackTrace();
logAndRejectPromise(promise, "RUNTIME_EXCEPTION", "Method not available on this version of Android.");
return;
}
}
isPaused = false;
promise.resolve(null);
}
private void startTimer(){
timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (!isPaused) {
WritableMap body = Arguments.createMap();
body.putDouble("currentTime", stopWatch.getTimeSeconds());
sendEvent("recordingProgress", body);
}
}
}, 0, 1000);
}
private void stopTimer(){
if (timer != null) {
timer.cancel();
timer.purge();
timer = null;
}
}
private void sendEvent(String eventName, Object params) {
getReactApplicationContext()
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
}
private void logAndRejectPromise(Promise promise, String errorCode, String errorMessage) {
Log.e(TAG, errorMessage);
promise.reject(errorCode, errorMessage);
}
}
package com.rnim.rn.audio;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ReactNativeAudioPackage implements ReactPackage {
/**
* @param reactContext react application context that can be used to create modules
* @return list of native modules to register with the newly created catalyst instance
*/
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new AudioRecorderManager(reactContext));
return modules;
}
/**
* @param reactContext
* @return a list of view managers that should be registered with {UIManagerModule}
*/
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
package com.rnim.rn.audio;
import java.lang.System;
import java.lang.Thread;
public class StopWatch {
private long start;
private float elapsedTime = 0;
private boolean paused = true;
public StopWatch() {
}
public void start() {
start = System.currentTimeMillis();
paused = false;
}
public float stop() {
if (!paused) {
long now = System.currentTimeMillis();
elapsedTime += (now - start) / 1000f;
paused = true;
}
return elapsedTime;
}
public void reset() {
start = 0;
elapsedTime = 0;
paused = true;
}
public float getTimeSeconds() {
float seconds;
if (paused) {
seconds = elapsedTime;
} else {
long now = System.currentTimeMillis();
seconds = elapsedTime + (now - start) / 1000f;
}
return seconds;
}
}
\ No newline at end of file
'use strict';
import React from "react";
import ReactNative, {
NativeModules,
NativeAppEventEmitter,
DeviceEventEmitter,
PermissionsAndroid,
Platform
} from "react-native";
var AudioRecorderManager = NativeModules.AudioRecorderManager;
var AudioRecorder = {
prepareRecordingAtPath: function(path, options) {
if (this.progressSubscription) this.progressSubscription.remove();
this.progressSubscription = NativeAppEventEmitter.addListener('recordingProgress',
(data) => {
if (this.onProgress) {
this.onProgress(data);
}
}
);
if (this.finishedSubscription) this.finishedSubscription.remove();
this.finishedSubscription = NativeAppEventEmitter.addListener('recordingFinished',
(data) => {
if (this.onFinished) {
this.onFinished(data);
}
}
);
var defaultOptions = {
SampleRate: 44100.0,
Channels: 2,
AudioQuality: 'High',
AudioEncoding: 'ima4',
OutputFormat: 'mpeg_4',
MeteringEnabled: false,
MeasurementMode: false,
AudioEncodingBitRate: 32000,
IncludeBase64: false,
AudioSource: 0
};
var recordingOptions = {...defaultOptions, ...options};
if (Platform.OS === 'ios') {
AudioRecorderManager.prepareRecordingAtPath(
path,
recordingOptions.SampleRate,
recordingOptions.Channels,
recordingOptions.AudioQuality,
recordingOptions.AudioEncoding,
recordingOptions.MeteringEnabled,
recordingOptions.MeasurementMode,
recordingOptions.IncludeBase64
);
} else {
return AudioRecorderManager.prepareRecordingAtPath(path, recordingOptions);
}
},
startRecording: function() {
return AudioRecorderManager.startRecording();
},
pauseRecording: function() {
return AudioRecorderManager.pauseRecording();
},
resumeRecording: function() {
return AudioRecorderManager.resumeRecording();
},
stopRecording: function() {
return AudioRecorderManager.stopRecording();
},
checkAuthorizationStatus: AudioRecorderManager.checkAuthorizationStatus,
requestAuthorization: () => {
if (Platform.OS === 'ios')
return AudioRecorderManager.requestAuthorization();
else
return new Promise((resolve, reject) => {
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO
).then(result => {
if (result == PermissionsAndroid.RESULTS.GRANTED || result == true)
resolve(true);
else
resolve(false)
})
});
},
removeListeners: function() {
if (this.progressSubscription) this.progressSubscription.remove();
if (this.finishedSubscription) this.finishedSubscription.remove();
},
};
let AudioUtils = {};
let AudioSource = {};
if (Platform.OS === 'ios') {
AudioUtils = {
MainBundlePath: AudioRecorderManager.MainBundlePath,
CachesDirectoryPath: AudioRecorderManager.NSCachesDirectoryPath,
DocumentDirectoryPath: AudioRecorderManager.NSDocumentDirectoryPath,
LibraryDirectoryPath: AudioRecorderManager.NSLibraryDirectoryPath,
};
} else if (Platform.OS === 'android') {
AudioUtils = {
MainBundlePath: AudioRecorderManager.MainBundlePath,
CachesDirectoryPath: AudioRecorderManager.CachesDirectoryPath,
DocumentDirectoryPath: AudioRecorderManager.DocumentDirectoryPath,
LibraryDirectoryPath: AudioRecorderManager.LibraryDirectoryPath,
PicturesDirectoryPath: AudioRecorderManager.PicturesDirectoryPath,
MusicDirectoryPath: AudioRecorderManager.MusicDirectoryPath,
DownloadsDirectoryPath: AudioRecorderManager.DownloadsDirectoryPath
};
AudioSource = {
DEFAULT: 0,
MIC: 1,
VOICE_UPLINK: 2,
VOICE_DOWNLINK: 3,
VOICE_CALL: 4,
CAMCORDER: 5,
VOICE_RECOGNITION: 6,
VOICE_COMMUNICATION: 7,
REMOTE_SUBMIX: 8, // added in API 19
UNPROCESSED: 9, // added in API 24
};
}
module.exports = {AudioRecorder, AudioUtils, AudioSource};
//
// AudioRecorderManager.h
// AudioRecorderManager
//
// Created by Joshua Sierles on 15/04/15.
// Copyright (c) 2015 Joshua Sierles. All rights reserved.
//
#import <React/RCTBridgeModule.h>
#import <React/RCTLog.h>
#import <AVFoundation/AVFoundation.h>
@interface AudioRecorderManager : NSObject <RCTBridgeModule, AVAudioRecorderDelegate>
@end
\ No newline at end of file
//
// AudioRecorderManager.m
// AudioRecorderManager
//
// Created by Joshua Sierles on 15/04/15.
// Copyright (c) 2015 Joshua Sierles. All rights reserved.
//
#import "AudioRecorderManager.h"
#import <React/RCTConvert.h>
#import <React/RCTBridge.h>
#import <React/RCTUtils.h>
#import <React/RCTEventDispatcher.h>
#import <AVFoundation/AVFoundation.h>
NSString *const AudioRecorderEventProgress = @"recordingProgress";
NSString *const AudioRecorderEventFinished = @"recordingFinished";
@implementation AudioRecorderManager {
AVAudioRecorder *_audioRecorder;
NSTimeInterval _currentTime;
id _progressUpdateTimer;
int _progressUpdateInterval;
NSDate *_prevProgressUpdateTime;
NSURL *_audioFileURL;
NSNumber *_audioQuality;
NSNumber *_audioEncoding;
NSNumber *_audioChannels;
NSNumber *_audioSampleRate;
AVAudioSession *_recordSession;
BOOL _meteringEnabled;
BOOL _measurementMode;
BOOL _includeBase64;
}
@synthesize bridge = _bridge;
RCT_EXPORT_MODULE();
- (void)sendProgressUpdate {
if (_audioRecorder && _audioRecorder.isRecording) {
_currentTime = _audioRecorder.currentTime;
} else {
return;
}
if (_prevProgressUpdateTime == nil ||
(([_prevProgressUpdateTime timeIntervalSinceNow] * -1000.0) >= _progressUpdateInterval)) {
NSMutableDictionary *body = [[NSMutableDictionary alloc] init];
[body setObject:[NSNumber numberWithFloat:_currentTime] forKey:@"currentTime"];
if (_meteringEnabled) {
[_audioRecorder updateMeters];
float _currentMetering = [_audioRecorder averagePowerForChannel: 0];
[body setObject:[NSNumber numberWithFloat:_currentMetering] forKey:@"currentMetering"];
float _currentPeakMetering = [_audioRecorder peakPowerForChannel:0];
[body setObject:[NSNumber numberWithFloat:_currentPeakMetering] forKey:@"currentPeakMetering"];
}
[self.bridge.eventDispatcher sendAppEventWithName:AudioRecorderEventProgress body:body];
_prevProgressUpdateTime = [NSDate date];
}
}
- (void)stopProgressTimer {
[_progressUpdateTimer invalidate];
}
- (void)startProgressTimer {
_progressUpdateInterval = 250;
//_prevProgressUpdateTime = nil;
[self stopProgressTimer];
_progressUpdateTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(sendProgressUpdate)];
[_progressUpdateTimer addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
}
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag {
NSString *base64 = @"";
if (_includeBase64) {
NSData *data = [NSData dataWithContentsOfURL:_audioFileURL];
base64 = [data base64EncodedStringWithOptions:0];
}
uint64_t audioFileSize = 0;
audioFileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:[_audioFileURL path] error:nil] fileSize];
[self.bridge.eventDispatcher sendAppEventWithName:AudioRecorderEventFinished body:@{
@"base64":base64,
@"duration":@(_currentTime),
@"status": flag ? @"OK" : @"ERROR",
@"audioFileURL": [_audioFileURL absoluteString],
@"audioFileSize": @(audioFileSize)
}];
// This will resume the music/audio file that was playing before the recording started
// Without this piece of code, the music/audio will just be stopped
NSError *error;
[[AVAudioSession sharedInstance] setActive:NO
withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation
error:&error];
if (error) {
// TODO: dispatch error over the bridge
NSLog(@"error: %@", [error localizedDescription]);
}
}
- (void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder *)recorder error:(NSError *)error {
if (error) {
// TODO: dispatch error over the bridge
NSLog(@"error: %@", [error localizedDescription]);
}
}
- (NSString *) applicationDocumentsDirectory
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
return basePath;
}
RCT_EXPORT_METHOD(prepareRecordingAtPath:(NSString *)path sampleRate:(float)sampleRate channels:(nonnull NSNumber *)channels quality:(NSString *)quality encoding:(NSString *)encoding meteringEnabled:(BOOL)meteringEnabled measurementMode:(BOOL)measurementMode includeBase64:(BOOL)includeBase64)
{
_prevProgressUpdateTime = nil;
[self stopProgressTimer];
_audioFileURL = [NSURL fileURLWithPath:path];
// Default options
_audioQuality = [NSNumber numberWithInt:AVAudioQualityHigh];
_audioEncoding = [NSNumber numberWithInt:kAudioFormatAppleIMA4];
_audioChannels = [NSNumber numberWithInt:2];
_audioSampleRate = [NSNumber numberWithFloat:44100.0];
_meteringEnabled = NO;
_includeBase64 = NO;
// Set audio quality from options
if (quality != nil) {
if ([quality isEqual: @"Low"]) {
_audioQuality =[NSNumber numberWithInt:AVAudioQualityLow];
} else if ([quality isEqual: @"Medium"]) {
_audioQuality =[NSNumber numberWithInt:AVAudioQualityMedium];
} else if ([quality isEqual: @"High"]) {
_audioQuality =[NSNumber numberWithInt:AVAudioQualityHigh];
}
}
// Set channels from options
if (channels != nil) {
_audioChannels = channels;
}
// Set audio encoding from options
if (encoding != nil) {
if ([encoding isEqual: @"lpcm"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatLinearPCM];
} else if ([encoding isEqual: @"ima4"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatAppleIMA4];
} else if ([encoding isEqual: @"aac"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatMPEG4AAC];
} else if ([encoding isEqual: @"MAC3"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatMACE3];
} else if ([encoding isEqual: @"MAC6"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatMACE6];
} else if ([encoding isEqual: @"ulaw"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatULaw];
} else if ([encoding isEqual: @"alaw"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatALaw];
} else if ([encoding isEqual: @"mp1"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatMPEGLayer1];
} else if ([encoding isEqual: @"mp2"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatMPEGLayer2];
} else if ([encoding isEqual: @"alac"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatAppleLossless];
} else if ([encoding isEqual: @"amr"]) {
_audioEncoding =[NSNumber numberWithInt:kAudioFormatAMR];
} else if ([encoding isEqual: @"flac"]) {
if (@available(iOS 11, *)) _audioEncoding =[NSNumber numberWithInt:kAudioFormatFLAC];
} else if ([encoding isEqual: @"opus"]) {
if (@available(iOS 11, *)) _audioEncoding =[NSNumber numberWithInt:kAudioFormatOpus];
}
}
// Set sample rate from options
_audioSampleRate = [NSNumber numberWithFloat:sampleRate];
NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
_audioQuality, AVEncoderAudioQualityKey,
_audioEncoding, AVFormatIDKey,
_audioChannels, AVNumberOfChannelsKey,
_audioSampleRate, AVSampleRateKey,
nil];
// Enable metering from options
if (meteringEnabled != NO) {
_meteringEnabled = meteringEnabled;
}
// Measurement mode to disable mic auto gain and high pass filters
if (measurementMode != NO) {
_measurementMode = measurementMode;
}
if (includeBase64) {
_includeBase64 = includeBase64;
}
NSError *error = nil;
_recordSession = [AVAudioSession sharedInstance];
if (_measurementMode) {
[_recordSession setCategory:AVAudioSessionCategoryRecord error:nil];
[_recordSession setMode:AVAudioSessionModeMeasurement error:nil];
}else{
[_recordSession setCategory:AVAudioSessionCategoryMultiRoute error:nil];
}
_audioRecorder = [[AVAudioRecorder alloc]
initWithURL:_audioFileURL
settings:recordSettings
error:&error];
_audioRecorder.meteringEnabled = _meteringEnabled;
_audioRecorder.delegate = self;
if (error) {
NSLog(@"error: %@", [error localizedDescription]);
// TODO: dispatch error over the bridge
} else {
[_audioRecorder prepareToRecord];
}
}
RCT_EXPORT_METHOD(startRecording)
{
[self startProgressTimer];
[_recordSession setActive:YES error:nil];
[_audioRecorder record];
}
RCT_EXPORT_METHOD(stopRecording)
{
[_audioRecorder stop];
[_recordSession setCategory:AVAudioSessionCategoryPlayback error:nil];
_prevProgressUpdateTime = nil;
}
RCT_EXPORT_METHOD(pauseRecording)
{
if (_audioRecorder.isRecording) {
[_audioRecorder pause];
}
}
RCT_EXPORT_METHOD(resumeRecording)
{
if (!_audioRecorder.isRecording) {
[_audioRecorder record];
}
}
RCT_EXPORT_METHOD(checkAuthorizationStatus:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject)
{
AVAudioSessionRecordPermission permissionStatus = [[AVAudioSession sharedInstance] recordPermission];
switch (permissionStatus) {
case AVAudioSessionRecordPermissionUndetermined:
resolve(@("undetermined"));
break;
case AVAudioSessionRecordPermissionDenied:
resolve(@("denied"));
break;
case AVAudioSessionRecordPermissionGranted:
resolve(@("granted"));
break;
default:
reject(RCTErrorUnspecified, nil, RCTErrorWithMessage(@("Error checking device authorization status.")));
break;
}
}
RCT_EXPORT_METHOD(requestAuthorization:(RCTPromiseResolveBlock)resolve
rejecter:(__unused RCTPromiseRejectBlock)reject)
{
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
if(granted) {
resolve(@YES);
} else {
resolve(@NO);
}
}];
}
- (NSString *)getPathForDirectory:(int)directory
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES);
return [paths firstObject];
}
- (NSDictionary *)constantsToExport
{
return @{
@"MainBundlePath": [[NSBundle mainBundle] bundlePath],
@"NSCachesDirectoryPath": [self getPathForDirectory:NSCachesDirectory],
@"NSDocumentDirectoryPath": [self getPathForDirectory:NSDocumentDirectory],
@"NSLibraryDirectoryPath": [self getPathForDirectory:NSLibraryDirectory]
};
}
@end
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
429D457A1CFC96E100CBD51A /* AudioRecorderManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 429D45761CFC96E100CBD51A /* AudioRecorderManager.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
42F559B81CFC90C400DC3F84 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
429D45761CFC96E100CBD51A /* AudioRecorderManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioRecorderManager.m; sourceTree = SOURCE_ROOT; };
429D45771CFC96E100CBD51A /* AudioRecorderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioRecorderManager.h; sourceTree = SOURCE_ROOT; };
42F559BA1CFC90C400DC3F84 /* libRNAudio.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNAudio.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
42F559B71CFC90C400DC3F84 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
42F559B11CFC90C400DC3F84 = {
isa = PBXGroup;
children = (
42F559BC1CFC90C400DC3F84 /* RNAudio */,
42F559BB1CFC90C400DC3F84 /* Products */,
);
sourceTree = "<group>";
};
42F559BB1CFC90C400DC3F84 /* Products */ = {
isa = PBXGroup;
children = (
42F559BA1CFC90C400DC3F84 /* libRNAudio.a */,
);
name = Products;
sourceTree = "<group>";
};
42F559BC1CFC90C400DC3F84 /* RNAudio */ = {
isa = PBXGroup;
children = (
429D45761CFC96E100CBD51A /* AudioRecorderManager.m */,
429D45771CFC96E100CBD51A /* AudioRecorderManager.h */,
);
path = RNAudio;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
42F559B91CFC90C400DC3F84 /* RNAudio */ = {
isa = PBXNativeTarget;
buildConfigurationList = 42F559C31CFC90C400DC3F84 /* Build configuration list for PBXNativeTarget "RNAudio" */;
buildPhases = (
42F559B61CFC90C400DC3F84 /* Sources */,
42F559B71CFC90C400DC3F84 /* Frameworks */,
42F559B81CFC90C400DC3F84 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = RNAudio;
productName = RNAudio;
productReference = 42F559BA1CFC90C400DC3F84 /* libRNAudio.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
42F559B21CFC90C400DC3F84 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Joshua Sierles";
TargetAttributes = {
42F559B91CFC90C400DC3F84 = {
CreatedOnToolsVersion = 7.3.1;
};
};
};
buildConfigurationList = 42F559B51CFC90C400DC3F84 /* Build configuration list for PBXProject "RNAudio" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 42F559B11CFC90C400DC3F84;
productRefGroup = 42F559BB1CFC90C400DC3F84 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
42F559B91CFC90C400DC3F84 /* RNAudio */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
42F559B61CFC90C400DC3F84 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
429D457A1CFC96E100CBD51A /* AudioRecorderManager.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
42F559C11CFC90C400DC3F84 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
42F559C21CFC90C400DC3F84 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
42F559C41CFC90C400DC3F84 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../react-native/React/**",
);
"HEADER_SEARCH_PATHS[arch=*]" = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Debug;
};
42F559C51CFC90C400DC3F84 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../react-native/React/**",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
42F559B51CFC90C400DC3F84 /* Build configuration list for PBXProject "RNAudio" */ = {
isa = XCConfigurationList;
buildConfigurations = (
42F559C11CFC90C400DC3F84 /* Debug */,
42F559C21CFC90C400DC3F84 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
42F559C31CFC90C400DC3F84 /* Build configuration list for PBXNativeTarget "RNAudio" */ = {
isa = XCConfigurationList;
buildConfigurations = (
42F559C41CFC90C400DC3F84 /* Debug */,
42F559C51CFC90C400DC3F84 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 42F559B21CFC90C400DC3F84 /* Project object */;
}
{
"name": "react-native-audio",
"version": "4.3.0",
"description": "React Native extension for recording audio",
"main": "index.js",
"author": "Joshua Sierles <joshua@diluvia.net> (https://github.com/jsierles)",
"files": [
"ios/AudioRecorderManager.m",
"ios/AudioRecorderManager.h",
"ios/RNAudio.xcodeproj",
"README.md",
"LICENSE",
"index.js",
"android/*",
"RNAudio.podspec"
],
"keywords": [
"react-native",
"audio",
"record"
],
"repository": {
"type": "git",
"url": "git@github.com:jsierles/react-native-audio.git"
},
"nativePackage": true
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment