@capgo/native-audio 5.1.0 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,6 @@ import static ee.forgr.audio.Constant.LOOP;
12
12
  import static ee.forgr.audio.Constant.OPT_FADE_MUSIC;
13
13
  import static ee.forgr.audio.Constant.OPT_FOCUS_AUDIO;
14
14
  import static ee.forgr.audio.Constant.VOLUME;
15
- import static ee.forgr.audio.Constant.RATE;
16
15
 
17
16
  import android.Manifest;
18
17
  import android.content.Context;
@@ -225,6 +224,9 @@ public class NativeAudio extends Plugin implements AudioManager.OnAudioFocusChan
225
224
  if (wasPlaying) {
226
225
  resumeList.add(asset);
227
226
  }
227
+ call.resolve();
228
+ } else {
229
+ call.reject(ERROR_ASSET_NOT_LOADED + " - " + audioId);
228
230
  }
229
231
  } else {
230
232
  call.reject(ERROR_ASSET_NOT_LOADED + " - " + audioId);
@@ -245,6 +247,9 @@ public class NativeAudio extends Plugin implements AudioManager.OnAudioFocusChan
245
247
  if (asset != null) {
246
248
  asset.resume();
247
249
  resumeList.add(asset);
250
+ call.resolve();
251
+ } else {
252
+ call.reject(ERROR_ASSET_NOT_LOADED + " - " + audioId);
248
253
  }
249
254
  } else {
250
255
  call.reject(ERROR_ASSET_NOT_LOADED + " - " + audioId);
@@ -264,6 +269,9 @@ public class NativeAudio extends Plugin implements AudioManager.OnAudioFocusChan
264
269
  AudioAsset asset = audioAssetList.get(audioId);
265
270
  if (asset != null) {
266
271
  asset.stop();
272
+ call.resolve();
273
+ } else {
274
+ call.reject(ERROR_ASSET_NOT_LOADED + " - " + audioId);
267
275
  }
268
276
  } else {
269
277
  call.reject(ERROR_ASSET_NOT_LOADED + " - " + audioId);
@@ -288,7 +296,6 @@ public class NativeAudio extends Plugin implements AudioManager.OnAudioFocusChan
288
296
  if (asset != null) {
289
297
  asset.unload();
290
298
  audioAssetList.remove(audioId);
291
-
292
299
  status = new JSObject();
293
300
  status.put("status", "OK");
294
301
  call.resolve(status);
@@ -324,27 +331,9 @@ public class NativeAudio extends Plugin implements AudioManager.OnAudioFocusChan
324
331
  AudioAsset asset = audioAssetList.get(audioId);
325
332
  if (asset != null) {
326
333
  asset.setVolume(volume);
327
- }
328
- } else {
329
- call.reject(ERROR_AUDIO_ASSET_MISSING);
330
- }
331
- } catch (Exception ex) {
332
- call.reject(ex.getMessage());
333
- }
334
- }
335
-
336
- @PluginMethod
337
- public void setRate(PluginCall call) {
338
- try {
339
- initSoundPool();
340
-
341
- String audioId = call.getString(ASSET_ID);
342
- float rate = call.getFloat(RATE);
343
-
344
- if (audioAssetList.containsKey(audioId)) {
345
- AudioAsset asset = audioAssetList.get(audioId);
346
- if (asset != null) {
347
- asset.setRate(rate);
334
+ call.resolve();
335
+ } else {
336
+ call.reject(ERROR_AUDIO_ASSET_MISSING);
348
337
  }
349
338
  } else {
350
339
  call.reject(ERROR_AUDIO_ASSET_MISSING);
@@ -370,6 +359,8 @@ public class NativeAudio extends Plugin implements AudioManager.OnAudioFocusChan
370
359
  AudioAsset asset = audioAssetList.get(audioId);
371
360
  if (asset != null) {
372
361
  call.resolve(new JSObject().put("isPlaying", asset.isPlaying()));
362
+ } else {
363
+ call.reject(ERROR_AUDIO_ASSET_MISSING + " - " + audioId);
373
364
  }
374
365
  } else {
375
366
  call.reject(ERROR_AUDIO_ASSET_MISSING + " - " + audioId);
@@ -470,7 +461,6 @@ public class NativeAudio extends Plugin implements AudioManager.OnAudioFocusChan
470
461
  @Override
471
462
  public Void call() throws Exception {
472
463
  call.resolve(new JSObject().put(ASSET_ID, audioId));
473
-
474
464
  return null;
475
465
  }
476
466
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/native-audio",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "A native plugin for native audio engine",
5
5
  "main": "dist/plugin.js",
6
6
  "module": "dist/esm/index.js",