jbristowe / nativescript-sound

MIT License
12 stars 15 forks source link

stop() is not stopping the sounds from playing #9

Open sschocke opened 7 years ago

sschocke commented 7 years ago

The library works great for playing sounds, and is really simple to use, but I have 1 small issue with it. The .stop() command does not seem to work (on Android at least, not tested on iOS)

Given the following code the 5 second alarm sound plays to completion every time:

this.alarm = sound.create("~/sounds/alarm.mp3");
this.alarm.play();
setTimeout(() => { this.alarm.stop() }, 1000);

(Not my actual code... just a simple sample to illustrate the problem)

Any idea why?

madakk commented 7 years ago

Looks like the code is calling SoundPool.stop with the sound ID returned from SoundPool.load, while it expects the stream ID returned from the SoundPool.play call.