Sound & Video

Adding Music & Sound Effects

Have you ever been inspired to write a story after hearing a specific song or sound effect? I love creating playlists that relate to my story ideas, and with Twine, I can add those songs directly into my project.

If you are working with the online version of Twine, your sound file will have to be stored in a separate location. For example, you can upload the sound to your Dropbox and grab the link.

If you are using the downloaded, computer version of Twine, you can link to the file directly on your computer.

To add a song or a sound effect to a passage, you can use the following codes. Remember to replace "soundfilepath" with the path to your sound file.

Harlowe:
<audio src="soundfilepath" autoplay>


SugarCube:
In SugarCube, you have to cache the sound file before using it:
<<cacheaudio audioID soundfilepath>>

<<audio "soundfilepath" play>>


SugarCube also has multiple options when it comes to working with sound and music. You can raise or lower the volume, edit playback, and more. Visit the SugarCube documentation page for more information.

How to Add Video

Adding videos to your Twine project is similar to using audio. Your video must be stored in an external place (like Dropbox) or on your computer, if you are using the downloaded version of Twine.

Use the following code to add a video in Harlowe or SugarCube. Remember to replace "videofilepath" with the path to your video file.

Harlowe & SugarCube:
<video src="videofilepath">&lit;/video>

<<video "videofilepath" play>>


You can also use the following attributes when working with videos in Twine:


Video Height & Width
<video src="videofilepath" width="640" height="480"></video>


Video Autoplay
<video src="videofilepath" autoplay></video>