@scr2em/capacitor-plugin-recorder 0.0.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.
@@ -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 = 'CapacitorPluginRecorder'
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 = '15.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapacitorPluginRecorder",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "CapacitorPluginRecorder",
10
+ targets: ["RecorderPlayerPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "RecorderPlayerPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/RecorderPlayerPlugin"),
23
+ .testTarget(
24
+ name: "RecorderPlayerPluginTests",
25
+ dependencies: ["RecorderPlayerPlugin"],
26
+ path: "ios/Tests/RecorderPlayerPluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,395 @@
1
+ # capacitor-plugin-recorder
2
+
3
+ ee
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install capacitor-plugin-recorder
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`requestPermission()`](#requestpermission)
17
+ * [`checkPermission()`](#checkpermission)
18
+ * [`startRecord(...)`](#startrecord)
19
+ * [`stopRecord()`](#stoprecord)
20
+ * [`pauseRecord()`](#pauserecord)
21
+ * [`resumeRecord()`](#resumerecord)
22
+ * [`preparePlay(...)`](#prepareplay)
23
+ * [`play(...)`](#play)
24
+ * [`pausePlay(...)`](#pauseplay)
25
+ * [`resumePlay(...)`](#resumeplay)
26
+ * [`stopPlay(...)`](#stopplay)
27
+ * [`seekTo(...)`](#seekto)
28
+ * [`getPlaybackStatus(...)`](#getplaybackstatus)
29
+ * [`getRecordingStatus()`](#getrecordingstatus)
30
+ * [`destroyPlayer(...)`](#destroyplayer)
31
+ * [`addListener('recordingStatusChange', ...)`](#addlistenerrecordingstatuschange-)
32
+ * [`addListener('playbackStatusChange', ...)`](#addlistenerplaybackstatuschange-)
33
+ * [`removeAllListeners()`](#removealllisteners)
34
+ * [Interfaces](#interfaces)
35
+ * [Type Aliases](#type-aliases)
36
+
37
+ </docgen-index>
38
+
39
+ <docgen-api>
40
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
41
+
42
+ ### requestPermission()
43
+
44
+ ```typescript
45
+ requestPermission() => Promise<PermissionStatus>
46
+ ```
47
+
48
+ Request microphone permission
49
+
50
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
51
+
52
+ --------------------
53
+
54
+
55
+ ### checkPermission()
56
+
57
+ ```typescript
58
+ checkPermission() => Promise<PermissionStatus>
59
+ ```
60
+
61
+ Check current permission status
62
+
63
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
64
+
65
+ --------------------
66
+
67
+
68
+ ### startRecord(...)
69
+
70
+ ```typescript
71
+ startRecord(options?: StartRecordOptions | undefined) => Promise<void>
72
+ ```
73
+
74
+ Start recording audio
75
+
76
+ | Param | Type |
77
+ | ------------- | ----------------------------------------------------------------- |
78
+ | **`options`** | <code><a href="#startrecordoptions">StartRecordOptions</a></code> |
79
+
80
+ --------------------
81
+
82
+
83
+ ### stopRecord()
84
+
85
+ ```typescript
86
+ stopRecord() => Promise<StopRecordResult>
87
+ ```
88
+
89
+ Stop recording and return the recorded file path
90
+
91
+ **Returns:** <code>Promise&lt;<a href="#stoprecordresult">StopRecordResult</a>&gt;</code>
92
+
93
+ --------------------
94
+
95
+
96
+ ### pauseRecord()
97
+
98
+ ```typescript
99
+ pauseRecord() => Promise<void>
100
+ ```
101
+
102
+ Pause the current recording
103
+
104
+ --------------------
105
+
106
+
107
+ ### resumeRecord()
108
+
109
+ ```typescript
110
+ resumeRecord() => Promise<void>
111
+ ```
112
+
113
+ Resume a paused recording
114
+
115
+ --------------------
116
+
117
+
118
+ ### preparePlay(...)
119
+
120
+ ```typescript
121
+ preparePlay(options: PlayOptions) => Promise<PreparePlayResult>
122
+ ```
123
+
124
+ Prepare an audio file for playback (loads metadata without playing).
125
+ Returns a playerId that must be used for all subsequent operations on this player.
126
+
127
+ | Param | Type |
128
+ | ------------- | --------------------------------------------------- |
129
+ | **`options`** | <code><a href="#playoptions">PlayOptions</a></code> |
130
+
131
+ **Returns:** <code>Promise&lt;<a href="#prepareplayresult">PreparePlayResult</a>&gt;</code>
132
+
133
+ --------------------
134
+
135
+
136
+ ### play(...)
137
+
138
+ ```typescript
139
+ play(options: PlayerOptions) => Promise<void>
140
+ ```
141
+
142
+ Start playing an audio file
143
+
144
+ | Param | Type |
145
+ | ------------- | ------------------------------------------------------- |
146
+ | **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |
147
+
148
+ --------------------
149
+
150
+
151
+ ### pausePlay(...)
152
+
153
+ ```typescript
154
+ pausePlay(options: PlayerOptions) => Promise<void>
155
+ ```
156
+
157
+ Pause audio playback
158
+
159
+ | Param | Type |
160
+ | ------------- | ------------------------------------------------------- |
161
+ | **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |
162
+
163
+ --------------------
164
+
165
+
166
+ ### resumePlay(...)
167
+
168
+ ```typescript
169
+ resumePlay(options: PlayerOptions) => Promise<void>
170
+ ```
171
+
172
+ Resume paused audio playback
173
+
174
+ | Param | Type |
175
+ | ------------- | ------------------------------------------------------- |
176
+ | **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |
177
+
178
+ --------------------
179
+
180
+
181
+ ### stopPlay(...)
182
+
183
+ ```typescript
184
+ stopPlay(options: PlayerOptions) => Promise<void>
185
+ ```
186
+
187
+ Stop audio playback
188
+
189
+ | Param | Type |
190
+ | ------------- | ------------------------------------------------------- |
191
+ | **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |
192
+
193
+ --------------------
194
+
195
+
196
+ ### seekTo(...)
197
+
198
+ ```typescript
199
+ seekTo(options: SeekOptions) => Promise<void>
200
+ ```
201
+
202
+ Seek to a specific position in the audio
203
+
204
+ | Param | Type |
205
+ | ------------- | --------------------------------------------------- |
206
+ | **`options`** | <code><a href="#seekoptions">SeekOptions</a></code> |
207
+
208
+ --------------------
209
+
210
+
211
+ ### getPlaybackStatus(...)
212
+
213
+ ```typescript
214
+ getPlaybackStatus(options: PlayerOptions) => Promise<PlaybackStatusChangeEvent>
215
+ ```
216
+
217
+ Get current playback status for a specific player
218
+
219
+ | Param | Type |
220
+ | ------------- | ------------------------------------------------------- |
221
+ | **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |
222
+
223
+ **Returns:** <code>Promise&lt;<a href="#playbackstatuschangeevent">PlaybackStatusChangeEvent</a>&gt;</code>
224
+
225
+ --------------------
226
+
227
+
228
+ ### getRecordingStatus()
229
+
230
+ ```typescript
231
+ getRecordingStatus() => Promise<RecordingStatusChangeEvent>
232
+ ```
233
+
234
+ Get current recording status
235
+
236
+ **Returns:** <code>Promise&lt;<a href="#recordingstatuschangeevent">RecordingStatusChangeEvent</a>&gt;</code>
237
+
238
+ --------------------
239
+
240
+
241
+ ### destroyPlayer(...)
242
+
243
+ ```typescript
244
+ destroyPlayer(options: PlayerOptions) => Promise<void>
245
+ ```
246
+
247
+ Destroy a player and release its resources
248
+
249
+ | Param | Type |
250
+ | ------------- | ------------------------------------------------------- |
251
+ | **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |
252
+
253
+ --------------------
254
+
255
+
256
+ ### addListener('recordingStatusChange', ...)
257
+
258
+ ```typescript
259
+ addListener(eventName: 'recordingStatusChange', listenerFunc: (event: RecordingStatusChangeEvent) => void) => Promise<PluginListenerHandle>
260
+ ```
261
+
262
+ Listen for recording status changes
263
+
264
+ | Param | Type |
265
+ | ------------------ | ----------------------------------------------------------------------------------------------------- |
266
+ | **`eventName`** | <code>'recordingStatusChange'</code> |
267
+ | **`listenerFunc`** | <code>(event: <a href="#recordingstatuschangeevent">RecordingStatusChangeEvent</a>) =&gt; void</code> |
268
+
269
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
270
+
271
+ --------------------
272
+
273
+
274
+ ### addListener('playbackStatusChange', ...)
275
+
276
+ ```typescript
277
+ addListener(eventName: 'playbackStatusChange', listenerFunc: (event: PlaybackStatusChangeEvent) => void) => Promise<PluginListenerHandle>
278
+ ```
279
+
280
+ Listen for playback status changes (includes playerId to identify which player)
281
+
282
+ | Param | Type |
283
+ | ------------------ | --------------------------------------------------------------------------------------------------- |
284
+ | **`eventName`** | <code>'playbackStatusChange'</code> |
285
+ | **`listenerFunc`** | <code>(event: <a href="#playbackstatuschangeevent">PlaybackStatusChangeEvent</a>) =&gt; void</code> |
286
+
287
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
288
+
289
+ --------------------
290
+
291
+
292
+ ### removeAllListeners()
293
+
294
+ ```typescript
295
+ removeAllListeners() => Promise<void>
296
+ ```
297
+
298
+ Remove all listeners
299
+
300
+ --------------------
301
+
302
+
303
+ ### Interfaces
304
+
305
+
306
+ #### PermissionStatus
307
+
308
+ | Prop | Type |
309
+ | ---------------- | ---------------------------------------------- |
310
+ | **`microphone`** | <code>'granted' \| 'denied' \| 'prompt'</code> |
311
+
312
+
313
+ #### StartRecordOptions
314
+
315
+ | Prop | Type | Description |
316
+ | ---------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
317
+ | **`path`** | <code>string</code> | Optional relative path for the recording (including extension), relative to the app's data directory. If not provided, a default filename will be used. |
318
+
319
+
320
+ #### StopRecordResult
321
+
322
+ | Prop | Type | Description |
323
+ | -------------- | ------------------- | ----------------------------------------- |
324
+ | **`path`** | <code>string</code> | Path to the recorded file |
325
+ | **`duration`** | <code>number</code> | Duration of the recording in milliseconds |
326
+
327
+
328
+ #### PreparePlayResult
329
+
330
+ | Prop | Type | Description |
331
+ | -------------- | ------------------- | ------------------------------------------ |
332
+ | **`playerId`** | <code>string</code> | Unique identifier for this player instance |
333
+ | **`duration`** | <code>number</code> | Duration of the audio in milliseconds |
334
+
335
+
336
+ #### PlayOptions
337
+
338
+ | Prop | Type | Description |
339
+ | ---------- | ------------------- | ------------------------------------------------------------------------------ |
340
+ | **`path`** | <code>string</code> | Relative path to the audio file to play (relative to the app's data directory) |
341
+
342
+
343
+ #### PlayerOptions
344
+
345
+ | Prop | Type | Description |
346
+ | -------------- | ------------------- | --------------------------------------- |
347
+ | **`playerId`** | <code>string</code> | The player ID returned from preparePlay |
348
+
349
+
350
+ #### SeekOptions
351
+
352
+ | Prop | Type | Description |
353
+ | -------------- | ------------------- | --------------------------------------- |
354
+ | **`playerId`** | <code>string</code> | The player ID returned from preparePlay |
355
+ | **`position`** | <code>number</code> | Position to seek to in milliseconds |
356
+
357
+
358
+ #### PlaybackStatusChangeEvent
359
+
360
+ | Prop | Type | Description |
361
+ | --------------------- | --------------------------------------------------------- | ------------------------------------------- |
362
+ | **`playerId`** | <code>string</code> | The player ID this event belongs to |
363
+ | **`status`** | <code><a href="#playbackstatus">PlaybackStatus</a></code> | |
364
+ | **`currentPosition`** | <code>number</code> | Current playback position in milliseconds |
365
+ | **`duration`** | <code>number</code> | Total duration of the audio in milliseconds |
366
+
367
+
368
+ #### RecordingStatusChangeEvent
369
+
370
+ | Prop | Type | Description |
371
+ | -------------- | ----------------------------------------------------------- | ------------------------------------------ |
372
+ | **`status`** | <code><a href="#recordingstatus">RecordingStatus</a></code> | |
373
+ | **`duration`** | <code>number</code> | Current recording duration in milliseconds |
374
+
375
+
376
+ #### PluginListenerHandle
377
+
378
+ | Prop | Type |
379
+ | ------------ | ----------------------------------------- |
380
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
381
+
382
+
383
+ ### Type Aliases
384
+
385
+
386
+ #### PlaybackStatus
387
+
388
+ <code>'playing' | 'paused' | 'stopped' | 'ended'</code>
389
+
390
+
391
+ #### RecordingStatus
392
+
393
+ <code>'recording' | 'paused' | 'stopped'</code>
394
+
395
+ </docgen-api>
@@ -0,0 +1,58 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.13.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace = "com.capacitor.recorderplayer"
22
+ compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
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
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
3
+ </manifest>