Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cf1832
commit 99e6fa7
Showing
21 changed files
with
1,509 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.DS_Store | ||
.DS_Store | ||
*Thumbs.db | ||
.gradle | ||
.idea | ||
*.iml | ||
npm-debug.log | ||
node_modules | ||
/android/build | ||
/ios/**/*xcuserdata* | ||
/ios/**/*xcshareddata* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,106 @@ | ||
# React Native media-capture (remobile) | ||
A media-capture for react-native | ||
# React Native Capture (remobile) | ||
A cordova capture for react-native, support for ios and android | ||
|
||
## Installation | ||
```sh | ||
npm install react-native-media-capture --save | ||
npm install @remobile/react-native-capture --save | ||
``` | ||
### Installation (iOS) | ||
* Drag RCTCapture.xcodeproj to your project on Xcode. | ||
* Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag libRCTCapture.a from the Products folder inside the RCTCapture.xcodeproj. | ||
* Look for Header Search Paths and make sure it contains both $(SRCROOT)/../../../react-native/React as recursive. | ||
|
||
### Installation (Android) | ||
```gradle | ||
... | ||
include ':react-native-capture' | ||
project(':react-native-capture').projectDir = new File(settingsDir, '../node_modules/@remobile/react-native-capture/android') | ||
``` | ||
|
||
* In `android/app/build.gradle` | ||
|
||
```gradle | ||
... | ||
dependencies { | ||
... | ||
compile project(':react-native-capture') | ||
} | ||
``` | ||
|
||
* register module (in MainApplication.java) | ||
|
||
```java | ||
...... | ||
import com.remobile.capture.RCTCapturePackage; // <--- import | ||
|
||
...... | ||
|
||
@Override | ||
protected List<ReactPackage> getPackages() { | ||
...... | ||
new RCTCapturePackage(), // <------ add here | ||
...... | ||
} | ||
|
||
``` | ||
|
||
## Usage | ||
|
||
### Example | ||
```js | ||
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 | ||
* look https://github.com/apache/cordova-plugin-media-capture | ||
|
||
|
||
### thanks | ||
* this project come from https://github.com/apache/cordova-plugin-media-capture | ||
|
||
### see detail use | ||
* https://github.com/remobile/react-native-template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
targetSdkVersion 22 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.android.support:appcompat-v7:23.0.1' | ||
compile 'com.facebook.react:react-native:+' | ||
compile project(':react-native-cordova') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.remobile.capture"> | ||
<uses-permission android:name="android.permission.RECORD_VIDEO"/> | ||
</manifest> |
Oops, something went wrong.