ReactNative VR视频封装
近期给VR视频做了个封装,并上传到npm与git
git地址:react-native-vrplayer
npm:react-native-vrplayer
以下是使用方法:
安装
使用npm:
npm install react-native-vrplayer -save
link:
1、Android:
运行 react-native link react-native-vrplayer
手动link:
android/settings.gradle
include ':react-native-vrplayer'
project(':react-native-vrplayer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vrplayer/android')
android/app/build.gradle
dependencies {
...
implementation project(':react-native-vrplayer')
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
}
MainApplication.java
引入:
import com.zjiaxin.vrvideo.RNVRVideoPackage;
添加RNVRVideoPackage
到你的Package.
@Override
protected List<ReactPackage> getPackages() {
return Arrays.asList(
new MainReactPackage(),
new RNVRVideoPackage()
);
}
2、iOS:
暂不支持
平台
- Android (支持)
- iOS (暂不支持)
使用方法
import { VRVideoPlayer } from 'react-native-vrplayer';
class VRVideoPage extends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
return (
<View style={{ flex: 1 }}>
<VRVideoPlayer
url={'xxx.mp4'}
paused={false}
style={{ flex: 1 }}
/>
</View>
);
}
}
export default VRVideoPage;
后续会给出具体api使用方法