Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio broken on safari #73

Open
increpare opened this issue Aug 18, 2019 · 0 comments
Open

audio broken on safari #73

increpare opened this issue Aug 18, 2019 · 0 comments

Comments

@increpare
Copy link

increpare commented Aug 18, 2019

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);
  }
}

)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant