capacitor-voice-recorder
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "capacitor-voice-recorder", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Capacitor plugin for voice recording", | ||
@@ -5,0 +5,0 @@ "main": "dist/esm/index.js", |
113
README.md
@@ -1,32 +0,80 @@ | ||
# capacitor-voice-recorder | ||
<p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p> | ||
<h3 align="center">Capacitor Voice Recorder</h3> | ||
<p align="center"><strong><code>tchvu3/capacitor-voice-recorder</code></strong></p> | ||
<p align="center"> | ||
Capacitor plugin for simple voice recording | ||
</p> | ||
Capacitor plugin for simple voice recording | ||
<p align="center"> | ||
<img src="https://img.shields.io/maintenance/yes/2020?style=flat-square" /> | ||
<!-- <a href="https://github.com/tchvu3/capacitor-voice-recorder/actions?query=workflow%3A%22CI%22"><img src="https://img.shields.io/github/workflow/status/tchvu3/capacitor-voice-recorder/CI?style=flat-square" /></a> --> | ||
<a href="https://www.npmjs.com/package/capacitor-voice-recorder"><img src="https://img.shields.io/npm/l/capacitor-voice-recorder?style=flat-square" /></a> | ||
<br> | ||
<a href="https://www.npmjs.com/package/capacitor-voice-recorder"><img src="https://img.shields.io/npm/dw/capacitor-voice-recorder?style=flat-square" /></a> | ||
<a href="https://www.npmjs.com/package/capacitor-voice-recorder"><img src="https://img.shields.io/npm/v/capacitor-voice-recorder?style=flat-square" /></a> | ||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> | ||
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-0-orange?style=flat-square" /></a> | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
</p> | ||
## Install | ||
## Maintainers | ||
| Maintainer | GitHub | Social | | ||
| -----------| -------| -------| | ||
| Avihu Harush | [tchvu3](https://github.com/tchvu3) | [@tchvu3](https://twitter.com/tchvu3) | | ||
## Installation | ||
``` | ||
npm install --save capacitor-voice-recorder | ||
npx cap sync | ||
``` | ||
## API | ||
#### ios note | ||
Make sure to include the ```NSMicrophoneUsageDescription``` | ||
key, and a corresponding purpose string in your app's Info.plist | ||
| Method | Info | Platform | | ||
| ----------------------------------|:--------------------------------------------------:|:-----------:| | ||
| canDeviceVoiceRecord() | test if the phone can voice record | ios/android | | ||
| requestAudioRecordingPermission() | request the user for permission | ios/android | | ||
| hasAudioRecordingPermission() | test if the user already gave permission to record | ios/android | | ||
| startRecording() | start the recording | ios/android | | ||
| stopRecording() | end the recording | ios/android | | ||
#### android note | ||
Make sure to add the plugin to your MainActivity.java like so: | ||
``` | ||
import com.tchvu3.capvoicerecorder.VoiceRecorder; | ||
... | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{ | ||
add(VoiceRecorder.class); // Add this line | ||
}}); | ||
} | ||
``` | ||
## Deep dive | ||
#### Each function returns Promise | ||
* canDeviceVoiceRecord - return promise that resolves to {"value": true} / {"value": false} based | ||
on the phones ability to record voice (will never throw exception) | ||
## Configuration | ||
No configuration required for this plugin. | ||
## Supported methods | ||
| Name | Android | iOS | Web | | ||
| :------------------------------ | :------ | :-- | :-- | | ||
| canDeviceVoiceRecord | ✅ | ✅ | ❌ | | ||
| requestAudioRecordingPermission | ✅ | ✅ | ❌ | | ||
| hasAudioRecordingPermission | ✅ | ✅ | ❌ | | ||
| startRecording | ✅ | ✅ | ❌ | | ||
| stopRecording | ✅ | ✅ | ❌ | | ||
## Explanation | ||
* canDeviceVoiceRecord - return promise that resolves to {"value": true} / {"value": false} | ||
based on the phone's ability to record voice. | ||
--- | ||
* requestAudioRecordingPermission - if the permission has already been provided | ||
then the promise will resolve with {"value": true}, otherwise the promise will resolve | ||
to {"value": true} / {"value": false} based on the answer of the user to the request | ||
to {"value": true} / {"value": false} based on the answer of the user to the request. | ||
--- | ||
* hasAudioRecordingPermission - will resolve to {"value": true} / {"value": false} based on the | ||
status of the permission | ||
status of the permission. | ||
--- | ||
@@ -38,10 +86,12 @@ * startRecording - if the app lacks the required permission then | ||
if there's a recording already running then the promise will reject with "ALREADY_RECORDING", | ||
and if the microphone is being used by other app then the promise will reject with "MICROPHONE_BEING_USED". | ||
NOTE: in case of unknown error the promise will reject with "FAILED_TO_RECORD" | ||
and if other apps are using the microphone then the promise will reject with "MICROPHONE_BEING_USED". | ||
in a case of unknown error the promise will reject with "FAILED_TO_RECORD". | ||
--- | ||
* stopRecording - will stop the recording that previously started. if the function startRecording() | ||
has not been called beforehand then the promise will reject with: "RECORDING_HAS_NOT_STARTED". | ||
* stopRecording - will stop the recording that has been previously started. | ||
if the function startRecording() has not been called beforehand | ||
the promise will reject with: "RECORDING_HAS_NOT_STARTED". | ||
in case of success, you will get the recording in base-64, | ||
the duration of the recording in milliseconds and the mime type | ||
the duration of the recording in milliseconds, and the mime type. | ||
## Usage | ||
@@ -56,3 +106,2 @@ | ||
// without types | ||
const { VoiceRecorder } = Plugins | ||
@@ -95,2 +144,3 @@ | ||
## Playback | ||
To play the recorded file you can use plain | ||
@@ -105,18 +155,1 @@ javascript: | ||
``` | ||
## ios note | ||
Make sure to include the NSMicrophoneUsageDescription key | ||
and a corresponding purpose string in your app's Info.plist | ||
## android note | ||
Please make sure to add the plugin in your MainActivity.java like so: | ||
``` | ||
import com.tchvu3.capvoicerecorder.VoiceRecorder; | ||
... | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{ | ||
add(VoiceRecorder.class); // Add this line | ||
}}); | ||
} | ||
``` |
1790741
152