更新时间:2021-08-27 11:07:18下载pdf
import { NativeModules } from 'react-native';
export default NativeModules.TYRCTCameraManager;
import CameraManager from './cameramanager.js';
// 调用Native封装方法模块TYRCTCameraManager中的connect方法
CameraManager.connect(
res => {
console.log(res, 'P2P连接成功');
},
err => {
console.log(res, 'P2P建立失败');
}
);
import React from 'react';
import { requireNativeComponent, View } from 'react-native';
import PropTypes from 'prop-types';
// 引入原生组件
const Player = requireNativeComponent('TYRCTCameraPlayer', CameraPlayer, {
nativeOnly: { onChange: true }
});
// 原生组件引入再封装
class CameraPlayer extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<Player
{...this.props}
onChange={event => {
this.props.onChangePreview(event);
}}
/>
);
}
}
CameraPlayer.propTypes = {
action: PropTypes.number.isRequired,
onChangePreview: PropTypes.func.isRequired,
...View.propTypes,
};
module.exports = CameraPlayer;
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈