A short video for React Native
Using npm:
npm install --save react-native-aliyun-short-video
or using yarn:
yarn add react-native-aliyun-short-video
react-native link react-native-aliyun-short-video
(or using rnpm
for versions of React Native < 0.27)
rnpm link react-native-aliyun-short-video
android/app/build.gradle
:diff
dependencies {
...
compile "com.facebook.react:react-native:+" // From node_modules
+ compile project(':react-native-aliyun-short-video')
...
}
in android/settings.gradle
:diff
...
include ':app'
+ include ':react-native-aliyun-short-video'
+ project(':react-native-aliyun-short-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-aliyun-short-video/android')
...
MainApplication.java
:diff
...
+ import com.rnshortvideo.RNShortVideoPackage;
public class MainApplication extends Application implements ReactApplication {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
+ new RNShortVideoPackage()
);
}
...
}
MainActivity.java
:diff
...
+ import com.rnshortvideo.RNShortVideoPackage;
public class MainActivity extends ReactActivity {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
+ new RNShortVideoPackage()
);
}
}
node_modules/react-native-aliyun-short-video/ios
Add the RNShortVideo.xcodeproj
filenode_modules/react-native-aliyun-short-video/ios/AliyunSDK
folder to your xcode project. (Make sure Copy items if needed IS ticked)+
and add AliThirdparty.framework
, AliyunPlayerSDK.framework
, AliyunVideoSDK.framework
, AliyunVodPlayerSDK.framework
, QuCore-ThirdParty.framework
+
and add RNShortVideo.framework
, libz.tbd
, libc++.tbd
, libiconv.tbd
, libresolv.tbd
, ImageIO.framework
, CoreMedia.framework
, CoreVideo.framework
, SystemConfiguration.framework
, Photos.framework
, OpenAL.framework
, VideoToolbox.framework
-ObjC
Look for Framework Search Paths and make sure it contain $(SRCROOT)/../node_modules/react-native-aliyun-short-video/ios/AliyunSDK
$(SRCROOT)/../node_modules/react-native-aliyun-short-video/ios/RNShortVideo
(Mark as recursive)+
and add QPSDK.bundle
and AliyunLanguageSource.bundle
NSPhotoLibraryUsageDescription
, NSMicrophoneUsageDescription
, NSCameraUsageDescription
and NSPhotoLibraryAddUsageDescription
keys to your Info.plist
with strings describing why your app needs these permissions. Note: You will get a SIGABRT crash if you don’t complete this stepSee the example
...
import RNShortVideo, { VideoView } from 'react-native-aliyun-short-video';
...
...
onRecord = () => {
RNShortVideo.recordShortVideo()
.then((path) => {
this.setState({ path });
})
.catch((err) => {
console.error(err);
});
};
...
...
<View>
{
this.state.path ? (
<VideoView
fullscreen
source={{ url: this.state.path }}
poster="http://t.cn/RuWRYzv?1=1"
></VideoView>
) : null
}
</View>
...
When installing or using react-native-aliyun-short-video
, you may encounter the following problems:
android/app/build.gradle
::QuSdk-RC:
…android/app/build.gradle
:diff
...
repositories {
flatDir {
- dirs "libs"
+ dirs "libs", "$rootDir/../node_modules/react-native-aliyun-short-video/android/libs"
}
}
...