loov / jsfx

Javascript Sound Effect Generator
MIT License
576 stars 49 forks source link

Stop #5

Closed raphaelbastide closed 9 years ago

raphaelbastide commented 12 years ago

I was wondering if there is a way to stop (interrupt) a sound.

egonelbre commented 12 years ago

createWave/createWaves creates Audio objects. You can see the full spec at http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#the-audio-element . To stop the sound you can just use sound.pause(). Also here's a tip; to see what things an element supports you can use: for(var e in (new Audio())) console.log(e).

raphaelbastide commented 12 years ago

It is exactly what I was looking for. Thank you for that.

raphaelbastide commented 11 years ago

I am sorry, I still get an issue because I don't really understand how to stop or pause the current sound. Should I make a button with sound.pause() ? And Should I create a this.pause function in jsfxguy.js?

egonelbre commented 11 years ago

Pause method is available on all Audio objects. So just call pause on the currently playing wave.

var wave = audio.make(data);
wave.play();
...
wave.pause();