Howdy, Stranger!

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

Timed sound effects on mobile?

So basically when I use something like <<timed 2s>><<audio "bgm_song1" loop play>><</timed>>\, it works fine on my laptop browser but when I run the html on my android tablet or phone none of the timed sound effects work. Other timed elements work and sound effects that occur on passage loads or <<click>>s work. I was just wondering if I'm doing something wrong on my part or if there's a way around it or if it's just a limitation of twine on mobile devices.

Thanks

Comments

  • It's a limitation of the HTML <audio> element—which is what backs the audio macros—in mobile devices. Generally, mobile devices limit playback of HTML audio and video to those triggered by user interaction. Additionally, volume control is also usually limited, which affects not only direct volume manipulation but also fading.

    Depending on how you're going about it, you may be able to get timer triggered playback to work on mobile devices by "priming" the playback via user interaction. For example, if you're trying to have a timed effect play within a passage, you may be able to do something like the following:
    <<audio "bgm_song1" loop play>><<audio "bgm_song1" pause>>\
    <<timed 2s>><<audio "bgm_song1" play>><</timed>>\
    
    It looks ridiculous, however, it or some variant thereof might work—I've tested something similar before for someone else, as I recall. The reason would be because playback is initially started by user interaction—the click that delivered the user to the passage—and then immediately paused—so nothing is actually played at that moment—to be restarted by the timed play action.
  • It worked! Thanks for the help, TheMadExile. Its much appreciated.
Sign In or Register to comment.