TinksJS

TinksJS Reference / pauseMusic

// Pause music. Stop, but keep position void tj.pauseMusic();

Summary

tj.pauseMusic() stops music, but keeps its current position. If you call tj.playMusic() again, it will play from where it was paused.

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

The following demo shows loading music and then playing it on a button click. And provides a Pause button for you to pause it half way through. When you click Play again, it will play from where you paused it.

If you'd like to Stop music instead, e.g. stop it and set its position to zero, you can use tj.stopMusic().

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

Encouragement Music (encouragement.mp3) Unnamed author on Free SFX
Free Audio Hosting DropBox

JS

 

Result