0 votes
by (150 points)
reshown by
Please help me.

I can't add music with StoryInit, <<cacheaudio "song" "music/song.mp3">> for example and <<audio song play>>. I don't know what to do to play this music. I'm using Sugarcube 2.28 and Twine 2.

1 Answer

0 votes
by (44.7k points)
selected by
 
Best answer

Most modern browsers now block autoplaying audio (in both music files and videos) due to spam ads that blast audio unexpectedly.  Due to this you'll need to have the audio play only after the user has interacted with the story, such as by clicking a link or button, since the browsers will allow it at that time.  The simplest way to do this is to only start the audio after they either go to the second passage of the game or if they click a button to "unmute" the audio.

If you still need help, then you can take a look at the "Music" sample code here and it should show you what you need.

Hope that helps!  :-)

by (150 points)
Sorry, didn't helped. I don't know what to do. I will send here link for test twine html and can you please find mistake or tell me why it doesn't work?

http://www.mediafire.com/file/w782kz8sl5lsjg5/test.zip/file

Audio commands are same as my story.
by (44.7k points)

The problem is exactly what I explained to you above and what was explained at that link.  You're trying to autoplay the audio before the user has interacted with the page.  If you move the:

<<audio "start" play>>

to the "End" passage, then it works just fine fine after you click the "Continue" link which takes you to the "End" passage.  This is because, by clicking that link, you've now interacted with the page.

You just need to have the user interact with the page before you can play any audio.

by (150 points)
Thank you it now work.
...