tj.playMusic() plays music loaded with tj.loadMusic().
tj.playMusic() will do nothing if the music is already playing (as in, the playMusic will just continue until finished).
If you'd like to force the music to play from the start, you can use tj.playMusicFromStart().
Most web browsers won't play any music until the user has clicked the page. There is no delay in the enabling of music however, so the music will play if you play it in the same frame as a click.
The following demo shows loading music 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.
Encouragement Music (encouragement.mp3) | Unnamed author on Free SFX |
---|---|
Free Audio Hosting | DropBox |