React Native module for record and playing sound in realtime
Edit android/settings.gradle
to declare the project directory:
include ':RNVoiceFilter', ':app'
project(':RNVoiceFilter').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-voice-filter/android')
Edit android/app/build.gradle
to declare the project dependency:
dependencies {
...
compile project(':react-native-voice-filter')
}
Edit android/app/src/main/java/.../MainActivity.java
to register the native module:
...
import com.boilerplate.RNVoiceFilter.RNVoiceFilterPackage; // <-- New
...
public class MainActivity extends ReactActivity {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNVoiceFilterPackage() // <-- New
);
}
For older MainActivity.java
templates, edit as follows:
...
import com.boilerplate.RNVoiceFilter.RNVoiceFilterPackage; // <-- New
...
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
...
@Override
protected void onCreate(Bundle savedInstanceState){
...
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
...
.addPackage(new MainReactPackage())
.addPackage(new RNVoiceFilterPackage()) // <-- New
...
}
// Import the react-native-boilerplate-bridge module
var RNVoiceFilter = require('../lib/react-native-voice-filter');
// init
var voiceFilter = new RNVoiceFilter();
// Callback
voiceFilter.listen();
voiceFilter.setVolume(0.5);
voiceFilter.stop();