Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-audio-player-recorder

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-audio-player-recorder

React Native extension for playing and recording audio

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-47.83%
Maintainers
1
Weekly downloads
 
Created
Source

React Native Audio Player Recorder npm version

NPM

Record and play back audio through Loud Speaker, Receiver, Bluetooth and Headphones in your iOS or Android React Native apps.

Features

react-native-audio-player-recorder is a package that allows you to:

  • Record audio on both iOS and Android with Progress reporting and features such as: recording, pause recording and stop recording.
  • Play audio on both iOS and Android with progress reporting and features such as: playing, pause playing and stop playing.

Installation

Install package

  • Install with npm:

If you're using react-native version < 0.40.0

Please run:

npm install react-native-audio-player-recorder@1.1.1 --save

If you're using react-native version >= 0.40.0

Please run

npm install react-native-audio-player-recorder@2.0.0 --save
  • Install with yarn:

If you're using react-native version < 0.40.0

Please run:

yarn add react-native-audio-player-recorder@1.1.1

If you're using react-native version >= 0.40.0

Please run

yarn add react-native-audio-player-recorder@2.0.0
react-native link react-native-audio-player-recorder

Configration for iOS and Android

On iOS you need to add a usage description to Info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>This sample uses the microphone to record your speech and convert it to text.</string>

On Android you need to add a permission to AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

Quick Getting Started

In the AudioExample directory:

npm install
react-native run-ios

API Documentation

AudioRecorder
MethodMethod DescriptionParametersParameters Description
prepareRecordingAtPathThis method must be called before recording to set up the recording path and set the recording audio quality and output format and so on.path, optionspath: the local path to store the recording audio. options: the recording options
startRecordingStart recording
pauseRecordingPause recording
stopRecordingWhen this method is called, the recorded audio file will be saved to local automatically.
playRecordingPlaying the recorded audio after recording finishes.
stopPlayingStop playing the recorded audio.
pausePlayingPause playing the recorded audio.
onProgressRecording progress reporting callback function.
onFinishedRecording finishes callback function.
AudioPlayer
MethodMethod DescriptionParametersParameters Description
playPlay audio form path with optionspath, optionspath: local audio path options: the playing options
playWithUrlurl, optionsurl: audio url options: the playing options
pausePause playing
unpauseUnpause playing
stopStop playing audio
skipToSecondsPlay audio from some position, the unit is secondpositionposition: use second as unit
onProgressPlaying progress reporting callback, must call function setProgressSubscription to subscribe the onProgress callbackdata
setProgressSubscriptiononProgress callback subscriotion
onFinishedPlaying finish callback, must call function setFinishedSubscription to subscribe the onFinished callback
setFinishedSubscriptiononFinished callback subscription
getOutputsGet current available outputs, will return an array of String, for example the outputs can be: ["Phone", "Phone Speaker", "Bluetooth"]
Available Playback Outputs

When playing audio, there are chances that the headphone is plugged, or the bluetooth headset is connected to your device.

react-native-audio-player-recorder supports to get current the available outputs.

_getAvailableOutputs() {
  AudioPlayer.getOutputs(outputs => {
    console.log('outputs========', outputs)
  })
}
Set Playback Outputs With Options

react-native-audio-player-recorder supports to play audio via appointed output.

Play Audio via outputs by passing output params:

  • Receiver: Phone

  • Loud Speaker: Phone Speaker

  • Bluetooth: Bluetooth

  • Headphones: Headphones

_playViaOutput(output) {
  let audioPath = AudioUtils.DocumentDirectoryPath + '/test.aac';      
  let options = {output: 'Phone'};
  AudioPlayer.play(audioPath, options)      
}

Support

This package is forked from https://github.com/jsierles/react-native-audio.

We borrow some features from it, learn a lot and add features such as: Playing via appointed outputs, get current available outputs, add audio progress reporting support for Andoid and so on.

If you like the component and want to support it, feel free to donate any amount or help with issues.

Keywords

FAQs

Package last updated on 20 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc