@independo/capacitor-voice-recorder 8.1.2 → 8.1.3-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +99 -27
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,6 +14,10 @@
14
14
  <a href="https://codecov.io/gh/independo-gmbh/capacitor-voice-recorder/branch/master"><img src="https://codecov.io/gh/independo-gmbh/capacitor-voice-recorder/branch/master/graph/badge.svg" alt="Coverage Badge: master" /></a>
15
15
  </p>
16
16
 
17
+ ## Overview
18
+
19
+ The `@independo/capacitor-voice-recorder` plugin allows you to record audio on Android, iOS, and Web platforms.
20
+
17
21
  ## Installation
18
22
 
19
23
  ```
@@ -21,43 +25,72 @@ npm install --save @independo/capacitor-voice-recorder
21
25
  npx cap sync
22
26
  ```
23
27
 
24
- ## Requirements
28
+ ### Configuration
29
+
30
+ #### Using with Android
31
+
32
+ Add the following to your `AndroidManifest.xml`:
33
+
34
+ ```xml
35
+ <uses-permission android:name="android.permission.RECORD_AUDIO"/>
36
+ ```
37
+
38
+ #### Using with iOS
39
+
40
+ Add the following to your `Info.plist`:
41
+
42
+ ```xml
43
+ <key>NSMicrophoneUsageDescription</key>
44
+ <string>This app uses the microphone to record audio.</string>
45
+ ```
46
+
47
+ ### Requirements
25
48
 
26
49
  - Capacitor 8+
27
50
  - iOS 15+
28
51
  - Android minSdk 24+; builds require Java 21 (recommended). `npm run verify:android` requires a Java version supported
29
52
  by the bundled Gradle wrapper (currently Java 21–24, with Java 21 recommended).
30
53
 
31
- ## iOS Package Manager Support
54
+ ### Compatibility
55
+
56
+ Versioning follows Capacitor versioning. Major versions of the plugin are compatible with major versions of Capacitor.
57
+
58
+ | Plugin Version | Capacitor Version | Status |
59
+ |----------------|-------------------|------------|
60
+ | 8.* | 8 | Active |
61
+ | 7.* | 7 | Deprecated |
62
+ | 6.* | 6 | Deprecated |
63
+ | 5.* | 5 | Deprecated |
64
+
65
+ ### iOS Package Manager Support
32
66
 
33
67
  This plugin supports both CocoaPods and Swift Package Manager (SPM) on iOS.
34
68
 
35
69
  - CocoaPods (default Capacitor iOS template): `npx cap sync ios`
36
70
  - Swift Package Manager (SPM): migrate/create your iOS app to use SPM, then run `npx cap sync ios`
37
71
 
38
- ## Configuration
39
-
40
- ### Using with Android
72
+ ## Quick start
41
73
 
42
- Add the following to your `AndroidManifest.xml`:
74
+ Minimal flow for starting and stopping a recording:
43
75
 
44
- ```xml
45
- <uses-permission android:name="android.permission.RECORD_AUDIO"/>
46
- ```
76
+ ```typescript
77
+ import {VoiceRecorder} from '@independo/capacitor-voice-recorder';
47
78
 
48
- ### Using with iOS
79
+ export const startRecording = async () => {
80
+ const permission = await VoiceRecorder.requestAudioRecordingPermission();
81
+ if (!permission.value) {
82
+ throw new Error('Microphone permission not granted');
83
+ }
49
84
 
50
- Add the following to your `Info.plist`:
85
+ await VoiceRecorder.startRecording();
86
+ };
51
87
 
52
- ```xml
53
- <key>NSMicrophoneUsageDescription</key>
54
- <string>This app uses the microphone to record audio.</string>
88
+ export const stopRecording = async () => {
89
+ const {value} = await VoiceRecorder.stopRecording();
90
+ return value;
91
+ };
55
92
  ```
56
93
 
57
- ## Overview
58
-
59
- The `@independo/capacitor-voice-recorder` plugin allows you to record audio on Android, iOS, and Web platforms.
60
-
61
94
  ## API
62
95
 
63
96
  Below is an index of all available methods. Run `npm run docgen` after updating any JSDoc comments to refresh this
@@ -370,7 +403,9 @@ Event payload for voiceRecordingInterruptionEnded event (empty - no data).
370
403
 
371
404
  </docgen-api>
372
405
 
373
- ## Audio interruption handling
406
+ ## Platform behaviors
407
+
408
+ ### Interruption handling (iOS and Android)
374
409
 
375
410
  On iOS and Android, the plugin listens for system audio interruptions (phone calls, other apps taking audio focus). When
376
411
  an interruption begins, the recording is paused, the status becomes `INTERRUPTED`, and the `voiceRecordingInterrupted`
@@ -380,6 +415,32 @@ event fires. When the interruption ends, the `voiceRecordingInterruptionEnded` e
380
415
  If interruptions occur on iOS, recordings are segmented and merged when you stop. The merged file is M4A with MIME type
381
416
  `audio/mp4`. Recordings without interruptions remain AAC with MIME type `audio/aac`.
382
417
 
418
+ ### Web constraints
419
+
420
+ - `getUserMedia` requires a secure context (HTTPS or localhost).
421
+ - Most browsers require a user gesture to start recording; call `startRecording()` from a click/tap handler.
422
+ - The Permissions API is not consistently supported; `hasAudioRecordingPermission()` can reject with
423
+ `COULD_NOT_QUERY_PERMISSION_STATUS`. In that case, use `requestAudioRecordingPermission()` or `startRecording()` and
424
+ handle errors.
425
+
426
+ ## Recording options and storage
427
+
428
+ When you set `RecordingOptions.directory`, recordings are written to the Capacitor filesystem and `stopRecording()`
429
+ returns a `uri`. This avoids large base64 payloads and is recommended for long recordings. When `directory` is not set,
430
+ the data is returned in `recordDataBase64`.
431
+
432
+ When a `uri` is present, `recordDataBase64` may be empty or omitted, so prefer `uri` when available.
433
+
434
+ ```typescript
435
+ import {Directory} from '@capacitor/filesystem';
436
+ import {VoiceRecorder} from '@independo/capacitor-voice-recorder';
437
+
438
+ await VoiceRecorder.startRecording({
439
+ directory: Directory.Cache,
440
+ subDirectory: 'voice',
441
+ });
442
+ ```
443
+
383
444
  ## Format and MIME type
384
445
 
385
446
  The plugin returns the recording in one of several possible formats. The actual MIME type depends on the platform and
@@ -412,16 +473,26 @@ audioRef.oncanplaythrough = () => audioRef.play();
412
473
  audioRef.load();
413
474
  ```
414
475
 
415
- ## Compatibility
476
+ ## Troubleshooting
416
477
 
417
- Versioning follows Capacitor versioning. Major versions of the plugin are compatible with major versions of Capacitor.
478
+ ### Common error codes
479
+
480
+ The plugin rejects with error codes; check `error.code` (native) or `error.message` (web). Not all codes apply to every
481
+ platform.
418
482
 
419
- | Plugin Version | Capacitor Version |
420
- |----------------|-------------------|
421
- | 5.* | 5 |
422
- | 6.* | 6 |
423
- | 7.* | 7 |
424
- | 8.* | 8 |
483
+ | Code | Platform(s) | Typical cause |
484
+ |-------------------------------------|-------------------|---------------------------------------------------------------------------------|
485
+ | `MISSING_PERMISSION` | iOS, Android, Web | Microphone permission is not granted. |
486
+ | `ALREADY_RECORDING` | iOS, Android, Web | `startRecording()` called while already recording. |
487
+ | `DEVICE_CANNOT_VOICE_RECORD` | iOS, Android, Web | The device or browser cannot record audio. |
488
+ | `FAILED_TO_RECORD` | iOS, Android, Web | Recording failed to start or continue. |
489
+ | `RECORDING_HAS_NOT_STARTED` | iOS, Android, Web | `stopRecording()`, `pauseRecording()`, or `resumeRecording()` called too early. |
490
+ | `EMPTY_RECORDING` | iOS, Android, Web | Recording stopped too quickly or produced no data. |
491
+ | `FAILED_TO_FETCH_RECORDING` | iOS, Android, Web | The recording could not be read back. |
492
+ | `FAILED_TO_MERGE_RECORDING` | iOS | Interrupted recording segments failed to merge. |
493
+ | `MICROPHONE_BEING_USED` | Android | The microphone is busy or held by another app. |
494
+ | `NOT_SUPPORTED_OS_VERSION` | Android | Pause/resume is not supported on the current OS version. |
495
+ | `COULD_NOT_QUERY_PERMISSION_STATUS` | Web | Permissions API is unavailable. |
425
496
 
426
497
  ## Origins and credit
427
498
 
@@ -430,3 +501,4 @@ This project started as a fork of [
430
501
  Thanks to Avihu Harush for the original implementation and community groundwork. Since then, the plugin has been
431
502
  re-architected for improved performance, reliability, and testability (service/adapters split, contract tests, and a
432
503
  normalized response path). The codebase now diverges substantially, which is why this repo left the fork network.
504
+ This plugin is maintained by [Independo GmbH](https://www.independo.app/).
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "url": "https://github.com/independo-gmbh/capacitor-voice-recorder.git"
14
14
  },
15
15
  "description": "Capacitor plugin for voice recording",
16
- "version": "8.1.2",
16
+ "version": "8.1.3-dev.1",
17
17
  "devDependencies": {
18
18
  "@capacitor/android": "^8.0.0",
19
19
  "conventional-changelog-conventionalcommits": "^9.1.0",