TinksJS

TinksJS Reference / stopSound

// Stop a sound and set its position to 0 seconds void tj.stopSound();

Summary

tj.stopSound() stops a sound and sets its position to zero. If you call tj.playSound() again, it will play from the start.

If the sound is already not playing when you call tj.stopSound(), the call has no effect.

The following demo shows loading a sound and then playing it on a button click. And provides a Stop button for you to stop it half way through. When you click Play again, it will play from the start.

If you'd like to Pause a sound instead, e.g. stop it but keep its position. You can use tj.pauseSound().

If you'd like to see a demonstration of a range of TinksJS Audio functions, you may like to check out the Audio Player example.

Thanks/Credits

Coin Sound (coin.wav) NXRT on Freesound
Free Audio Hosting DropBox

JS

 

Result