|
void play(String sampleName, boolean loop, Promise promise) { |
|
Integer soundId = soundIds.get(sampleName); |
|
if (soundId == null) { |
|
Errors.UNKNOWN_SAMPLE_NAME.reject(promise, sampleName); |
|
return; |
|
} |
|
|
|
Integer streamId = streamIds.remove(sampleName); |
|
if (streamId != null) pool.stop(streamId); |
|
|
|
streamId = pool.play(soundId, 1, 1, 1, loop ? 1 : 0, 1); |
|
if (streamId == 0) Errors.OPERATION_FAILED.reject(promise); |
|
else streamIds.put(sampleName, streamId); |
|
} |