Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Play sound files throughout a twine game

I was wondering if there's a way to play a sound file in the background during the game, so that you don't have to start it each time you start a new thread?


  • I had the same problem and got some help from a friend who is a JS developer. You can use following code in "Edit Story JavaScript":

    var audio = document.createElement('audio');
    audio.src = 'sounds/test.ogg';
    audio.loop = true;;
    If the loop does not work (depends on the browser's JS implementation) you can use this string here instead:

    document.body.innerHTML += "<audio autoplay loop><source src=\"sounds/test.ogg\" type=\"audio/ogg\"></audio>";
    Remember to change "sounds/test.ogg" to the path you need for your background music.

    But maybe there is a better solution than this?...
Sign In or Register to comment.