0 votes
by (120 points)
retagged by
i'm new to twine and i was doing a beginner’s guide using SugarCube and I can't seem to play a mp3 file

i'm doing +passage and in the passage im putting

<<cacheaudio "tree" "sounds/steps.mp3">

and in the passage I want to play it i go

<<audio tree play>>

but it isn't working it says

Error: <<audio>>: track "tree" does not exist

i think it's because the guide was doing a older technique that is not up to date if so show me the new way if not that maybe i'm not doing cache audio correctly please help

and yes i put it as a html ner the sounds folder and play it

1 Answer

+1 vote
by (44.7k points)

If you want the audio to work from within Twine, then you'll have to give it an absolute path when running inside Twine.  I have some audio sample code here which shows how to do that, and that page also lets you know about a few other problems you may encounter.  You can also download that HTML file (plus the audio file) and import it into Twine 2 if you want to see the code directly.

You also might want to update to the latest version of SugarCube (currently v2.28.2), since some nice new audio features were added, such as being able to have the audio automatically mute/unmute itself when the window isn't/is visible.  (Installation instructions are here if you need them.)

Hope that helps!  :-)

by (159k points)

The OP also posted this question on the Twine Discord server, the main issue with the example posed there was the extra space characters in the track ID being passed to the <<audio>> macro.

their code:	<<audio" tree "play>>
should be:	<<audio "tree" play>>


by (120 points)
thank you so much this was a lot of help :)