GithubHelp home page GithubHelp logo

catalinmiron / react-native-record-audio-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rhaker/react-native-record-audio-ios

0.0 3.0 1.0 109 KB

This is a wrapper for react native that records audio for ios. Can start and stop recording. Supports .caf, .m4a, and .wav files.

Objective-C 83.05% JavaScript 16.95%

react-native-record-audio-ios's Introduction

react-native-record-audio-ios

This is a wrapper for react-native that records audio. The options are to start and stop recording. Supported files include .caf, .m4a, and .wav types. This is for ios only.

Add it to your project

npm install react-native-record-audio-ios --save

In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]

Go to node_modules ➜ react-native-record-audio-ios and add RNRecordAudio.xcodeproj

In XCode, in the project navigator, select your project. Add libRNRecordAudio.a to your project's Build Phases ➜ Link Binary With Libraries

Click RNRecordAudio.xcodeproj in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.

Run your project (Cmd+R)

Setup trouble?

If you get stuck, take a look at Brent Vatne's blog. His blog is my go to reference for this stuff.

Api Setup

var React = require('react-native');

var { NativeModules } = React;

var { RNRecordAudio } = NativeModules;

// Start Recording

RNRecordAudio.startRecord(

"test.m4a", // filename

function errorCallback(results) {

    console.log('JS Error: ' + results['errMsg']);

},

function successCallback(results) {

    console.log('JS Success: ' + results['successMsg']);

}

);

// Stop Recording

RNRecordAudio.stopRecord(

"test.m4a", // filename

function errorCallback(results) {

    console.log('JS Error: ' + results['errMsg']);

},

function successCallback(results) {

    console.log('JS Success: ' + results['successMsg']);

}

);

Additional Notes

The recorded audio is saved in the app documents directory. The format/file type of the audio should be either a .caf, .wav, or .m4a.

Error Callback

The following will cause an error callback (use the console.log to see the specific message):

  1. Filename not included in api call

  2. Filename is a hidden file

  3. File is not .caf, .wav, .m4a type

  4. If stopping, file does not exist in the app documents directory

  5. If stopping, recording is not already in progress

Acknowledgements

Special thanks to Joshua Sierles for his work and code on react-native-audio. Brent Vatne for his posts on creating a react native packager. Some portions of this code have been based on answers from stackoverflow. This package also owes a special thanks to the tutorial by Jay Garcia at Modus Create on how to create a custom react native module.

react-native-record-audio-ios's People

Watchers

 avatar  avatar  avatar

Forkers

fabioued

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.