@capgo/capacitor-native-audio 8.4.3
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.
- package/CapgoCapacitorNativeAudio.podspec +16 -0
- package/LICENSE +373 -0
- package/Package.swift +31 -0
- package/README.md +1229 -0
- package/android/build.gradle +89 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/ee/forgr/audio/AudioAsset.java +611 -0
- package/android/src/main/java/ee/forgr/audio/AudioCompletionListener.java +5 -0
- package/android/src/main/java/ee/forgr/audio/AudioDispatcher.java +208 -0
- package/android/src/main/java/ee/forgr/audio/Constant.java +36 -0
- package/android/src/main/java/ee/forgr/audio/HlsAvailabilityChecker.java +84 -0
- package/android/src/main/java/ee/forgr/audio/Logger.java +55 -0
- package/android/src/main/java/ee/forgr/audio/NativeAudio.java +2022 -0
- package/android/src/main/java/ee/forgr/audio/RemoteAudioAsset.java +886 -0
- package/android/src/main/java/ee/forgr/audio/StreamAudioAsset.java +708 -0
- package/android/src/main/res/values/colors.xml +3 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/main/res/values/styles.xml +3 -0
- package/dist/docs.json +1470 -0
- package/dist/esm/audio-asset.d.ts +4 -0
- package/dist/esm/audio-asset.js +6 -0
- package/dist/esm/audio-asset.js.map +1 -0
- package/dist/esm/definitions.d.ts +597 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +82 -0
- package/dist/esm/web.js +553 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +571 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +574 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/NativeAudioPlugin/AudioAsset+Fade.swift +157 -0
- package/ios/Sources/NativeAudioPlugin/AudioAsset.swift +403 -0
- package/ios/Sources/NativeAudioPlugin/Constant.swift +52 -0
- package/ios/Sources/NativeAudioPlugin/Logger.swift +43 -0
- package/ios/Sources/NativeAudioPlugin/Plugin.swift +1786 -0
- package/ios/Sources/NativeAudioPlugin/RemoteAudioAsset+Fade.swift +152 -0
- package/ios/Sources/NativeAudioPlugin/RemoteAudioAsset.swift +405 -0
- package/ios/Tests/NativeAudioPluginTests/PluginTests.swift +648 -0
- package/ios/Tests/README.md +39 -0
- package/package.json +101 -0
- package/scripts/configure-dependencies.js +251 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-asset.js","sourceRoot":"","sources":["../../src/audio-asset.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAU;IAGrB,YAAY,KAAuB;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF","sourcesContent":["export class AudioAsset {\n public readonly audio: HTMLAudioElement;\n\n constructor(audio: HTMLAudioElement) {\n this.audio = audio;\n }\n}\n"]}
|
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
import type { PluginListenerHandle } from '@capacitor/core';
|
|
2
|
+
export interface CompletedEvent {
|
|
3
|
+
/**
|
|
4
|
+
* Emit when a play completes
|
|
5
|
+
*
|
|
6
|
+
* @since 5.0.0
|
|
7
|
+
*/
|
|
8
|
+
assetId: string;
|
|
9
|
+
}
|
|
10
|
+
export type CompletedListener = (state: CompletedEvent) => void;
|
|
11
|
+
export interface Assets {
|
|
12
|
+
/**
|
|
13
|
+
* Asset Id, unique identifier of the file
|
|
14
|
+
*/
|
|
15
|
+
assetId: string;
|
|
16
|
+
}
|
|
17
|
+
export interface AssetVolume {
|
|
18
|
+
/**
|
|
19
|
+
* Asset Id, unique identifier of the file
|
|
20
|
+
*/
|
|
21
|
+
assetId: string;
|
|
22
|
+
/**
|
|
23
|
+
* Volume of the audio, between 0.1 and 1.0
|
|
24
|
+
*/
|
|
25
|
+
volume: number;
|
|
26
|
+
/**
|
|
27
|
+
* Time over which to fade to the target volume, in seconds. Default is 0s (immediate).
|
|
28
|
+
*/
|
|
29
|
+
duration?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface AssetRate {
|
|
32
|
+
/**
|
|
33
|
+
* Asset Id, unique identifier of the file
|
|
34
|
+
*/
|
|
35
|
+
assetId: string;
|
|
36
|
+
/**
|
|
37
|
+
* Rate of the audio, between 0.1 and 1.0
|
|
38
|
+
*/
|
|
39
|
+
rate: number;
|
|
40
|
+
}
|
|
41
|
+
export interface AssetSetTime {
|
|
42
|
+
/**
|
|
43
|
+
* Asset Id, unique identifier of the file
|
|
44
|
+
*/
|
|
45
|
+
assetId: string;
|
|
46
|
+
/**
|
|
47
|
+
* Time to set the audio, in seconds
|
|
48
|
+
*/
|
|
49
|
+
time: number;
|
|
50
|
+
}
|
|
51
|
+
export interface AssetPlayOptions {
|
|
52
|
+
/**
|
|
53
|
+
* Asset Id, unique identifier of the file
|
|
54
|
+
*/
|
|
55
|
+
assetId: string;
|
|
56
|
+
/**
|
|
57
|
+
* Time to start playing the audio, in seconds
|
|
58
|
+
*/
|
|
59
|
+
time?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Delay to start playing the audio, in seconds
|
|
62
|
+
*/
|
|
63
|
+
delay?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Volume of the audio, between 0.1 and 1.0
|
|
66
|
+
*/
|
|
67
|
+
volume?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Whether to fade in the audio
|
|
70
|
+
*/
|
|
71
|
+
fadeIn?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether to fade out the audio
|
|
74
|
+
*/
|
|
75
|
+
fadeOut?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Fade in duration in seconds.
|
|
78
|
+
* Only used if fadeIn is true.
|
|
79
|
+
* Default is 1s.
|
|
80
|
+
*/
|
|
81
|
+
fadeInDuration?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Fade out duration in seconds.
|
|
84
|
+
* Only used if fadeOut is true.
|
|
85
|
+
* Default is 1s.
|
|
86
|
+
*/
|
|
87
|
+
fadeOutDuration?: number;
|
|
88
|
+
/**
|
|
89
|
+
* Time in seconds from the start of the audio to start fading out.
|
|
90
|
+
* Only used if fadeOut is true.
|
|
91
|
+
* Default is fadeOutDuration before end of audio.
|
|
92
|
+
*/
|
|
93
|
+
fadeOutStartTime?: number;
|
|
94
|
+
}
|
|
95
|
+
export interface AssetStopOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Asset Id, unique identifier of the file
|
|
98
|
+
*/
|
|
99
|
+
assetId: string;
|
|
100
|
+
/**
|
|
101
|
+
* Whether to fade out the audio before stopping
|
|
102
|
+
*/
|
|
103
|
+
fadeOut?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Fade out duration in seconds.
|
|
106
|
+
* Default is 1s.
|
|
107
|
+
*/
|
|
108
|
+
fadeOutDuration?: number;
|
|
109
|
+
}
|
|
110
|
+
export interface AssetPauseOptions {
|
|
111
|
+
/**
|
|
112
|
+
* Asset Id, unique identifier of the file
|
|
113
|
+
*/
|
|
114
|
+
assetId: string;
|
|
115
|
+
/**
|
|
116
|
+
* Whether to fade out the audio before pausing
|
|
117
|
+
*/
|
|
118
|
+
fadeOut?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Fade out duration in seconds.
|
|
121
|
+
* Default is 1s.
|
|
122
|
+
*/
|
|
123
|
+
fadeOutDuration?: number;
|
|
124
|
+
}
|
|
125
|
+
export interface AssetResumeOptions {
|
|
126
|
+
/**
|
|
127
|
+
* Asset Id, unique identifier of the file
|
|
128
|
+
*/
|
|
129
|
+
assetId: string;
|
|
130
|
+
/**
|
|
131
|
+
* Whether to fade in the audio during resume
|
|
132
|
+
*/
|
|
133
|
+
fadeIn?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Fade in duration in seconds.
|
|
136
|
+
* Default is 1s.
|
|
137
|
+
*/
|
|
138
|
+
fadeInDuration?: number;
|
|
139
|
+
}
|
|
140
|
+
export interface ConfigureOptions {
|
|
141
|
+
/**
|
|
142
|
+
* focus the audio with Audio Focus
|
|
143
|
+
*/
|
|
144
|
+
focus?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Play the audio in the background
|
|
147
|
+
*/
|
|
148
|
+
background?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Ignore silent mode, works only on iOS setting this will nuke other audio apps
|
|
151
|
+
*/
|
|
152
|
+
ignoreSilent?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Show audio playback in the notification center (iOS and Android)
|
|
155
|
+
* When enabled, displays audio metadata (title, artist, album, artwork) in the system notification
|
|
156
|
+
* and Control Center (iOS) or lock screen.
|
|
157
|
+
*
|
|
158
|
+
* **Important iOS Behavior:**
|
|
159
|
+
* Enabling this option changes the audio session category to `.playback` with `.default` mode,
|
|
160
|
+
* which means your app's audio will **interrupt** other apps' audio (like background music from
|
|
161
|
+
* Spotify, Apple Music, etc.) instead of mixing with it. This is required for the Now Playing
|
|
162
|
+
* info to appear in Control Center and on the lock screen.
|
|
163
|
+
*
|
|
164
|
+
* **Trade-offs:**
|
|
165
|
+
* - `showNotification: true` → Shows Now Playing controls, but interrupts other audio
|
|
166
|
+
* - `showNotification: false` → Audio mixes with other apps, but no Now Playing controls
|
|
167
|
+
*
|
|
168
|
+
* Use this when your app is the primary audio source (music players, podcast apps, etc.).
|
|
169
|
+
* Disable this for secondary audio like sound effects or notification sounds where mixing
|
|
170
|
+
* with background music is preferred.
|
|
171
|
+
*
|
|
172
|
+
* @see https://github.com/Cap-go/capacitor-native-audio/issues/202
|
|
173
|
+
*/
|
|
174
|
+
showNotification?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Enable background audio playback (Android only)
|
|
177
|
+
*
|
|
178
|
+
* When enabled, audio will continue playing when the app is backgrounded or the screen is locked.
|
|
179
|
+
* The plugin will skip the automatic pause/resume logic that normally occurs when the app
|
|
180
|
+
* enters the background or returns to the foreground.
|
|
181
|
+
*
|
|
182
|
+
* **Important Android Requirements:**
|
|
183
|
+
* To use background playback on Android, your app must:
|
|
184
|
+
* 1. Declare the required permissions in `AndroidManifest.xml`:
|
|
185
|
+
* - `<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />`
|
|
186
|
+
* - `<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />`
|
|
187
|
+
* - `<uses-permission android:name="android.permission.WAKE_LOCK" />`
|
|
188
|
+
* 2. Start a Foreground Service with a media-style notification before backgrounding
|
|
189
|
+
* (the plugin does not automatically create or manage the foreground service)
|
|
190
|
+
* 3. Use `showNotification: true` to display playback controls in the notification
|
|
191
|
+
*
|
|
192
|
+
* **Usage Example:**
|
|
193
|
+
* ```typescript
|
|
194
|
+
* await NativeAudio.configure({
|
|
195
|
+
* backgroundPlayback: true,
|
|
196
|
+
* showNotification: true
|
|
197
|
+
* });
|
|
198
|
+
* // Start your foreground service here
|
|
199
|
+
* // Then preload and play audio as normal
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @default false
|
|
203
|
+
* @platform Android
|
|
204
|
+
* @since 8.2.0
|
|
205
|
+
*/
|
|
206
|
+
backgroundPlayback?: boolean;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Metadata to display in the notification center, Control Center (iOS), and lock screen
|
|
210
|
+
* when `showNotification` is enabled in `configure()`.
|
|
211
|
+
*
|
|
212
|
+
* Note: This metadata will only be displayed if `showNotification: true` is set in the
|
|
213
|
+
* `configure()` method. See {@link ConfigureOptions.showNotification} for important
|
|
214
|
+
* behavior details about audio mixing on iOS.
|
|
215
|
+
*/
|
|
216
|
+
export interface NotificationMetadata {
|
|
217
|
+
/**
|
|
218
|
+
* The title to display in the notification center
|
|
219
|
+
*/
|
|
220
|
+
title?: string;
|
|
221
|
+
/**
|
|
222
|
+
* The artist name to display in the notification center
|
|
223
|
+
*/
|
|
224
|
+
artist?: string;
|
|
225
|
+
/**
|
|
226
|
+
* The album name to display in the notification center
|
|
227
|
+
*/
|
|
228
|
+
album?: string;
|
|
229
|
+
/**
|
|
230
|
+
* URL or local path to the artwork/album art image
|
|
231
|
+
*/
|
|
232
|
+
artworkUrl?: string;
|
|
233
|
+
}
|
|
234
|
+
export interface PlayOnceOptions {
|
|
235
|
+
/**
|
|
236
|
+
* Path to the audio file, relative path of the file, absolute url (file://) or remote url (https://)
|
|
237
|
+
* Supported formats:
|
|
238
|
+
* - MP3, WAV (all platforms)
|
|
239
|
+
* - M3U8/HLS streams (iOS and Android)
|
|
240
|
+
*/
|
|
241
|
+
assetPath: string;
|
|
242
|
+
/**
|
|
243
|
+
* Volume of the audio, between 0.1 and 1.0
|
|
244
|
+
* @default 1.0
|
|
245
|
+
*/
|
|
246
|
+
volume?: number;
|
|
247
|
+
/**
|
|
248
|
+
* Is the audio file a URL, pass true if assetPath is a `file://` url
|
|
249
|
+
* or a streaming URL (m3u8)
|
|
250
|
+
* @default false
|
|
251
|
+
*/
|
|
252
|
+
isUrl?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Automatically start playback after loading
|
|
255
|
+
* @default true
|
|
256
|
+
*/
|
|
257
|
+
autoPlay?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Delete the audio file from disk after playback completes
|
|
260
|
+
* Only works for local files (file:// URLs), ignored for remote URLs
|
|
261
|
+
* @default false
|
|
262
|
+
* @since 7.11.0
|
|
263
|
+
*/
|
|
264
|
+
deleteAfterPlay?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Metadata to display in the notification center when audio is playing.
|
|
267
|
+
* Only used when `showNotification: true` is set in `configure()`.
|
|
268
|
+
*
|
|
269
|
+
* See {@link ConfigureOptions.showNotification} for important details about
|
|
270
|
+
* how this affects audio mixing behavior on iOS.
|
|
271
|
+
*
|
|
272
|
+
* @see NotificationMetadata
|
|
273
|
+
* @since 7.10.0
|
|
274
|
+
*/
|
|
275
|
+
notificationMetadata?: NotificationMetadata;
|
|
276
|
+
/**
|
|
277
|
+
* Custom HTTP headers to include when fetching remote audio files.
|
|
278
|
+
* Only used when isUrl is true and assetPath is a remote URL (http/https).
|
|
279
|
+
* Example: { 'x-api-key': 'abc123', 'Authorization': 'Bearer token' }
|
|
280
|
+
*
|
|
281
|
+
* @since 7.10.0
|
|
282
|
+
*/
|
|
283
|
+
headers?: Record<string, string>;
|
|
284
|
+
}
|
|
285
|
+
export interface PlayOnceResult {
|
|
286
|
+
/**
|
|
287
|
+
* The internally generated asset ID for this playback
|
|
288
|
+
* Can be used to control playback (pause, stop, etc.) before completion
|
|
289
|
+
*/
|
|
290
|
+
assetId: string;
|
|
291
|
+
}
|
|
292
|
+
export interface PreloadOptions {
|
|
293
|
+
/**
|
|
294
|
+
* Path to the audio file, relative path of the file, absolute url (file://) or remote url (https://)
|
|
295
|
+
* Supported formats:
|
|
296
|
+
* - MP3, WAV (all platforms)
|
|
297
|
+
* - M3U8/HLS streams (iOS and Android)
|
|
298
|
+
*/
|
|
299
|
+
assetPath: string;
|
|
300
|
+
/**
|
|
301
|
+
* Asset Id, unique identifier of the file
|
|
302
|
+
*/
|
|
303
|
+
assetId: string;
|
|
304
|
+
/**
|
|
305
|
+
* Volume of the audio, between 0.1 and 1.0
|
|
306
|
+
*/
|
|
307
|
+
volume?: number;
|
|
308
|
+
/**
|
|
309
|
+
* Audio channel number, default is 1
|
|
310
|
+
*/
|
|
311
|
+
audioChannelNum?: number;
|
|
312
|
+
/**
|
|
313
|
+
* Is the audio file a URL, pass true if assetPath is a `file://` url
|
|
314
|
+
* or a streaming URL (m3u8)
|
|
315
|
+
*/
|
|
316
|
+
isUrl?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Metadata to display in the notification center when audio is playing.
|
|
319
|
+
* Only used when `showNotification: true` is set in `configure()`.
|
|
320
|
+
*
|
|
321
|
+
* See {@link ConfigureOptions.showNotification} for important details about
|
|
322
|
+
* how this affects audio mixing behavior on iOS.
|
|
323
|
+
*
|
|
324
|
+
* @see NotificationMetadata
|
|
325
|
+
*/
|
|
326
|
+
notificationMetadata?: NotificationMetadata;
|
|
327
|
+
/**
|
|
328
|
+
* Custom HTTP headers to include when fetching remote audio files.
|
|
329
|
+
* Only used when isUrl is true and assetPath is a remote URL (http/https).
|
|
330
|
+
* Example: { 'x-api-key': 'abc123', 'Authorization': 'Bearer token' }
|
|
331
|
+
*
|
|
332
|
+
* @since 7.10.0
|
|
333
|
+
*/
|
|
334
|
+
headers?: Record<string, string>;
|
|
335
|
+
}
|
|
336
|
+
export interface CurrentTimeEvent {
|
|
337
|
+
/**
|
|
338
|
+
* Current time of the audio in seconds
|
|
339
|
+
* @since 6.5.0
|
|
340
|
+
*/
|
|
341
|
+
currentTime: number;
|
|
342
|
+
/**
|
|
343
|
+
* Asset Id of the audio
|
|
344
|
+
* @since 6.5.0
|
|
345
|
+
*/
|
|
346
|
+
assetId: string;
|
|
347
|
+
}
|
|
348
|
+
export type CurrentTimeListener = (state: CurrentTimeEvent) => void;
|
|
349
|
+
export type PlaybackStateValue = 'playing' | 'paused' | 'stopped';
|
|
350
|
+
export interface PlaybackStateEvent {
|
|
351
|
+
/**
|
|
352
|
+
* Asset Id of the audio
|
|
353
|
+
*/
|
|
354
|
+
assetId: string;
|
|
355
|
+
/**
|
|
356
|
+
* Resolved playback state after a local or remote transport action.
|
|
357
|
+
*/
|
|
358
|
+
state: PlaybackStateValue;
|
|
359
|
+
/**
|
|
360
|
+
* Reason for the state change, for example `play`, `pause`, `remotePlay`, or `complete`.
|
|
361
|
+
*/
|
|
362
|
+
reason: string;
|
|
363
|
+
/**
|
|
364
|
+
* Whether the asset is currently playing.
|
|
365
|
+
*/
|
|
366
|
+
isPlaying: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Current playback position in seconds when available.
|
|
369
|
+
*/
|
|
370
|
+
currentTime?: number;
|
|
371
|
+
/**
|
|
372
|
+
* Total playback duration in seconds when available.
|
|
373
|
+
*/
|
|
374
|
+
duration?: number;
|
|
375
|
+
}
|
|
376
|
+
export type PlaybackStateListener = (state: PlaybackStateEvent) => void;
|
|
377
|
+
export interface NativeAudio {
|
|
378
|
+
/**
|
|
379
|
+
* Configure the audio player
|
|
380
|
+
* @since 5.0.0
|
|
381
|
+
* @param option {@link ConfigureOptions}
|
|
382
|
+
* @returns
|
|
383
|
+
*/
|
|
384
|
+
configure(options: ConfigureOptions): Promise<void>;
|
|
385
|
+
/**
|
|
386
|
+
* Load an audio file
|
|
387
|
+
* @since 5.0.0
|
|
388
|
+
* @param option {@link PreloadOptions}
|
|
389
|
+
* @returns
|
|
390
|
+
*/
|
|
391
|
+
preload(options: PreloadOptions): Promise<void>;
|
|
392
|
+
/**
|
|
393
|
+
* Play an audio file once with automatic cleanup
|
|
394
|
+
*
|
|
395
|
+
* Method designed for simple, single-shot audio playback,
|
|
396
|
+
* such as notification sounds, UI feedback, or other short audio clips
|
|
397
|
+
* that don't require manual state management.
|
|
398
|
+
*
|
|
399
|
+
* **Key Features:**
|
|
400
|
+
* - **Fire-and-forget**: No need to manually preload, play, stop, or unload
|
|
401
|
+
* - **Auto-cleanup**: Asset is automatically unloaded after playback completes
|
|
402
|
+
* - **Optional file deletion**: Can delete local files after playback (useful for temp files)
|
|
403
|
+
* - **Returns assetId**: Can still control playback if needed (pause, stop, etc.)
|
|
404
|
+
*
|
|
405
|
+
* **Use Cases:**
|
|
406
|
+
* - Notification sounds
|
|
407
|
+
* - UI sound effects (button clicks, alerts)
|
|
408
|
+
* - Short audio clips that play once
|
|
409
|
+
* - Temporary audio files that should be cleaned up
|
|
410
|
+
*
|
|
411
|
+
* **Comparison with regular play():**
|
|
412
|
+
* - `play()`: Requires manual preload, play, and unload steps
|
|
413
|
+
* - `playOnce()`: Handles everything automatically with a single call
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* // Simple one-shot playback
|
|
418
|
+
* await NativeAudio.playOnce({ assetPath: 'audio/notification.mp3' });
|
|
419
|
+
*
|
|
420
|
+
* // Play and delete the file after completion
|
|
421
|
+
* await NativeAudio.playOnce({
|
|
422
|
+
* assetPath: 'file:///path/to/temp/audio.mp3',
|
|
423
|
+
* isUrl: true,
|
|
424
|
+
* deleteAfterPlay: true
|
|
425
|
+
* });
|
|
426
|
+
*
|
|
427
|
+
* // Get the assetId to control playback
|
|
428
|
+
* const { assetId } = await NativeAudio.playOnce({
|
|
429
|
+
* assetPath: 'audio/long-track.mp3',
|
|
430
|
+
* autoPlay: true
|
|
431
|
+
* });
|
|
432
|
+
* // Later, you can stop it manually if needed
|
|
433
|
+
* await NativeAudio.stop({ assetId });
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @since 7.11.0
|
|
437
|
+
* @param options {@link PlayOnceOptions}
|
|
438
|
+
* @returns {Promise<PlayOnceResult>} Object containing the generated assetId
|
|
439
|
+
*/
|
|
440
|
+
playOnce(options: PlayOnceOptions): Promise<PlayOnceResult>;
|
|
441
|
+
/**
|
|
442
|
+
* Check if an audio file is preloaded
|
|
443
|
+
*
|
|
444
|
+
* @since 6.1.0
|
|
445
|
+
* @param option {@link Assets}
|
|
446
|
+
* @returns {Promise<boolean>}
|
|
447
|
+
*/
|
|
448
|
+
isPreloaded(options: PreloadOptions): Promise<{
|
|
449
|
+
found: boolean;
|
|
450
|
+
}>;
|
|
451
|
+
/**
|
|
452
|
+
* Play an audio file
|
|
453
|
+
* @since 5.0.0
|
|
454
|
+
* @param option {@link AssetPlayOptions}
|
|
455
|
+
* @returns
|
|
456
|
+
*/
|
|
457
|
+
play(options: AssetPlayOptions): Promise<void>;
|
|
458
|
+
/**
|
|
459
|
+
* Pause an audio file
|
|
460
|
+
* @since 5.0.0
|
|
461
|
+
* @param option {@link AssetPauseOptions}
|
|
462
|
+
* @returns
|
|
463
|
+
*/
|
|
464
|
+
pause(options: AssetPauseOptions): Promise<void>;
|
|
465
|
+
/**
|
|
466
|
+
* Resume an audio file
|
|
467
|
+
* @since 5.0.0
|
|
468
|
+
* @param option {@link AssetResumeOptions}
|
|
469
|
+
* @returns
|
|
470
|
+
*/
|
|
471
|
+
resume(options: AssetResumeOptions): Promise<void>;
|
|
472
|
+
/**
|
|
473
|
+
* Stop an audio file
|
|
474
|
+
* @since 5.0.0
|
|
475
|
+
* @param option {@link Assets}
|
|
476
|
+
* @returns
|
|
477
|
+
*/
|
|
478
|
+
loop(options: Assets): Promise<void>;
|
|
479
|
+
/**
|
|
480
|
+
* Stop an audio file
|
|
481
|
+
* @since 5.0.0
|
|
482
|
+
* @param option {@link AssetStopOptions}
|
|
483
|
+
* @returns
|
|
484
|
+
*/
|
|
485
|
+
stop(options: AssetStopOptions): Promise<void>;
|
|
486
|
+
/**
|
|
487
|
+
* Unload an audio file
|
|
488
|
+
* @since 5.0.0
|
|
489
|
+
* @param option {@link Assets}
|
|
490
|
+
* @returns
|
|
491
|
+
*/
|
|
492
|
+
unload(options: Assets): Promise<void>;
|
|
493
|
+
/**
|
|
494
|
+
* Set the volume of an audio file
|
|
495
|
+
* @since 5.0.0
|
|
496
|
+
* @param option {@link AssetVolume}
|
|
497
|
+
* @returns {Promise<void>}
|
|
498
|
+
*/
|
|
499
|
+
setVolume(options: AssetVolume): Promise<void>;
|
|
500
|
+
/**
|
|
501
|
+
* Set the rate of an audio file
|
|
502
|
+
* @since 5.0.0
|
|
503
|
+
* @param option {@link AssetRate}
|
|
504
|
+
* @returns {Promise<void>}
|
|
505
|
+
*/
|
|
506
|
+
setRate(options: AssetRate): Promise<void>;
|
|
507
|
+
/**
|
|
508
|
+
* Set the current time of an audio file
|
|
509
|
+
* @since 6.5.0
|
|
510
|
+
* @param option {@link AssetSetTime}
|
|
511
|
+
* @returns {Promise<void>}
|
|
512
|
+
*/
|
|
513
|
+
setCurrentTime(options: AssetSetTime): Promise<void>;
|
|
514
|
+
/**
|
|
515
|
+
* Get the current time of an audio file
|
|
516
|
+
* @since 5.0.0
|
|
517
|
+
* @param option {@link Assets}
|
|
518
|
+
* @returns {Promise<{ currentTime: number }>}
|
|
519
|
+
*/
|
|
520
|
+
getCurrentTime(options: Assets): Promise<{
|
|
521
|
+
currentTime: number;
|
|
522
|
+
}>;
|
|
523
|
+
/**
|
|
524
|
+
* Get the duration of an audio file in seconds
|
|
525
|
+
* @since 5.0.0
|
|
526
|
+
* @param option {@link Assets}
|
|
527
|
+
* @returns {Promise<{ duration: number }>}
|
|
528
|
+
*/
|
|
529
|
+
getDuration(options: Assets): Promise<{
|
|
530
|
+
duration: number;
|
|
531
|
+
}>;
|
|
532
|
+
/**
|
|
533
|
+
* Check if an audio file is playing
|
|
534
|
+
*
|
|
535
|
+
* @since 5.0.0
|
|
536
|
+
* @param option {@link Assets}
|
|
537
|
+
* @returns {Promise<boolean>}
|
|
538
|
+
*/
|
|
539
|
+
isPlaying(options: Assets): Promise<{
|
|
540
|
+
isPlaying: boolean;
|
|
541
|
+
}>;
|
|
542
|
+
/**
|
|
543
|
+
* Listen for complete event
|
|
544
|
+
*
|
|
545
|
+
* @since 5.0.0
|
|
546
|
+
* return {@link CompletedEvent}
|
|
547
|
+
*/
|
|
548
|
+
addListener(eventName: 'complete', listenerFunc: CompletedListener): Promise<PluginListenerHandle>;
|
|
549
|
+
/**
|
|
550
|
+
* Listen for current time updates
|
|
551
|
+
* Emits every 100ms while audio is playing
|
|
552
|
+
*
|
|
553
|
+
* @since 6.5.0
|
|
554
|
+
* return {@link CurrentTimeEvent}
|
|
555
|
+
*/
|
|
556
|
+
addListener(eventName: 'currentTime', listenerFunc: CurrentTimeListener): Promise<PluginListenerHandle>;
|
|
557
|
+
/**
|
|
558
|
+
* Listen for playback state changes, including notification and lock-screen transport controls.
|
|
559
|
+
* Emitted by Android and iOS. The current Web implementation does not emit this event.
|
|
560
|
+
*
|
|
561
|
+
* @since 8.3.15
|
|
562
|
+
* return {@link PlaybackStateEvent}
|
|
563
|
+
*/
|
|
564
|
+
addListener(eventName: 'playbackState', listenerFunc: PlaybackStateListener): Promise<PluginListenerHandle>;
|
|
565
|
+
/**
|
|
566
|
+
* Clear the audio cache for remote audio files
|
|
567
|
+
* @since 6.5.0
|
|
568
|
+
* @returns {Promise<void>}
|
|
569
|
+
*/
|
|
570
|
+
clearCache(): Promise<void>;
|
|
571
|
+
/**
|
|
572
|
+
* Set debug mode logging
|
|
573
|
+
* @since 6.5.0
|
|
574
|
+
* @param options - Options to enable or disable debug mode
|
|
575
|
+
*/
|
|
576
|
+
setDebugMode(options: {
|
|
577
|
+
enabled: boolean;
|
|
578
|
+
}): Promise<void>;
|
|
579
|
+
/**
|
|
580
|
+
* Get the native Capacitor plugin version
|
|
581
|
+
*
|
|
582
|
+
* @returns {Promise<{ id: string }>} an Promise with version for this device
|
|
583
|
+
* @throws An error if the something went wrong
|
|
584
|
+
*/
|
|
585
|
+
getPluginVersion(): Promise<{
|
|
586
|
+
version: string;
|
|
587
|
+
}>;
|
|
588
|
+
/**
|
|
589
|
+
* Deinitialize the plugin and restore original audio session settings
|
|
590
|
+
* This method stops all playing audio and reverts any audio session changes made by the plugin
|
|
591
|
+
* Use this when you need to ensure compatibility with other audio plugins
|
|
592
|
+
*
|
|
593
|
+
* @since 7.7.0
|
|
594
|
+
* @returns {Promise<void>}
|
|
595
|
+
*/
|
|
596
|
+
deinitPlugin(): Promise<void>;
|
|
597
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface CompletedEvent {\n /**\n * Emit when a play completes\n *\n * @since 5.0.0\n */\n assetId: string;\n}\n\nexport type CompletedListener = (state: CompletedEvent) => void;\n\nexport interface Assets {\n /**\n * Asset Id, unique identifier of the file\n */\n assetId: string;\n}\n\nexport interface AssetVolume {\n /**\n * Asset Id, unique identifier of the file\n */\n assetId: string;\n /**\n * Volume of the audio, between 0.1 and 1.0\n */\n volume: number;\n /**\n * Time over which to fade to the target volume, in seconds. Default is 0s (immediate).\n */\n duration?: number;\n}\n\nexport interface AssetRate {\n /**\n * Asset Id, unique identifier of the file\n */\n assetId: string;\n /**\n * Rate of the audio, between 0.1 and 1.0\n */\n rate: number;\n}\n\nexport interface AssetSetTime {\n /**\n * Asset Id, unique identifier of the file\n */\n assetId: string;\n /**\n * Time to set the audio, in seconds\n */\n time: number;\n}\n\nexport interface AssetPlayOptions {\n /**\n * Asset Id, unique identifier of the file\n */\n assetId: string;\n /**\n * Time to start playing the audio, in seconds\n */\n time?: number;\n /**\n * Delay to start playing the audio, in seconds\n */\n delay?: number;\n\n /**\n * Volume of the audio, between 0.1 and 1.0\n */\n volume?: number;\n\n /**\n * Whether to fade in the audio\n */\n fadeIn?: boolean;\n\n /**\n * Whether to fade out the audio\n */\n fadeOut?: boolean;\n\n /**\n * Fade in duration in seconds.\n * Only used if fadeIn is true.\n * Default is 1s.\n */\n fadeInDuration?: number;\n\n /**\n * Fade out duration in seconds.\n * Only used if fadeOut is true.\n * Default is 1s.\n */\n fadeOutDuration?: number;\n\n /**\n * Time in seconds from the start of the audio to start fading out.\n * Only used if fadeOut is true.\n * Default is fadeOutDuration before end of audio.\n */\n fadeOutStartTime?: number;\n}\n\nexport interface AssetStopOptions {\n /**\n * Asset Id, unique identifier of the file\n */\n assetId: string;\n\n /**\n * Whether to fade out the audio before stopping\n */\n fadeOut?: boolean;\n\n /**\n * Fade out duration in seconds.\n * Default is 1s.\n */\n fadeOutDuration?: number;\n}\n\nexport interface AssetPauseOptions {\n /**\n * Asset Id, unique identifier of the file\n */\n assetId: string;\n\n /**\n * Whether to fade out the audio before pausing\n */\n fadeOut?: boolean;\n\n /**\n * Fade out duration in seconds.\n * Default is 1s.\n */\n fadeOutDuration?: number;\n}\n\nexport interface AssetResumeOptions {\n /**\n * Asset Id, unique identifier of the file\n */\n assetId: string;\n\n /**\n * Whether to fade in the audio during resume\n */\n fadeIn?: boolean;\n\n /**\n * Fade in duration in seconds.\n * Default is 1s.\n */\n fadeInDuration?: number;\n}\n\nexport interface ConfigureOptions {\n /**\n * focus the audio with Audio Focus\n */\n focus?: boolean;\n /**\n * Play the audio in the background\n */\n background?: boolean;\n /**\n * Ignore silent mode, works only on iOS setting this will nuke other audio apps\n */\n ignoreSilent?: boolean;\n /**\n * Show audio playback in the notification center (iOS and Android)\n * When enabled, displays audio metadata (title, artist, album, artwork) in the system notification\n * and Control Center (iOS) or lock screen.\n *\n * **Important iOS Behavior:**\n * Enabling this option changes the audio session category to `.playback` with `.default` mode,\n * which means your app's audio will **interrupt** other apps' audio (like background music from\n * Spotify, Apple Music, etc.) instead of mixing with it. This is required for the Now Playing\n * info to appear in Control Center and on the lock screen.\n *\n * **Trade-offs:**\n * - `showNotification: true` → Shows Now Playing controls, but interrupts other audio\n * - `showNotification: false` → Audio mixes with other apps, but no Now Playing controls\n *\n * Use this when your app is the primary audio source (music players, podcast apps, etc.).\n * Disable this for secondary audio like sound effects or notification sounds where mixing\n * with background music is preferred.\n *\n * @see https://github.com/Cap-go/capacitor-native-audio/issues/202\n */\n showNotification?: boolean;\n /**\n * Enable background audio playback (Android only)\n *\n * When enabled, audio will continue playing when the app is backgrounded or the screen is locked.\n * The plugin will skip the automatic pause/resume logic that normally occurs when the app\n * enters the background or returns to the foreground.\n *\n * **Important Android Requirements:**\n * To use background playback on Android, your app must:\n * 1. Declare the required permissions in `AndroidManifest.xml`:\n * - `<uses-permission android:name=\"android.permission.FOREGROUND_SERVICE\" />`\n * - `<uses-permission android:name=\"android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK\" />`\n * - `<uses-permission android:name=\"android.permission.WAKE_LOCK\" />`\n * 2. Start a Foreground Service with a media-style notification before backgrounding\n * (the plugin does not automatically create or manage the foreground service)\n * 3. Use `showNotification: true` to display playback controls in the notification\n *\n * **Usage Example:**\n * ```typescript\n * await NativeAudio.configure({\n * backgroundPlayback: true,\n * showNotification: true\n * });\n * // Start your foreground service here\n * // Then preload and play audio as normal\n * ```\n *\n * @default false\n * @platform Android\n * @since 8.2.0\n */\n backgroundPlayback?: boolean;\n}\n\n/**\n * Metadata to display in the notification center, Control Center (iOS), and lock screen\n * when `showNotification` is enabled in `configure()`.\n *\n * Note: This metadata will only be displayed if `showNotification: true` is set in the\n * `configure()` method. See {@link ConfigureOptions.showNotification} for important\n * behavior details about audio mixing on iOS.\n */\nexport interface NotificationMetadata {\n /**\n * The title to display in the notification center\n */\n title?: string;\n /**\n * The artist name to display in the notification center\n */\n artist?: string;\n /**\n * The album name to display in the notification center\n */\n album?: string;\n /**\n * URL or local path to the artwork/album art image\n */\n artworkUrl?: string;\n}\n\nexport interface PlayOnceOptions {\n /**\n * Path to the audio file, relative path of the file, absolute url (file://) or remote url (https://)\n * Supported formats:\n * - MP3, WAV (all platforms)\n * - M3U8/HLS streams (iOS and Android)\n */\n assetPath: string;\n /**\n * Volume of the audio, between 0.1 and 1.0\n * @default 1.0\n */\n volume?: number;\n /**\n * Is the audio file a URL, pass true if assetPath is a `file://` url\n * or a streaming URL (m3u8)\n * @default false\n */\n isUrl?: boolean;\n /**\n * Automatically start playback after loading\n * @default true\n */\n autoPlay?: boolean;\n /**\n * Delete the audio file from disk after playback completes\n * Only works for local files (file:// URLs), ignored for remote URLs\n * @default false\n * @since 7.11.0\n */\n deleteAfterPlay?: boolean;\n /**\n * Metadata to display in the notification center when audio is playing.\n * Only used when `showNotification: true` is set in `configure()`.\n *\n * See {@link ConfigureOptions.showNotification} for important details about\n * how this affects audio mixing behavior on iOS.\n *\n * @see NotificationMetadata\n * @since 7.10.0\n */\n notificationMetadata?: NotificationMetadata;\n /**\n * Custom HTTP headers to include when fetching remote audio files.\n * Only used when isUrl is true and assetPath is a remote URL (http/https).\n * Example: { 'x-api-key': 'abc123', 'Authorization': 'Bearer token' }\n *\n * @since 7.10.0\n */\n headers?: Record<string, string>;\n}\n\nexport interface PlayOnceResult {\n /**\n * The internally generated asset ID for this playback\n * Can be used to control playback (pause, stop, etc.) before completion\n */\n assetId: string;\n}\n\nexport interface PreloadOptions {\n /**\n * Path to the audio file, relative path of the file, absolute url (file://) or remote url (https://)\n * Supported formats:\n * - MP3, WAV (all platforms)\n * - M3U8/HLS streams (iOS and Android)\n */\n assetPath: string;\n /**\n * Asset Id, unique identifier of the file\n */\n assetId: string;\n /**\n * Volume of the audio, between 0.1 and 1.0\n */\n volume?: number;\n /**\n * Audio channel number, default is 1\n */\n audioChannelNum?: number;\n /**\n * Is the audio file a URL, pass true if assetPath is a `file://` url\n * or a streaming URL (m3u8)\n */\n isUrl?: boolean;\n /**\n * Metadata to display in the notification center when audio is playing.\n * Only used when `showNotification: true` is set in `configure()`.\n *\n * See {@link ConfigureOptions.showNotification} for important details about\n * how this affects audio mixing behavior on iOS.\n *\n * @see NotificationMetadata\n */\n notificationMetadata?: NotificationMetadata;\n /**\n * Custom HTTP headers to include when fetching remote audio files.\n * Only used when isUrl is true and assetPath is a remote URL (http/https).\n * Example: { 'x-api-key': 'abc123', 'Authorization': 'Bearer token' }\n *\n * @since 7.10.0\n */\n headers?: Record<string, string>;\n}\n\nexport interface CurrentTimeEvent {\n /**\n * Current time of the audio in seconds\n * @since 6.5.0\n */\n currentTime: number;\n /**\n * Asset Id of the audio\n * @since 6.5.0\n */\n assetId: string;\n}\n\nexport type CurrentTimeListener = (state: CurrentTimeEvent) => void;\n\nexport type PlaybackStateValue = 'playing' | 'paused' | 'stopped';\n\nexport interface PlaybackStateEvent {\n /**\n * Asset Id of the audio\n */\n assetId: string;\n /**\n * Resolved playback state after a local or remote transport action.\n */\n state: PlaybackStateValue;\n /**\n * Reason for the state change, for example `play`, `pause`, `remotePlay`, or `complete`.\n */\n reason: string;\n /**\n * Whether the asset is currently playing.\n */\n isPlaying: boolean;\n /**\n * Current playback position in seconds when available.\n */\n currentTime?: number;\n /**\n * Total playback duration in seconds when available.\n */\n duration?: number;\n}\n\nexport type PlaybackStateListener = (state: PlaybackStateEvent) => void;\n\nexport interface NativeAudio {\n /**\n * Configure the audio player\n * @since 5.0.0\n * @param option {@link ConfigureOptions}\n * @returns\n */\n configure(options: ConfigureOptions): Promise<void>;\n\n /**\n * Load an audio file\n * @since 5.0.0\n * @param option {@link PreloadOptions}\n * @returns\n */\n preload(options: PreloadOptions): Promise<void>;\n /**\n * Play an audio file once with automatic cleanup\n *\n * Method designed for simple, single-shot audio playback,\n * such as notification sounds, UI feedback, or other short audio clips\n * that don't require manual state management.\n *\n * **Key Features:**\n * - **Fire-and-forget**: No need to manually preload, play, stop, or unload\n * - **Auto-cleanup**: Asset is automatically unloaded after playback completes\n * - **Optional file deletion**: Can delete local files after playback (useful for temp files)\n * - **Returns assetId**: Can still control playback if needed (pause, stop, etc.)\n *\n * **Use Cases:**\n * - Notification sounds\n * - UI sound effects (button clicks, alerts)\n * - Short audio clips that play once\n * - Temporary audio files that should be cleaned up\n *\n * **Comparison with regular play():**\n * - `play()`: Requires manual preload, play, and unload steps\n * - `playOnce()`: Handles everything automatically with a single call\n *\n * @example\n * ```typescript\n * // Simple one-shot playback\n * await NativeAudio.playOnce({ assetPath: 'audio/notification.mp3' });\n *\n * // Play and delete the file after completion\n * await NativeAudio.playOnce({\n * assetPath: 'file:///path/to/temp/audio.mp3',\n * isUrl: true,\n * deleteAfterPlay: true\n * });\n *\n * // Get the assetId to control playback\n * const { assetId } = await NativeAudio.playOnce({\n * assetPath: 'audio/long-track.mp3',\n * autoPlay: true\n * });\n * // Later, you can stop it manually if needed\n * await NativeAudio.stop({ assetId });\n * ```\n *\n * @since 7.11.0\n * @param options {@link PlayOnceOptions}\n * @returns {Promise<PlayOnceResult>} Object containing the generated assetId\n */\n playOnce(options: PlayOnceOptions): Promise<PlayOnceResult>;\n /**\n * Check if an audio file is preloaded\n *\n * @since 6.1.0\n * @param option {@link Assets}\n * @returns {Promise<boolean>}\n */\n isPreloaded(options: PreloadOptions): Promise<{ found: boolean }>;\n\n /**\n * Play an audio file\n * @since 5.0.0\n * @param option {@link AssetPlayOptions}\n * @returns\n */\n play(options: AssetPlayOptions): Promise<void>;\n\n /**\n * Pause an audio file\n * @since 5.0.0\n * @param option {@link AssetPauseOptions}\n * @returns\n */\n pause(options: AssetPauseOptions): Promise<void>;\n\n /**\n * Resume an audio file\n * @since 5.0.0\n * @param option {@link AssetResumeOptions}\n * @returns\n */\n resume(options: AssetResumeOptions): Promise<void>;\n\n /**\n * Stop an audio file\n * @since 5.0.0\n * @param option {@link Assets}\n * @returns\n */\n loop(options: Assets): Promise<void>;\n\n /**\n * Stop an audio file\n * @since 5.0.0\n * @param option {@link AssetStopOptions}\n * @returns\n */\n stop(options: AssetStopOptions): Promise<void>;\n\n /**\n * Unload an audio file\n * @since 5.0.0\n * @param option {@link Assets}\n * @returns\n */\n unload(options: Assets): Promise<void>;\n\n /**\n * Set the volume of an audio file\n * @since 5.0.0\n * @param option {@link AssetVolume}\n * @returns {Promise<void>}\n */\n setVolume(options: AssetVolume): Promise<void>;\n\n /**\n * Set the rate of an audio file\n * @since 5.0.0\n * @param option {@link AssetRate}\n * @returns {Promise<void>}\n */\n setRate(options: AssetRate): Promise<void>;\n\n /**\n * Set the current time of an audio file\n * @since 6.5.0\n * @param option {@link AssetSetTime}\n * @returns {Promise<void>}\n */\n setCurrentTime(options: AssetSetTime): Promise<void>;\n\n /**\n * Get the current time of an audio file\n * @since 5.0.0\n * @param option {@link Assets}\n * @returns {Promise<{ currentTime: number }>}\n */\n getCurrentTime(options: Assets): Promise<{ currentTime: number }>;\n\n /**\n * Get the duration of an audio file in seconds\n * @since 5.0.0\n * @param option {@link Assets}\n * @returns {Promise<{ duration: number }>}\n */\n getDuration(options: Assets): Promise<{ duration: number }>;\n\n /**\n * Check if an audio file is playing\n *\n * @since 5.0.0\n * @param option {@link Assets}\n * @returns {Promise<boolean>}\n */\n isPlaying(options: Assets): Promise<{ isPlaying: boolean }>;\n\n /**\n * Listen for complete event\n *\n * @since 5.0.0\n * return {@link CompletedEvent}\n */\n addListener(eventName: 'complete', listenerFunc: CompletedListener): Promise<PluginListenerHandle>;\n\n /**\n * Listen for current time updates\n * Emits every 100ms while audio is playing\n *\n * @since 6.5.0\n * return {@link CurrentTimeEvent}\n */\n addListener(eventName: 'currentTime', listenerFunc: CurrentTimeListener): Promise<PluginListenerHandle>;\n /**\n * Listen for playback state changes, including notification and lock-screen transport controls.\n * Emitted by Android and iOS. The current Web implementation does not emit this event.\n *\n * @since 8.3.15\n * return {@link PlaybackStateEvent}\n */\n addListener(eventName: 'playbackState', listenerFunc: PlaybackStateListener): Promise<PluginListenerHandle>;\n /**\n * Clear the audio cache for remote audio files\n * @since 6.5.0\n * @returns {Promise<void>}\n */\n clearCache(): Promise<void>;\n\n /**\n * Set debug mode logging\n * @since 6.5.0\n * @param options - Options to enable or disable debug mode\n */\n setDebugMode(options: { enabled: boolean }): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Deinitialize the plugin and restore original audio session settings\n * This method stops all playing audio and reverts any audio session changes made by the plugin\n * Use this when you need to ensure compatibility with other audio plugins\n *\n * @since 7.7.0\n * @returns {Promise<void>}\n */\n deinitPlugin(): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const NativeAudio = registerPlugin('NativeAudio', {
|
|
3
|
+
web: () => import('./web').then((m) => new m.NativeAudioWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { NativeAudio };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,WAAW,GAAG,cAAc,CAAc,aAAa,EAAE;IAC7D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;CAC/D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport { NativeAudio } from './definitions';\n\nconst NativeAudio = registerPlugin<NativeAudio>('NativeAudio', {\n web: () => import('./web').then((m) => new m.NativeAudioWeb()),\n});\n\nexport * from './definitions';\nexport { NativeAudio };\n"]}
|