项目作者: xinlc

项目描述 :
A short video for React Native
高级语言: Objective-C
项目地址: git://github.com/xinlc/react-native-aliyun-video.git
创建时间: 2018-05-30T10:37:30Z
项目社区:https://github.com/xinlc/react-native-aliyun-video

开源协议:MIT License

下载


react-native-aliyun-video

短视频SDK需要 License

npm package
npm downloads

TOC

Installation

Using npm:

  1. npm install --save react-native-aliyun-short-video

or using yarn:

  1. yarn add react-native-aliyun-short-video

Linking

Automatic

  1. react-native link react-native-aliyun-short-video

(or using rnpm for versions of React Native < 0.27)

  1. rnpm link react-native-aliyun-short-video

Manual


Android

in 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') ...

#### With React Native 0.29+

in 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() ); } ... }

#### With older versions of React Native:
in 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() ); } }

iOS

In XCode, in the project navigator:

Right click Libraries Add Files to [your project’s name]
Go to node_modules/react-native-aliyun-short-video/ios Add the RNShortVideo.xcodeproj file
Drag and drop the node_modules/react-native-aliyun-short-video/ios/AliyunSDK folder to your xcode project. (Make sure Copy items if needed IS ticked)

Click on project General tab
Under Embedded Binaries click + and add AliThirdparty.framework, AliyunPlayerSDK.framework, AliyunVideoSDK.framework, AliyunVodPlayerSDK.framework, QuCore-ThirdParty.framework
Under Linked Frameworks and Libraries click + 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

Click on project Build Settings tab
Look for Enable Bitcode set to No
Look for Other Linker Flags and make sure it contain -ObjC Look for Framework Search Paths and make sure it contain $(SRCROOT)/../node_modules/react-native-aliyun-short-video/ios/AliyunSDK
Look for Header Search Paths and make sure it contain $(SRCROOT)/../node_modules/react-native-aliyun-short-video/ios/RNShortVideo (Mark as recursive)

Click on project Build Phase tab
Under Copy Bundle Resources click + and add QPSDK.bundle and AliyunLanguageSource.bundle


In the project navigator:

Click Info.plist Add the NSPhotoLibraryUsageDescription, NSMicrophoneUsageDescription, NSCameraUsageDescription and NSPhotoLibraryAddUsageDescriptionkeys 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 step

Run your project (Cmd+R)

Usage

See the example

  1. ...
  2. import RNShortVideo, { VideoView } from 'react-native-aliyun-short-video';
  3. ...
  4. ...
  5. onRecord = () => {
  6. RNShortVideo.recordShortVideo()
  7. .then((path) => {
  8. this.setState({ path });
  9. })
  10. .catch((err) => {
  11. console.error(err);
  12. });
  13. };
  14. ...
  15. ...
  16. <View>
  17. {
  18. this.state.path ? (
  19. <VideoView
  20. fullscreen
  21. source={{ url: this.state.path }}
  22. poster="http://t.cn/RuWRYzv?1=1"
  23. ></VideoView>
  24. ) : null
  25. }
  26. </View>
  27. ...

API

android short video

Troubleshooting

When installing or using react-native-aliyun-short-video, you may encounter the following problems:


[android] - Duplicate files copied in APK lib/armeabi-v7a/libgnustl_shared.so

in android/app/build.gradle:

```diff
android {

packagingOptions {
exclude(‘META-INF/LICENSE’)
+ pickFirst “*
/libgnustl_shared.so”
}

}
```


[android] - Could not find :QuSdk-RC:

* in android/app/build.gradle:

diff ... repositories { flatDir { - dirs "libs" + dirs "libs", "$rootDir/../node_modules/react-native-aliyun-short-video/android/libs" } } ...

TODO

  • Compatible with iOS