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
MisterAlex95
committed
Jun 3, 2016
0 parents
commit a6db6d1
Showing
7 changed files
with
180 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
# Android/IJ | ||
# | ||
.idea | ||
.gradle | ||
local.properties | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
android/app/libs | ||
android/keystores/debug.keystore |
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,2 @@ | ||
import { NativeModules } from 'react-native'; | ||
module.exports = NativeModules.ReactNativeRecorder; |
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,34 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:1.1.3' | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
targetSdkVersion 22 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile 'com.facebook.react:react-native:0.12.+' | ||
} |
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.reactnativerecorder" > | ||
</manifest> |
36 changes: 36 additions & 0 deletions
36
android/src/main/java/com/reactnativerecorder/CustomPackages.java
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,36 @@ | ||
package com.reactnativerecorder; | ||
|
||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
import com.facebook.react.bridge.JavaScriptModule; | ||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import com.reactnativerecorder.ReactNativeRecorder; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
|
||
public class CustomPackages implements ReactPackage { | ||
@Override | ||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { | ||
List<NativeModule> modules = new ArrayList<>(); | ||
modules.add(new ReactNativeRecorder(reactContext)); | ||
return modules; | ||
} | ||
|
||
@Override | ||
public List<Class<? extends JavaScriptModule>> createJSModules() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | ||
return Arrays.asList(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
android/src/main/java/com/reactnativerecorder/ReactNativeRecorder.java
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,51 @@ | ||
package com.reactnativerecorder; | ||
|
||
import android.media.MediaRecorder; | ||
import java.io.IOException; | ||
|
||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
|
||
import java.util.Map; | ||
|
||
public class ReactNativeRecorder extends ReactContextBaseJavaModule { | ||
|
||
private static final String LOG_TAG = "RecordModule"; | ||
private MediaRecorder mRecorder = null; | ||
|
||
public ReactNativeRecorder(ReactApplicationContext reactContext) { | ||
super(reactContext); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "ReactNativeRecorder"; | ||
} | ||
|
||
@ReactMethod | ||
public void startRecord(String filename) { | ||
mRecorder = new MediaRecorder(); | ||
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); | ||
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); | ||
mRecorder.setOutputFile(filename); | ||
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); | ||
|
||
try { | ||
mRecorder.prepare(); | ||
} catch (IOException e) { | ||
//oups | ||
} | ||
|
||
mRecorder.start(); | ||
} | ||
|
||
@ReactMethod | ||
private void stopRecording() { | ||
mRecorder.stop(); | ||
mRecorder.release(); | ||
mRecorder = null; | ||
} | ||
} |
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 @@ | ||
{ | ||
"name": "react-native-recorder", | ||
"version": "0.0.1", | ||
"description": "Android recorder for React Native", | ||
"keywords": ["react-native", "android", "recorder"], | ||
"homepage": "https://github.com/MisterAlex95/react-native-recorder", | ||
"author": "Alex Dana", | ||
"files": [ | ||
"android/", | ||
"ReactNativeRecorder.js" | ||
] | ||
} |