$ npm install react-native-video-compress --save
$ react-native link react-native-video-compress
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-video-compress
and addRNVideoCompress.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNVideoCompress.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNVideoCompressPackage;
to the imports at the top of the file - Add
new RNVideoCompressPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-video-compress' project(':react-native-video-compress').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video-compress/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-video-compress')
import RNVideoCompress from 'react-native-video-compress';
try {
const compressUri = await RNVideoCompress.compress(uri, {
width: 720,
height: 1280,
bitrate: 500000
}).progress(value => {
console.log(value);
})
console.log(compressUri);
} catch (error) {
console.log(error);
}