Howdy, Stranger!

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

Sharing with Audio

Hi everyone,

I've been playing around with Twine for a little while, but I'm struggling with a couple of things. Namely, audio - I love to have audio in my scenes if possible, and about a year ago I had it working in Twine 1 via youtube links. This worked great, though it sort of required the viewer to have AdBlocker or ads would play before some sounds.

Basically, I'm after a way to have sound in my Twine game hosted online and played in-game, so I can share the Twine game (probably have it hosted somewhere) and not have to send a big bunch of sound files to whoever wants to play it.

I'm happy to use Harlowe, Snowman or Sugarcube for this, I'm just not sure on a method. I've spent quite a while searching online and there've been a few solutions, but I haven't been able to get any working. So;

* How do I play audio that's being hosted somewhere online?

* What's a good place to host my audio?

It seems like two questions in one, and it sort of is, but I'm essentially just trying to find out how I can add sounds to my Twine game and have them play without any reliance on local files.

Thanks for your time!


  • edited July 2015
    Well, for me... I have a website. So I upload all the files there and just play it that way. It works out quite well and since I am already paying the $6 (or whatever it is) for everything else I am doing with the site, it doesn't cause an issue financially.

    So that means I just add the links in the header or the css or the passage, and the audio plays the way it should. Since you have been here more than a year, I am going to assume that you know how to do that part already and this is more a question of hosting audio.

    Assuming you don't have a website, you could always go to a place like in order to convert the YouTube video into an mp3 and then once you have that you could base64 encode the resulting audio (not advocating piracy--except maybe Jack Sparrow, savvy?).

    With the base64 code, you now use this:
    <audio autoplay loop>
      <source src="data:audio/mp3;base64,[Base64 Goes Here]" type="audio/mp3">

    Does that answer the question?
  • Can I ask how the website solution would work? I would put the audio file in the website -- but in a special folder? And what would the link in the Twine story look like? Let's say the website is Any help will be greatly appreciated.
  • mdewolf wrote: »
    Can I ask how the website solution would work?
    The answer to this can depend on which story format you are using.

    If you are using SugarCube then I suggest reading about the audio related macros (v2 and v1) but basically you use <<cacheaudio>> to cache your sound files, and then use <<audio>> to play them. Something like the following:
    <<cacheaudio "your-track-id" "">>;
    <<audio "your-track-id" play>>

    Your other choice (which should work for any story format) is to use a HTML audio element, which would look something like the following:
    <audio autoplay>
    <source src=""; type="audio/mpeg" />
  • I am a real newcomer to Twine, and must now find out about SugarCube. But the second choice you provide looks like it might work, as it resembles other HTML suggestions I've found online. I'll try it today, and if it works, you will have my thanks. And thanks right now for responding to my question!
  • Well, I put the audio file (in mp3 format) into the Music folder of my website, and inserted the HTML lines, with the middle line as <source src=""; type=audio/mpeg" /> But no dice. See any error? Any suggestion? Again, my thanks for responding.
  • First there's the obvious, ensuring that the URL actually points to an accessible file. The URL that you specified does not appear to do so (I get a 404 Not Found error).

    Beyond that, if you're going to use the <audio> element, then I'd suggest specifying the codec as well as the basic MIME-type. Based on the URL you specified (which, again, does not seem valid), that would be:
    <audio autoplay>
    <source src=""; type="audio/mpeg; codecs=mp3" />
    Note: The semi-colon between the src and type attributes is a forum error and should not be there, the forums here do that for some reason, and it should be removed. The only semi-colon in the above example which should be there is the one within the type attribute.
  • Success! Foolish me, I'd moved a copy of the file into my website's Music folder, but neglected to upload the file to the server. Now it plays just fine when I go to the Twine page into which I put your suggested HTML lines. Thank you! I'm giving a presentation to some educators in November (in Calgary, Alberta) on the benefits of getting students to create their own story games, using programs like Twine. And I'll be using Twine to demonstrate how relatively easy it is. This could enlarge the community just a bit.
Sign In or Register to comment.