Last active
October 15, 2019 14:45
-
-
Save hogart/dab4c1c5c29c2056353d400f92e2498b to your computer and use it in GitHub Desktop.
twine-bgmusic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::StoryTitle | |
twine-bgmusic | |
::PassageReady | |
<<if !$masterPlaying && passage() !== 'YOUR-START-PASSAGE'>> | |
<<bgsound>> | |
<</if>> | |
::_setup-sound | |
<!-- <<include [[_setup-sound]]>> in StoryInit --> | |
<<set $trackStartCrossfade = 15>> | |
<<set $masterPlaying = false>> | |
<<set $audioEnabled = window.location.host.includes('ssl.hwcdn.net') || window.hasMusic || window.location.host.includes('localhost')>> | |
<<if $audioEnabled>> | |
<<waitforaudio>> | |
<<cachetrack "YOUR-TRACK">> | |
<<waitforaudio>> | |
<</if>> | |
::widget-bgsound [widget] | |
<<widget bgsound>> | |
<<if $audioEnabled>> | |
<<set _track = ($args[0] || 'YOUR-TRACK')>> | |
<<audio _track volume 0 fadeoverto $trackStartCrossfade 1 loop>> | |
<<set $masterPlaying = true>> | |
<</if>> | |
<</widget>> | |
::widget-cachetrack [widget] | |
<<widget "cachetrack">> | |
<!-- trackname, [path = './sound/'] --> | |
<<set _path = ($args[1] || './sound/') + $args[0] + '.'>> | |
<<cacheaudio $args[0] `_path + 'mp3'` `_path + 'ogg'`>> | |
<</widget>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment