Skip to content

Commit

Permalink
* new: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterAlex95 committed Jun 3, 2016
0 parents commit a6db6d1
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .gitignore
@@ -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
2 changes: 2 additions & 0 deletions ReactNativeRecorder.js
@@ -0,0 +1,2 @@
import { NativeModules } from 'react-native';
module.exports = NativeModules.ReactNativeRecorder;
34 changes: 34 additions & 0 deletions android/build.gradle
@@ -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.+'
}
5 changes: 5 additions & 0 deletions android/src/main/AndroidManifest.xml
@@ -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 android/src/main/java/com/reactnativerecorder/CustomPackages.java
@@ -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();
}
}
@@ -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;
}
}
12 changes: 12 additions & 0 deletions package.json
@@ -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"
]
}

0 comments on commit a6db6d1

Please sign in to comment.