A simple AndroidAudioConverter wrapper for React Native
-
yarn add reactnativeandroidaudioconverter
-
link the library either automatically or manually
include ':react-native-android-audio-converter' // <---- add this line
project(':react-native-android-audio-converter').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-audio-converter/android') // <---- add this line
dependencies {
compile project(':react-native-android-audio-converter') // <---- add this line
}
import za.co.sovtech.rnaac.ReactNativeAndroidAudioConverterPackage; // <---- add this line
public class MainApplication extends ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeAndroidAudioConverterPackage() // <---- add this line
);
}
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
import {AudioConverter} from 'react-native-android-audio-converter';
a message will appear in the android logs
AudioConverter.convertAudioFile("my_audio.flac", (successMessage) => {
console.log(successMessage);
}, (errorMessage) => {
console.log(errorMessage);
});
This package uses AndroidAudioConverter which in turn uses FFmpeg-Android-Java