ga icon indicating copy to clipboard operation
ga copied to clipboard

audio broken on safari

Open increpare opened this issue 6 years ago • 0 comments

01_treasureHunter.html doesn't play audio in safari 12.1.1 for me, but does in Chrome/Firefox. (Usual browser audio sandboxing stuff, has to be somehow enabled in response to an event).

No error messages about it in the js terminal.

IIRC, this is my general handle for fixing the sound in puzzlescript - I call it whenever the user tries to play something (this means sometimes it skips the first sound - I could call it on startup as well I guess):

//unlock bullshit
function ULBS(){   
  if (AUDIO_CONTEXT.state === 'suspended')
  {
      var unlock = function()
      {
        AUDIO_CONTEXT.resume().then(function()
          {
            document.body.removeEventListener('touchstart', unlock);
            document.body.removeEventListener('touchend', unlock);
            document.body.removeEventListener('mousedown', unlock);
            document.body.removeEventListener('mouseup', unlock);
            document.body.removeEventListener('keydown', unlock);
            document.body.removeEventListener('keyup', unlock);
          });
      };

      document.body.addEventListener('touchstart', unlock, false);
      document.body.addEventListener('touchend', unlock, false);
      document.body.addEventListener('mousedown', unlock, false);
      document.body.addEventListener('mouseup', unlock, false);
      document.body.addEventListener('keydown', unlock, false);
      document.body.addEventListener('keyup', unlock, false);
  }
}

)

increpare avatar Aug 18 '19 21:08 increpare