TinksJS

TinksJS Reference / playSoundFromStart

// Play a sound from the start. If already playing, stop it and play it from the start void tj.playSoundFromStart();

Summary

tj.playSoundFromStart() plays a sound loaded with tj.loadSound(), but always from the start.

If the sound is already playing, it will start the sound over.

Most web browsers won't play any sound until the user has clicked the page. There is no delay in the enabling of sounds however, so the sound will play if you play it on a button click.

The following demo shows loading a sound and then playing it on a button click.

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