Howdy, Stranger!

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

Different audio files in the same passage

edited October 2015 in Help! with 2.0
Hello,

A story I am working on has a passage that opens with the sound of thunder - meaning that as soon as the passage is loaded, it also loads the respective mp3.
Here is the code (just in case). It's the very first line of that passage.
<audio autoplay>
<source src="[path edited to make it shorter]thunder.mp3" type="audio/mpeg" />
</audio>

It would be nice, however, if after the thunder, players could still hear a continuous faint sound of rain, to convey the idea that they are inside a room, but outside it is raining very heavily.

Is this possible, and how would you suggest to do that without forcing the user to load really long (big) audio files?

I am working with Harlowe, Twine 2.

Comments

  • The audio element includes a loop attribute.

    I'm not at the machine I normally test Twine code on, but something like the following should work:
    <audio autoplay loop>
    <source src="[path edited to make it shorter]thunder.mp3" type="audio/mpeg" />
    </audio>
    
  • greyelf wrote: »
    The audio element includes a loop attribute.

    I'm not at the machine I normally test Twine code on, but something like the following should work:
    <audio autoplay loop>
    <source src="[path edited to make it shorter]thunder.mp3" type="audio/mpeg" />
    </audio>
    

    This would have the "thunder" audio looping though...
    So would you suggest that I put together a longer file that starts with a thunder, than have some rain, and let it loop?

  • Unless you want the thunder to loop as well, putting it together with the rain is probably not your best option. Just play them both, but only loop the rain. For example:
    <audio autoplay loop>
    <source src="…/rain.mp3" type="audio/mpeg; codecs=mp3" />
    </audio>
    <audio autoplay>
    <source src="…/thunder.mp3" type="audio/mpeg; codecs=mp3" />
    </audio>
    
  • Melyanna wrote: »
    greyelf wrote: »
    The audio element includes a loop attribute.

    I'm not at the machine I normally test Twine code on, but something like the following should work:
    <audio autoplay loop>
    <source src="[path edited to make it shorter]thunder.mp3" type="audio/mpeg" />
    </audio>
    

    This would have the "thunder" audio looping though...
    So would you suggest that I put together a longer file that starts with a thunder, than have some rain, and let it loop?
    Unless you want the thunder to loop as well, putting it together with the rain is probably not your best option. Just play them both, but only loop the rain. For example:
    <audio autoplay loop>
    <source src="…/rain.mp3" type="audio/mpeg; codecs=mp3" />
    </audio>
    <audio autoplay>
    <source src="…/thunder.mp3" type="audio/mpeg; codecs=mp3" />
    </audio>
    

    Thank you! This is easier than I thought.
Sign In or Register to comment.