Twine Version: 2
Story Format: 2.34.1
Hi, thanks for all the help in the past!
So my first passage has:
<<cacheaudio “ping” “https://upload.wikimedia.org/wikipedia/commons/xyz.flac” “media/audio/ping.ogg”>>\
And most of the passages start with:
<<audio “ping” play>>
However if the user reloads their browser at any point, they will get the following error on every passage (and no sound).
“Error: (doublebrackets)audio(doublebrackets): error during runner initialization: track “ping” does not exist”
I’m assuming that caching audio on every passage is going to cause data download repeatedly which doesn’t seem reasonable (no idea - does it?), and possibly will slow the game down (does it?).
So I tried adding the following to the top of each passage as a fix, but it doesn’t work.
if (!(SimpleAudio.tracks.has(“ping”))) {
<<cacheaudio “ping” “https://upload.wikimedia.org/wikipedia/commons/xyzetc.flac” “media/audio/ping.ogg”>>
}
I’m not sure this code can even go in a passage because twine displays it, so it’s clearly not implemented right. Maybe code for the API doesn’t go in the passages - no idea. The motoslave documentation doesn’t seem to say what you actually do with those sort of snippets.
In future I’ll load the audio from C/username/somewhere, rather than wikimedia, so I guess I could re-cache the audio at the start of every single passage? Seems like overkill though.
Any advice appreciated!