Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics

Bitsy Game Maker

Make little games, worlds, and stories! (No coding required.) · By Adam Le Doux

Sounds help

A topic by Ranen created 23 days ago Views: 64 Replies: 3
Viewing posts 1 to 2

I have checked the various posts for audio background loops, used the code perfectly, even trying different iterations with different spacing, file types (wav and mp3), and trying different browsers, but i cant seem to get my game to play sound. Any suggestions?

Are you using a youtube video?

No, I've been using the posts by the developer and a few other people, each saying to add the same line of code after the game canvas of the html file.

<body onload='startExportedGame()'>
<!-- GAME CANVAS -->
<canvas id='game'></canvas>
<audio src="colorsofme.wav" autoplay loop display="none"> </body>


If you are using Chrome, you will need to add a tiny bit of js to make audio work. Chrome killed auto-play audio sources a few months ago, so now you have to have some sort of user interaction to make it "autoplay".

Best practice for the audio tag is something like this:

   <audio id="soundtrack" loop>
       <source src="yourfile.mp3" type="audio/mpeg">

Then you would you would hook into that audio tag id when the user first interacts with the game:

       function ostPlay() {
           document.removeEventListener('click', ostPlay);
           document.removeEventListener('touch', ostPlay);
       document.addEventListener("click", ostPlay);
       document.addEventListener("touch", ostPlay);

It's a little annoying, but until Chrome comes up with a better solution or reverses this change there's not really another option.

I hope this helps!