@capgo/native-audio 5.1.0 → 5.1.2

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.
@@ -42,6 +42,8 @@ public class AudioAsset {
42
42
  audio.play(time, callback);
43
43
  playIndex++;
44
44
  playIndex = playIndex % audioList.size();
45
+ } else {
46
+ throw new Exception("AudioDispatcher is null");
45
47
  }
46
48
  }
47
49
 
@@ -84,6 +86,8 @@ public class AudioAsset {
84
86
 
85
87
  if (audio != null) {
86
88
  audio.resume();
89
+ } else {
90
+ throw new Exception("AudioDispatcher is null");
87
91
  }
88
92
  }
89
93
  }
@@ -94,6 +98,8 @@ public class AudioAsset {
94
98
 
95
99
  if (audio != null) {
96
100
  audio.stop();
101
+ } else {
102
+ throw new Exception("AudioDispatcher is null");
97
103
  }
98
104
  }
99
105
  }
@@ -105,6 +111,8 @@ public class AudioAsset {
105
111
  audio.loop();
106
112
  playIndex++;
107
113
  playIndex = playIndex % audioList.size();
114
+ } else {
115
+ throw new Exception("AudioDispatcher is null");
108
116
  }
109
117
  }
110
118
 
@@ -116,6 +124,8 @@ public class AudioAsset {
116
124
 
117
125
  if (audio != null) {
118
126
  audio.unload();
127
+ } else {
128
+ throw new Exception("AudioDispatcher is null");
119
129
  }
120
130
  }
121
131
 
@@ -132,22 +142,6 @@ public class AudioAsset {
132
142
  }
133
143
  }
134
144
 
135
- /**
136
- * Set the playback rate for the player (ignored on API < 23)
137
- *
138
- * @param volume
139
- */
140
- public void setRate(float rate) throws Exception {
141
-
142
- for (int x = 0; x < audioList.size(); x++) {
143
- AudioDispatcher audio = audioList.get(x);
144
-
145
- if (audio != null) {
146
- audio.setRate(rate);
147
- }
148
- }
149
- }
150
-
151
145
  public boolean isPlaying() throws Exception {
152
146
  if (audioList.size() != 1) return false;
153
147
 
@@ -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.2",
4
4
  "description": "A native plugin for native audio engine",
5
5
  "main": "dist/plugin.js",
6
6
  "module": "dist/esm/index.js",