@capgo/capacitor-audio-recorder 7.0.0

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.
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapgoCapacitorAudioRecorder'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '14.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Capgo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapgoCapacitorAudioRecorder",
6
+ platforms: [.iOS(.v14)],
7
+ products: [
8
+ .library(
9
+ name: "CapgoCapacitorAudioRecorder",
10
+ targets: ["CapacitorAudioRecorderPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "CapacitorAudioRecorderPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/CapacitorAudioRecorderPlugin"),
23
+ .testTarget(
24
+ name: "CapacitorAudioRecorderPluginTests",
25
+ dependencies: ["CapacitorAudioRecorderPlugin"],
26
+ path: "ios/Tests/CapacitorAudioRecorderPluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,359 @@
1
+ # @capgo/capacitor-audio-recorder
2
+ <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
+
4
+ <div align="center">
5
+ <h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo</a></h2>
6
+ <h2><a href="https://capgo.app/consulting/?ref=plugin"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
7
+ </div>
8
+
9
+
10
+ Capture audio clips across iOS, Android, and the Web with a consistent Capacitor API.
11
+
12
+ WIP: the plugin is not yet ready for production
13
+
14
+ ## Documentation
15
+
16
+ The most complete doc is available here: https://capgo.app/docs/plugins/audio-recorder/
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @capgo/capacitor-audio-recorder
22
+ npx cap sync
23
+ ```
24
+
25
+ ## API
26
+
27
+ <docgen-index>
28
+
29
+ * [`startRecording(...)`](#startrecording)
30
+ * [`pauseRecording()`](#pauserecording)
31
+ * [`resumeRecording()`](#resumerecording)
32
+ * [`stopRecording()`](#stoprecording)
33
+ * [`cancelRecording()`](#cancelrecording)
34
+ * [`getRecordingStatus()`](#getrecordingstatus)
35
+ * [`checkPermissions()`](#checkpermissions)
36
+ * [`requestPermissions()`](#requestpermissions)
37
+ * [`addListener('recordingError', ...)`](#addlistenerrecordingerror-)
38
+ * [`addListener('recordingPaused', ...)`](#addlistenerrecordingpaused-)
39
+ * [`addListener('recordingStopped', ...)`](#addlistenerrecordingstopped-)
40
+ * [`removeAllListeners()`](#removealllisteners)
41
+ * [Interfaces](#interfaces)
42
+ * [Type Aliases](#type-aliases)
43
+ * [Enums](#enums)
44
+
45
+ </docgen-index>
46
+
47
+ <docgen-api>
48
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
49
+
50
+ Capacitor plugin contract for recording audio.
51
+
52
+ ### startRecording(...)
53
+
54
+ ```typescript
55
+ startRecording(options?: StartRecordingOptions | undefined) => Promise<void>
56
+ ```
57
+
58
+ Start recording audio using the device microphone.
59
+
60
+ | Param | Type | Description |
61
+ | ------------- | ----------------------------------------------------------------------- | -------------------------------- |
62
+ | **`options`** | <code><a href="#startrecordingoptions">StartRecordingOptions</a></code> | Recording configuration options. |
63
+
64
+ **Since:** 1.0.0
65
+
66
+ --------------------
67
+
68
+
69
+ ### pauseRecording()
70
+
71
+ ```typescript
72
+ pauseRecording() => Promise<void>
73
+ ```
74
+
75
+ Pause the ongoing recording. Only available on Android (API 24+), iOS, and Web.
76
+
77
+ **Since:** 1.0.0
78
+
79
+ --------------------
80
+
81
+
82
+ ### resumeRecording()
83
+
84
+ ```typescript
85
+ resumeRecording() => Promise<void>
86
+ ```
87
+
88
+ Resume a previously paused recording.
89
+
90
+ **Since:** 1.0.0
91
+
92
+ --------------------
93
+
94
+
95
+ ### stopRecording()
96
+
97
+ ```typescript
98
+ stopRecording() => Promise<StopRecordingResult>
99
+ ```
100
+
101
+ Stop the current recording and persist the recorded audio.
102
+
103
+ **Returns:** <code>Promise&lt;<a href="#stoprecordingresult">StopRecordingResult</a>&gt;</code>
104
+
105
+ **Since:** 1.0.0
106
+
107
+ --------------------
108
+
109
+
110
+ ### cancelRecording()
111
+
112
+ ```typescript
113
+ cancelRecording() => Promise<void>
114
+ ```
115
+
116
+ Cancel the current recording and discard any captured audio.
117
+
118
+ **Since:** 1.0.0
119
+
120
+ --------------------
121
+
122
+
123
+ ### getRecordingStatus()
124
+
125
+ ```typescript
126
+ getRecordingStatus() => Promise<GetRecordingStatusResult>
127
+ ```
128
+
129
+ Retrieve the current recording status.
130
+
131
+ **Returns:** <code>Promise&lt;<a href="#getrecordingstatusresult">GetRecordingStatusResult</a>&gt;</code>
132
+
133
+ **Since:** 1.0.0
134
+
135
+ --------------------
136
+
137
+
138
+ ### checkPermissions()
139
+
140
+ ```typescript
141
+ checkPermissions() => Promise<PermissionStatus>
142
+ ```
143
+
144
+ Return the current permission state for accessing the microphone.
145
+
146
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
147
+
148
+ **Since:** 1.0.0
149
+
150
+ --------------------
151
+
152
+
153
+ ### requestPermissions()
154
+
155
+ ```typescript
156
+ requestPermissions() => Promise<PermissionStatus>
157
+ ```
158
+
159
+ Request permission to access the microphone.
160
+
161
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
162
+
163
+ **Since:** 1.0.0
164
+
165
+ --------------------
166
+
167
+
168
+ ### addListener('recordingError', ...)
169
+
170
+ ```typescript
171
+ addListener(eventName: 'recordingError', listenerFunc: (event: RecordingErrorEvent) => void) => Promise<PluginListenerHandle>
172
+ ```
173
+
174
+ Listen for recording errors.
175
+
176
+ | Param | Type |
177
+ | ------------------ | --------------------------------------------------------------------------------------- |
178
+ | **`eventName`** | <code>'recordingError'</code> |
179
+ | **`listenerFunc`** | <code>(event: <a href="#recordingerrorevent">RecordingErrorEvent</a>) =&gt; void</code> |
180
+
181
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
182
+
183
+ **Since:** 1.0.0
184
+
185
+ --------------------
186
+
187
+
188
+ ### addListener('recordingPaused', ...)
189
+
190
+ ```typescript
191
+ addListener(eventName: 'recordingPaused', listenerFunc: () => void) => Promise<PluginListenerHandle>
192
+ ```
193
+
194
+ Listen for pause events emitted when a recording is paused.
195
+
196
+ | Param | Type |
197
+ | ------------------ | ------------------------------ |
198
+ | **`eventName`** | <code>'recordingPaused'</code> |
199
+ | **`listenerFunc`** | <code>() =&gt; void</code> |
200
+
201
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
202
+
203
+ **Since:** 1.0.0
204
+
205
+ --------------------
206
+
207
+
208
+ ### addListener('recordingStopped', ...)
209
+
210
+ ```typescript
211
+ addListener(eventName: 'recordingStopped', listenerFunc: (event: RecordingStoppedEvent) => void) => Promise<PluginListenerHandle>
212
+ ```
213
+
214
+ Listen for recording completion events.
215
+
216
+ | Param | Type |
217
+ | ------------------ | --------------------------------------------------------------------------------------- |
218
+ | **`eventName`** | <code>'recordingStopped'</code> |
219
+ | **`listenerFunc`** | <code>(event: <a href="#stoprecordingresult">StopRecordingResult</a>) =&gt; void</code> |
220
+
221
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
222
+
223
+ **Since:** 1.0.0
224
+
225
+ --------------------
226
+
227
+
228
+ ### removeAllListeners()
229
+
230
+ ```typescript
231
+ removeAllListeners() => Promise<void>
232
+ ```
233
+
234
+ Remove all registered listeners.
235
+
236
+ **Since:** 1.0.0
237
+
238
+ --------------------
239
+
240
+
241
+ ### Interfaces
242
+
243
+
244
+ #### StartRecordingOptions
245
+
246
+ Options accepted by {@link CapacitorAudioRecorderPlugin.startRecording}.
247
+
248
+ | Prop | Type | Description | Since |
249
+ | --------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------- | ----- |
250
+ | **`audioSessionCategoryOptions`** | <code>AudioSessionCategoryOption[]</code> | The audio session category options for recording. Only available on iOS. | 1.0.0 |
251
+ | **`audioSessionMode`** | <code><a href="#audiosessionmode">AudioSessionMode</a></code> | The audio session mode for recording. Only available on iOS. | 1.0.0 |
252
+ | **`bitRate`** | <code>number</code> | The audio bit rate in bytes per second. Only available on Android and iOS. | 1.0.0 |
253
+ | **`sampleRate`** | <code>number</code> | The audio sample rate in Hz. Only available on Android and iOS. | 1.0.0 |
254
+
255
+
256
+ #### StopRecordingResult
257
+
258
+ Result returned by {@link CapacitorAudioRecorderPlugin.stopRecording}.
259
+
260
+ | Prop | Type | Description | Since |
261
+ | -------------- | ------------------- | ------------------------------------------------------------------------- | ----- |
262
+ | **`blob`** | <code>Blob</code> | The recorded audio as a Blob. Only available on Web. | 1.0.0 |
263
+ | **`duration`** | <code>number</code> | The duration of the recording in milliseconds. | 1.0.0 |
264
+ | **`uri`** | <code>string</code> | The URI pointing to the recorded file. Only available on Android and iOS. | 1.0.0 |
265
+
266
+
267
+ #### GetRecordingStatusResult
268
+
269
+ Result returned by {@link CapacitorAudioRecorderPlugin.getRecordingStatus}.
270
+
271
+ | Prop | Type | Description | Since |
272
+ | ------------ | ----------------------------------------------------------- | ----------------------------- | ----- |
273
+ | **`status`** | <code><a href="#recordingstatus">RecordingStatus</a></code> | The current recording status. | 1.0.0 |
274
+
275
+
276
+ #### PermissionStatus
277
+
278
+ Permission information returned by {@link CapacitorAudioRecorderPlugin.checkPermissions}
279
+ and {@link CapacitorAudioRecorderPlugin.requestPermissions}.
280
+
281
+ | Prop | Type | Description | Since |
282
+ | ----------------- | ----------------------------------------------------------- | ----------------------------------------- | ----- |
283
+ | **`recordAudio`** | <code><a href="#permissionstate">PermissionState</a></code> | The permission state for audio recording. | 1.0.0 |
284
+
285
+
286
+ #### PluginListenerHandle
287
+
288
+ | Prop | Type |
289
+ | ------------ | ----------------------------------------- |
290
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
291
+
292
+
293
+ #### RecordingErrorEvent
294
+
295
+ Event emitted when an error occurs during recording.
296
+
297
+ | Prop | Type | Description | Since |
298
+ | ------------- | ------------------- | ------------------ | ----- |
299
+ | **`message`** | <code>string</code> | The error message. | 1.0.0 |
300
+
301
+
302
+ ### Type Aliases
303
+
304
+
305
+ #### PermissionState
306
+
307
+ <code>'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'</code>
308
+
309
+
310
+ #### RecordingStoppedEvent
311
+
312
+ Event emitted when a recording completes.
313
+
314
+ <code><a href="#stoprecordingresult">StopRecordingResult</a></code>
315
+
316
+
317
+ ### Enums
318
+
319
+
320
+ #### AudioSessionCategoryOption
321
+
322
+ | Members | Value |
323
+ | ------------------------------------------ | --------------------------------------------------------- |
324
+ | **`AllowAirPlay`** | <code>'ALLOW_AIR_PLAY'</code> |
325
+ | **`AllowBluetooth`** | <code>'ALLOW_BLUETOOTH'</code> |
326
+ | **`AllowBluetoothA2DP`** | <code>'ALLOW_BLUETOOTH_A2DP'</code> |
327
+ | **`DefaultToSpeaker`** | <code>'DEFAULT_TO_SPEAKER'</code> |
328
+ | **`DuckOthers`** | <code>'DUCK_OTHERS'</code> |
329
+ | **`InterruptSpokenAudioAndMixWithOthers`** | <code>'INTERRUPT_SPOKEN_AUDIO_AND_MIX_WITH_OTHERS'</code> |
330
+ | **`MixWithOthers`** | <code>'MIX_WITH_OTHERS'</code> |
331
+ | **`OverrideMutedMicrophoneInterruption`** | <code>'OVERRIDE_MUTED_MICROPHONE_INTERRUPTION'</code> |
332
+
333
+
334
+ #### AudioSessionMode
335
+
336
+ | Members | Value |
337
+ | -------------------- | ------------------------------ |
338
+ | **`Default`** | <code>'DEFAULT'</code> |
339
+ | **`GameChat`** | <code>'GAME_CHAT'</code> |
340
+ | **`Measurement`** | <code>'MEASUREMENT'</code> |
341
+ | **`SpokenAudio`** | <code>'SPOKEN_AUDIO'</code> |
342
+ | **`VideoChat`** | <code>'VIDEO_CHAT'</code> |
343
+ | **`VideoRecording`** | <code>'VIDEO_RECORDING'</code> |
344
+ | **`VoiceChat`** | <code>'VOICE_CHAT'</code> |
345
+
346
+
347
+ #### RecordingStatus
348
+
349
+ | Members | Value |
350
+ | --------------- | ------------------------ |
351
+ | **`Inactive`** | <code>'INACTIVE'</code> |
352
+ | **`Recording`** | <code>'RECORDING'</code> |
353
+ | **`Paused`** | <code>'PAUSED'</code> |
354
+
355
+ </docgen-api>
356
+
357
+ ### Credit
358
+
359
+ This plugin was inspired from: https://github.com/kesha-antonov/react-native-background-downloader
@@ -0,0 +1,57 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.7.2'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "app.capgo.audiorecorder"
22
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_21
41
+ targetCompatibility JavaVersion.VERSION_21
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+ dependencies {
51
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
52
+ implementation project(':capacitor-android')
53
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
54
+ testImplementation "junit:junit:$junitVersion"
55
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
56
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
57
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>