@capgo/native-audio 5.0.7 → 5.0.11

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/README.md CHANGED
@@ -25,7 +25,7 @@
25
25
  # Capacitor Native Audio Plugin
26
26
 
27
27
  Capacitor plugin for native audio engine.
28
- Capacitor v3/v4 - ✅ Support!
28
+ Capacitor v4 - ✅ Support!
29
29
 
30
30
  Click on video to see example 💥
31
31
 
@@ -41,8 +41,12 @@ Click on video to see example 💥
41
41
  Mainteinance Status: Actively Maintained
42
42
 
43
43
  ## Preparation
44
+
44
45
  All audio files must be with the rest of your source files.
45
46
 
47
+ First make your sound file end up in your builded code folder, example in folder `BUILDFOLDER/assets/sounds/FILENAME.mp3`
48
+ Then use it in preload like that `assets/sounds/FILENAME.mp3`
49
+
46
50
  ## Installation
47
51
 
48
52
  To use npm
@@ -110,7 +114,7 @@ import {NativeAudio} from '@capgo/native-audio'
110
114
  */
111
115
  NativeAudio.preload({
112
116
  assetId: "fire",
113
- assetPath: "fire.mp3",
117
+ assetPath: "assets/sounds/fire.mp3",
114
118
  audioChannelNum: 1,
115
119
  isUrl: false
116
120
  });
@@ -210,131 +214,149 @@ NativeAudio.isPlaying({
210
214
  ### configure(...)
211
215
 
212
216
  ```typescript
213
- configure(options: ConfigureOptions) => Promise<void>
217
+ configure(options: ConfigureOptions) => any
214
218
  ```
215
219
 
216
220
  | Param | Type |
217
221
  | ------------- | ------------------------------------------------------------- |
218
222
  | **`options`** | <code><a href="#configureoptions">ConfigureOptions</a></code> |
219
223
 
224
+ **Returns:** <code>any</code>
225
+
220
226
  --------------------
221
227
 
222
228
 
223
229
  ### preload(...)
224
230
 
225
231
  ```typescript
226
- preload(options: PreloadOptions) => Promise<void>
232
+ preload(options: PreloadOptions) => any
227
233
  ```
228
234
 
229
235
  | Param | Type |
230
236
  | ------------- | --------------------------------------------------------- |
231
237
  | **`options`** | <code><a href="#preloadoptions">PreloadOptions</a></code> |
232
238
 
239
+ **Returns:** <code>any</code>
240
+
233
241
  --------------------
234
242
 
235
243
 
236
244
  ### play(...)
237
245
 
238
246
  ```typescript
239
- play(options: { assetId: string; time?: number; }) => Promise<void>
247
+ play(options: { assetId: string; time?: number; }) => any
240
248
  ```
241
249
 
242
250
  | Param | Type |
243
251
  | ------------- | ------------------------------------------------ |
244
252
  | **`options`** | <code>{ assetId: string; time?: number; }</code> |
245
253
 
254
+ **Returns:** <code>any</code>
255
+
246
256
  --------------------
247
257
 
248
258
 
249
259
  ### pause(...)
250
260
 
251
261
  ```typescript
252
- pause(options: { assetId: string; }) => Promise<void>
262
+ pause(options: { assetId: string; }) => any
253
263
  ```
254
264
 
255
265
  | Param | Type |
256
266
  | ------------- | --------------------------------- |
257
267
  | **`options`** | <code>{ assetId: string; }</code> |
258
268
 
269
+ **Returns:** <code>any</code>
270
+
259
271
  --------------------
260
272
 
261
273
 
262
274
  ### resume(...)
263
275
 
264
276
  ```typescript
265
- resume(options: { assetId: string; }) => Promise<void>
277
+ resume(options: { assetId: string; }) => any
266
278
  ```
267
279
 
268
280
  | Param | Type |
269
281
  | ------------- | --------------------------------- |
270
282
  | **`options`** | <code>{ assetId: string; }</code> |
271
283
 
284
+ **Returns:** <code>any</code>
285
+
272
286
  --------------------
273
287
 
274
288
 
275
289
  ### loop(...)
276
290
 
277
291
  ```typescript
278
- loop(options: { assetId: string; }) => Promise<void>
292
+ loop(options: { assetId: string; }) => any
279
293
  ```
280
294
 
281
295
  | Param | Type |
282
296
  | ------------- | --------------------------------- |
283
297
  | **`options`** | <code>{ assetId: string; }</code> |
284
298
 
299
+ **Returns:** <code>any</code>
300
+
285
301
  --------------------
286
302
 
287
303
 
288
304
  ### stop(...)
289
305
 
290
306
  ```typescript
291
- stop(options: { assetId: string; }) => Promise<void>
307
+ stop(options: { assetId: string; }) => any
292
308
  ```
293
309
 
294
310
  | Param | Type |
295
311
  | ------------- | --------------------------------- |
296
312
  | **`options`** | <code>{ assetId: string; }</code> |
297
313
 
314
+ **Returns:** <code>any</code>
315
+
298
316
  --------------------
299
317
 
300
318
 
301
319
  ### unload(...)
302
320
 
303
321
  ```typescript
304
- unload(options: { assetId: string; }) => Promise<void>
322
+ unload(options: { assetId: string; }) => any
305
323
  ```
306
324
 
307
325
  | Param | Type |
308
326
  | ------------- | --------------------------------- |
309
327
  | **`options`** | <code>{ assetId: string; }</code> |
310
328
 
329
+ **Returns:** <code>any</code>
330
+
311
331
  --------------------
312
332
 
313
333
 
314
334
  ### setVolume(...)
315
335
 
316
336
  ```typescript
317
- setVolume(options: { assetId: string; volume: number; }) => Promise<void>
337
+ setVolume(options: { assetId: string; volume: number; }) => any
318
338
  ```
319
339
 
320
340
  | Param | Type |
321
341
  | ------------- | ------------------------------------------------- |
322
342
  | **`options`** | <code>{ assetId: string; volume: number; }</code> |
323
343
 
344
+ **Returns:** <code>any</code>
345
+
324
346
  --------------------
325
347
 
326
348
 
327
349
  ### getCurrentTime(...)
328
350
 
329
351
  ```typescript
330
- getCurrentTime(options: { assetId: string; }) => Promise<{ currentTime: number; }>
352
+ getCurrentTime(options: { assetId: string; }) => any
331
353
  ```
332
354
 
333
355
  | Param | Type |
334
356
  | ------------- | --------------------------------- |
335
357
  | **`options`** | <code>{ assetId: string; }</code> |
336
358
 
337
- **Returns:** <code>Promise&lt;{ currentTime: number; }&gt;</code>
359
+ **Returns:** <code>any</code>
338
360
 
339
361
  --------------------
340
362
 
@@ -342,14 +364,14 @@ getCurrentTime(options: { assetId: string; }) => Promise<{ currentTime: number;
342
364
  ### getDuration(...)
343
365
 
344
366
  ```typescript
345
- getDuration(options: { assetId: string; }) => Promise<{ duration: number; }>
367
+ getDuration(options: { assetId: string; }) => any
346
368
  ```
347
369
 
348
370
  | Param | Type |
349
371
  | ------------- | --------------------------------- |
350
372
  | **`options`** | <code>{ assetId: string; }</code> |
351
373
 
352
- **Returns:** <code>Promise&lt;{ duration: number; }&gt;</code>
374
+ **Returns:** <code>any</code>
353
375
 
354
376
  --------------------
355
377
 
@@ -357,14 +379,14 @@ getDuration(options: { assetId: string; }) => Promise<{ duration: number; }>
357
379
  ### isPlaying(...)
358
380
 
359
381
  ```typescript
360
- isPlaying(options: { assetId: string; }) => Promise<{ isPlaying: boolean; }>
382
+ isPlaying(options: { assetId: string; }) => any
361
383
  ```
362
384
 
363
385
  | Param | Type |
364
386
  | ------------- | --------------------------------- |
365
387
  | **`options`** | <code>{ assetId: string; }</code> |
366
388
 
367
- **Returns:** <code>Promise&lt;{ isPlaying: boolean; }&gt;</code>
389
+ **Returns:** <code>any</code>
368
390
 
369
391
  --------------------
370
392
 
@@ -407,6 +407,10 @@ public class NativeAudio extends Plugin implements AudioManager.OnAudioFocusChan
407
407
  ParcelFileDescriptor p = ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
408
408
  assetFileDescriptor = new AssetFileDescriptor(p, 0, -1);
409
409
  } else {
410
+ // if fullPath dont start with public/ add it
411
+ if (!fullPath.startsWith("public/")) {
412
+ fullPath = "public/".concat(fullPath);
413
+ }
410
414
  Context ctx = getBridge().getActivity().getApplicationContext();
411
415
  AssetManager am = ctx.getResources().getAssets();
412
416
  assetFileDescriptor = am.openFd(fullPath);
package/dist/docs.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "methods": [
8
8
  {
9
9
  "name": "configure",
10
- "signature": "(options: ConfigureOptions) => Promise<void>",
10
+ "signature": "(options: ConfigureOptions) => any",
11
11
  "parameters": [
12
12
  {
13
13
  "name": "options",
@@ -15,7 +15,7 @@
15
15
  "type": "ConfigureOptions"
16
16
  }
17
17
  ],
18
- "returns": "Promise<void>",
18
+ "returns": "any",
19
19
  "tags": [],
20
20
  "docs": "",
21
21
  "complexTypes": [
@@ -25,7 +25,7 @@
25
25
  },
26
26
  {
27
27
  "name": "preload",
28
- "signature": "(options: PreloadOptions) => Promise<void>",
28
+ "signature": "(options: PreloadOptions) => any",
29
29
  "parameters": [
30
30
  {
31
31
  "name": "options",
@@ -33,7 +33,7 @@
33
33
  "type": "PreloadOptions"
34
34
  }
35
35
  ],
36
- "returns": "Promise<void>",
36
+ "returns": "any",
37
37
  "tags": [],
38
38
  "docs": "",
39
39
  "complexTypes": [
@@ -43,7 +43,7 @@
43
43
  },
44
44
  {
45
45
  "name": "play",
46
- "signature": "(options: { assetId: string; time?: number; }) => Promise<void>",
46
+ "signature": "(options: { assetId: string; time?: number; }) => any",
47
47
  "parameters": [
48
48
  {
49
49
  "name": "options",
@@ -51,7 +51,7 @@
51
51
  "type": "{ assetId: string; time?: number | undefined; }"
52
52
  }
53
53
  ],
54
- "returns": "Promise<void>",
54
+ "returns": "any",
55
55
  "tags": [],
56
56
  "docs": "",
57
57
  "complexTypes": [],
@@ -59,7 +59,7 @@
59
59
  },
60
60
  {
61
61
  "name": "pause",
62
- "signature": "(options: { assetId: string; }) => Promise<void>",
62
+ "signature": "(options: { assetId: string; }) => any",
63
63
  "parameters": [
64
64
  {
65
65
  "name": "options",
@@ -67,7 +67,7 @@
67
67
  "type": "{ assetId: string; }"
68
68
  }
69
69
  ],
70
- "returns": "Promise<void>",
70
+ "returns": "any",
71
71
  "tags": [],
72
72
  "docs": "",
73
73
  "complexTypes": [],
@@ -75,7 +75,7 @@
75
75
  },
76
76
  {
77
77
  "name": "resume",
78
- "signature": "(options: { assetId: string; }) => Promise<void>",
78
+ "signature": "(options: { assetId: string; }) => any",
79
79
  "parameters": [
80
80
  {
81
81
  "name": "options",
@@ -83,7 +83,7 @@
83
83
  "type": "{ assetId: string; }"
84
84
  }
85
85
  ],
86
- "returns": "Promise<void>",
86
+ "returns": "any",
87
87
  "tags": [],
88
88
  "docs": "",
89
89
  "complexTypes": [],
@@ -91,7 +91,7 @@
91
91
  },
92
92
  {
93
93
  "name": "loop",
94
- "signature": "(options: { assetId: string; }) => Promise<void>",
94
+ "signature": "(options: { assetId: string; }) => any",
95
95
  "parameters": [
96
96
  {
97
97
  "name": "options",
@@ -99,7 +99,7 @@
99
99
  "type": "{ assetId: string; }"
100
100
  }
101
101
  ],
102
- "returns": "Promise<void>",
102
+ "returns": "any",
103
103
  "tags": [],
104
104
  "docs": "",
105
105
  "complexTypes": [],
@@ -107,7 +107,7 @@
107
107
  },
108
108
  {
109
109
  "name": "stop",
110
- "signature": "(options: { assetId: string; }) => Promise<void>",
110
+ "signature": "(options: { assetId: string; }) => any",
111
111
  "parameters": [
112
112
  {
113
113
  "name": "options",
@@ -115,7 +115,7 @@
115
115
  "type": "{ assetId: string; }"
116
116
  }
117
117
  ],
118
- "returns": "Promise<void>",
118
+ "returns": "any",
119
119
  "tags": [],
120
120
  "docs": "",
121
121
  "complexTypes": [],
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "unload",
126
- "signature": "(options: { assetId: string; }) => Promise<void>",
126
+ "signature": "(options: { assetId: string; }) => any",
127
127
  "parameters": [
128
128
  {
129
129
  "name": "options",
@@ -131,7 +131,7 @@
131
131
  "type": "{ assetId: string; }"
132
132
  }
133
133
  ],
134
- "returns": "Promise<void>",
134
+ "returns": "any",
135
135
  "tags": [],
136
136
  "docs": "",
137
137
  "complexTypes": [],
@@ -139,7 +139,7 @@
139
139
  },
140
140
  {
141
141
  "name": "setVolume",
142
- "signature": "(options: { assetId: string; volume: number; }) => Promise<void>",
142
+ "signature": "(options: { assetId: string; volume: number; }) => any",
143
143
  "parameters": [
144
144
  {
145
145
  "name": "options",
@@ -147,7 +147,7 @@
147
147
  "type": "{ assetId: string; volume: number; }"
148
148
  }
149
149
  ],
150
- "returns": "Promise<void>",
150
+ "returns": "any",
151
151
  "tags": [],
152
152
  "docs": "",
153
153
  "complexTypes": [],
@@ -155,7 +155,7 @@
155
155
  },
156
156
  {
157
157
  "name": "getCurrentTime",
158
- "signature": "(options: { assetId: string; }) => Promise<{ currentTime: number; }>",
158
+ "signature": "(options: { assetId: string; }) => any",
159
159
  "parameters": [
160
160
  {
161
161
  "name": "options",
@@ -163,7 +163,7 @@
163
163
  "type": "{ assetId: string; }"
164
164
  }
165
165
  ],
166
- "returns": "Promise<{ currentTime: number; }>",
166
+ "returns": "any",
167
167
  "tags": [],
168
168
  "docs": "",
169
169
  "complexTypes": [],
@@ -171,7 +171,7 @@
171
171
  },
172
172
  {
173
173
  "name": "getDuration",
174
- "signature": "(options: { assetId: string; }) => Promise<{ duration: number; }>",
174
+ "signature": "(options: { assetId: string; }) => any",
175
175
  "parameters": [
176
176
  {
177
177
  "name": "options",
@@ -179,7 +179,7 @@
179
179
  "type": "{ assetId: string; }"
180
180
  }
181
181
  ],
182
- "returns": "Promise<{ duration: number; }>",
182
+ "returns": "any",
183
183
  "tags": [],
184
184
  "docs": "",
185
185
  "complexTypes": [],
@@ -187,7 +187,7 @@
187
187
  },
188
188
  {
189
189
  "name": "isPlaying",
190
- "signature": "(options: { assetId: string; }) => Promise<{ isPlaying: boolean; }>",
190
+ "signature": "(options: { assetId: string; }) => any",
191
191
  "parameters": [
192
192
  {
193
193
  "name": "options",
@@ -195,7 +195,7 @@
195
195
  "type": "{ assetId: string; }"
196
196
  }
197
197
  ],
198
- "returns": "Promise<{ isPlaying: boolean; }>",
198
+ "returns": "any",
199
199
  "tags": [],
200
200
  "docs": "",
201
201
  "complexTypes": [],
@@ -124,8 +124,8 @@ const NativeAudio = new NativeAudioWeb();
124
124
 
125
125
  var web = /*#__PURE__*/Object.freeze({
126
126
  __proto__: null,
127
- NativeAudioWeb: NativeAudioWeb,
128
- NativeAudio: NativeAudio
127
+ NativeAudio: NativeAudio,
128
+ NativeAudioWeb: NativeAudioWeb
129
129
  });
130
130
 
131
131
  exports.NativeAudio = NativeAudio$1;
package/dist/plugin.js CHANGED
@@ -123,8 +123,8 @@ var capacitorApp = (function (exports, core) {
123
123
 
124
124
  var web = /*#__PURE__*/Object.freeze({
125
125
  __proto__: null,
126
- NativeAudioWeb: NativeAudioWeb,
127
- NativeAudio: NativeAudio
126
+ NativeAudio: NativeAudio,
127
+ NativeAudioWeb: NativeAudioWeb
128
128
  });
129
129
 
130
130
  exports.NativeAudio = NativeAudio$1;
@@ -200,7 +200,7 @@ public class NativeAudio: CAPPlugin {
200
200
  let isUrl: Bool?
201
201
 
202
202
  if audioId != "" {
203
- let assetPath: String = call.getString(Constant.AssetPathKey) ?? ""
203
+ var assetPath: String = call.getString(Constant.AssetPathKey) ?? ""
204
204
 
205
205
  if complex {
206
206
  volume = call.getFloat("volume") ?? 1.0
@@ -225,6 +225,9 @@ public class NativeAudio: CAPPlugin {
225
225
  if asset == nil {
226
226
  var basePath: String?
227
227
  if isUrl == false {
228
+ // if assetPath dont start with public/ add it
229
+ assetPath = assetPath.starts(with: "public/") ? assetPath : "public/" + assetPath
230
+
228
231
  let assetPathSplit = assetPath.components(separatedBy: ".")
229
232
  basePath = Bundle.main.path(forResource: assetPathSplit[0], ofType: assetPathSplit[1])
230
233
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/native-audio",
3
- "version": "5.0.7",
3
+ "version": "5.0.11",
4
4
  "description": "A native plugin for native audio engine",
5
5
  "main": "dist/plugin.js",
6
6
  "module": "dist/esm/index.js",
@@ -40,25 +40,25 @@
40
40
  "author": "Martin Donadieu <martindonadieu@gmail.com>",
41
41
  "license": "MIT",
42
42
  "devDependencies": {
43
- "@capacitor/android": "^4.4.0",
44
- "@capacitor/cli": "^4.4.0",
45
- "@capacitor/core": "^4.4.0",
46
- "@capacitor/docgen": "^0.2.0",
47
- "@capacitor/ios": "^4.4.0",
43
+ "@capacitor/android": "^4.7.0",
44
+ "@capacitor/cli": "^4.7.0",
45
+ "@capacitor/core": "^4.7.0",
46
+ "@capacitor/docgen": "^0.2.1",
47
+ "@capacitor/ios": "^4.7.0",
48
48
  "@ionic/eslint-config": "^0.3.0",
49
49
  "@ionic/prettier-config": "^2.0.0",
50
50
  "@ionic/swiftlint-config": "^1.1.2",
51
- "@typescript-eslint/eslint-plugin": "^5.42.1",
52
- "@typescript-eslint/parser": "^5.42.1",
53
- "eslint": "^8.27.0",
54
- "eslint-plugin-import": "^2.26.0",
55
- "husky": "^8.0.2",
51
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
52
+ "@typescript-eslint/parser": "^5.54.1",
53
+ "eslint": "^8.35.0",
54
+ "eslint-plugin-import": "^2.27.5",
55
+ "husky": "^8.0.3",
56
56
  "prettier": "^2.7.1",
57
57
  "prettier-plugin-java": "^2.0.0",
58
- "rimraf": "^3.0.2",
59
- "rollup": "^3.2.5",
58
+ "rimraf": "^4.3.1",
59
+ "rollup": "^3.18.0",
60
60
  "swiftlint": "^1.0.1",
61
- "typescript": "^4.8.4"
61
+ "typescript": "^4.9.5"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@capacitor/core": "^4.0.0"