How to use background music?


Hi, im completely new at this, i only started yesterday but made some nice progress so far. But i wanna know how to put background music to play. I have no idea of how to do it. I want to play some musics in MP3 format. How can i do this?


This works for me. If you dont like the music repeat only quit the addEventListener line. If you want stop the music myAudio.stop(); maybe works. In the Loss.mp3 you can place the url of the music file.

@start Init

    var myAudio = new Audio('Loss.mp3');
	myAudio.addEventListener('ended', function() {this.currentTime = 0;;}, false);;

Hello world!

Log in to post a reply.