User Tools

Site Tools


twine2:add_an_image_movie_sound_effect_or_music

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
twine2:add_an_image_movie_sound_effect_or_music [2015/05/15 18:58]
klembot
twine2:add_an_image_movie_sound_effect_or_music [2017/10/09 20:39] (current)
Line 2: Line 2:
  
 Twine 2 doesn'​t currently have the ability to embed multimedia into your story. If you'd like to create something that makes heavy use of images, sound, or movies, you may want to stick to Twine 1 for now. But that's not to say that you can't use these things in your story! For now, you'll need to store them elsewhere -- whether it's on a web site you control, or a service you use like Dropbox -- and put references to them in your story. Twine 2 doesn'​t currently have the ability to embed multimedia into your story. If you'd like to create something that makes heavy use of images, sound, or movies, you may want to stick to Twine 1 for now. But that's not to say that you can't use these things in your story! For now, you'll need to store them elsewhere -- whether it's on a web site you control, or a service you use like Dropbox -- and put references to them in your story.
 +
 +<WRAP important>​
 +If you are using relative links for your multimedia, you will need to publish your story to the correct location on your computer so that the references point to the right place. If you have an image tag whose source property is "​myimage.jpeg",​ for example, then your published file must be placed in the same folder as the file myimage.jpeg. [[https://​developer.mozilla.org/​en-US/​Learn/​Understanding_URLs#​Absolute_URLs_vs_relative_URLs|Learn more about relative links]]
 +
 +If you are using relative links, testing or playing your story inside Twine will unfortunately not work.
 +</​WRAP>​
  
 <WRAP info> <WRAP info>
Line 30: Line 36:
 ==== Adding Sound Effects and Music ==== ==== Adding Sound Effects and Music ====
  
-The code to add a sound effect looks like this:+The code to add a basic sound effect looks like this:
  
 <​code>​ <​code>​
Line 37: Line 43:
  
 The autoplay attribute causes it to play as soon as the passage it is in is displayed. The autoplay attribute causes it to play as soon as the passage it is in is displayed.
 +
 +That said, SugarCube has features that make using audio much simpler, and also allow for music. If you use the code above, you'll find that any music ends as soon as the reader navigates to another passage, which is probably not what you'd like to have happen. There are two steps to using audio in SugarCube. First, you'll need to cache it. Caching it allows the browser to load your audio ahead of time, so that there isn't a delay when you ask it to be played. It also allows you to give each sound effect or piece of music a short name to make 
 +
 +<​code>​
 +<<​cacheaudio "​door-opens"​ "the URL of your sound effect">>​
 +</​code>​
 +
 +The best place to cache audio is right at the start of your story. On a later passage, playing a sound effect is as simple as writing:
 +
 +<​code>​
 +<<​audio "​door-opens">>​
 +</​code>​
 +
 +There are many other options that let you fade in and out sounds, play multiple at the same time, and even move to another passage when a sound effect finishes. For more information,​ see the [[http://​www.motoslave.net/​sugarcube/​docs/​macros.html#​macrocat-audio|Audio section of the SugarCube macro documentation]].
 +
 +==== External Resources ====
 +
 +  * DJ White created a library called Twine Audio for incorporating narration into Twine stories. It only works on Chrome and Opera browsers, however. The original web site //​twineaudio dot com// seems to currently point to spam sites.
 +  * Dan Cox has published a [[https://​www.youtube.com/​watch?​v=zRxuFK2ukrw|tutorial video]] on adding images with the SugarCube story format.
twine2/add_an_image_movie_sound_effect_or_music.1431730729.txt.gz ยท Last modified: 2017/10/09 20:38 (external edit)