Home

Awesome

React Native Capture (remobile)

A cordova capture for react-native, support for ios and android

Installation

npm install @remobile/react-native-capture --save

Installation (iOS)

Installation (Android)

...
include ':react-native-capture'
project(':react-native-capture').projectDir = new File(settingsDir, '../node_modules/@remobile/react-native-capture/android')
...
dependencies {
    ...
    compile project(':react-native-capture')
}
......
import com.remobile.capture.RCTCapturePackage;  // <--- import

......

@Override
protected List<ReactPackage> getPackages() {
   ......
   new RCTCapturePackage(),            // <------ add here
   ......
}

Usage

Example

var React = require('react');
var ReactNative = require('react-native');
var {
    StyleSheet,
    View,
    Image
} = ReactNative;

var Capture = require('@remobile/react-native-capture');
var Button = require('@remobile/react-native-simple-button');

module.exports = React.createClass({
    getInitialState () {
        return {
            filePath: '',
        };
    },
    taskVideo() {
        Capture.captureVideo((mediaFiles)=>{
            let filePath = mediaFiles[0].fullPath;
            this.setState({filePath});
        }, ()=>{
            Toast('录制失败');
        }, {limit:1});
    },
    render() {
        const {filePath} = this.state;
        return (
            <View style={styles.container}>
                <Button onPress={this.taskVideo}>摄像</Button>
                <Text>{filePath}</Text>
            </View>
        );
    },
});


var styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'space-around',
        alignItems: 'center',
        backgroundColor: 'transparent',
    },
});

HELP

thanks

see detail use