Howdy, Stranger!

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

How do you play a .mp3 file on Twine 2?

I'm currently using SugarCube 1.0.34, I have read a bunch of forum posts and stuff, but my code still doesn't work.
Right now the code I have cache the audio looks like this in my StoryInit passage:
<<cacheaudio "bgm_mainsoundtrack" "Users/Name/Documents/Twine/Dungeon_Soundtrack_Main.mp3">>
And my audio code looks like this:
<<audio "bgm_mainsoundtrack" play>>
However, the audio doesn't play. Can someone please tell me what I'm doing wrong?
Thanks so much!

Comments

  • You can't play locally referenced media files when using either the Test or Play options, especially if you are using the install-able release of the Twine 2 application.

    You either have to:

    1. Host the media file on-line and use a fully referenced URL

    2. Use the Publish to File option to create a Story HTML file which you need to save in a folder on your local hard-drive. Your media files need to be stored either in the same folder as the Story HTML file or within a sub-folder.

    So the steps for 2 would be something like the following:

    a. Create a folder named mystory on your hard-drive, you will be storing your Story HTML file in this later.

    b. Create a sub-folder named media within the mystory folder.

    c. Copy all your media files into the media folder.

    d. Change the file reference in the <<cacheaudio>> macro to look for the media file in the media folder.
    <<cacheaudio "bgm_mainsoundtrack" "media/Dungeon_Soundtrack_Main.mp3">>
    
    e. Use the Publish to File option to create a Story HTML file and save it in the mystory folder.

    f. Open the Story HTML file in your web-browser and you should hear the sound now.
  • Thanks so much! It works now!
Sign In or Register to comment.