Howdy, Stranger!

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

Cannot get TIMED macro to work on Ipad

Hi, I am using Twine 2 and Sugarcube 2.

My story contains some audio, and everything works fine including playback of audio, but when I add the "Timed" macro, it never plays. The code is really simple:
<<timed 7s>><<audio "purplerain" play volume 1.0>><</timed>>

It works on my PC , but on Ipad/Iphone it does not work. I have tried Safari, Google Chrome and Firefox on the Ipad with the same result.

I am hosting all files on my website, not that I think that should have anything to do with it...

If it is well known that the timed macro doesn't work on IOS, does anyone know of a working replacement?

Best regards
Kenneth

Comments

  • Is it in a Windows sound format like wav?
  • Have you tried something other than playing music? Try displaying a picutre or printing some text inside the <<timed>>, then you'll at least know if it's the timed or the audio causing the problem.
  • Thanks for the advice - I'll test with a picture. It is MP3, but as I mentioned, it works fin if I just remove the timed tag
  • Ok, that was easy to test. It works fine with images, so the audio is the problem.

    What to do about I don't know.
  • I just tried with this way of playing audio. It works until I add the timed command :(
    <audio autoplay loop>
      <source src="http://farlig.dk/story/mp3/purple-rain.mp3"; type="audio/mp3">
    </audio>
    

    So I have no idea where the problem lies...
  • It's because of how mobile browsers treat HTML5 media elements. Playback of all media elements, currently, must be authorized by direct end user action. Using any sort of timing macro or function does not meet this requirement.

    That said, all is not lost. Once playback has been initiated by direct end user action it should remain authorized for the lifetime of the element, so you just need a way to force the authorization.

    I don't know how much audio or how pervasive delayed playback is within your project, however, you could do something like the following.

    1. Create a new passage, tag it with widget, and then paste something like the following into it:
    <<widget "authorizeaudio">>\
    <<silently>>
    	<<audio ":all" volume 0 play>>
    	<<audio ":all" stop>>
    	<<audio ":all" volume 1>>
    <</silently>>\
    <</widget>>
    
    NOTE: If your project uses a significant amount of audio, you may need to limit that to just the tracks you intend to delay.

    2. Assuming you have single link which leads from the starting passage into the rest of your project, do something like the following for that link:
    <<link [[link here]]>>
    	<<authorizeaudio>>
    <</link>>
    

    3. You'll also likely need to do something like the following to force the authorization when loading a save: (Twine 2: goes in Story JavaScript; Twine 1: goes in script-tagged passage)
    Config.saves.onLoad = function () {
    	new Wikifier(null, '<<authorizeaudio>>');
    };
    
  • Thanks a LOT for this very detailed reply. I'll look at that as a solution - hopefylly I can make it work :-)

    Thanks again
    /Kenneth
  • I couldn't make it work, and have given up. I'll fade in music instead.
Sign In or Register to comment.