diff options
author | Justin Kerk <dopefishjustin@gmail.com> | 2018-12-30 13:25:27 -0800 |
---|---|---|
committer | Justin Kerk <dopefishjustin@gmail.com> | 2018-12-30 13:25:27 -0800 |
commit | 56d8eeff86532123e6b8941cc94c975b5ab63172 (patch) | |
tree | 628962de771003b8c924aea20cb7b95b119bf7e1 /src/osd | |
parent | 3c34a1d3079e7d328cb1d6d74905296c2b53fa8b (diff) |
Workaround for Web Audio autoplay restrictions in Chrome 71 [Justin Kerk]
Diffstat (limited to 'src/osd')
-rw-r--r-- | src/osd/modules/sound/js_sound.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/osd/modules/sound/js_sound.js b/src/osd/modules/sound/js_sound.js index b1ca76eff9e..5cbcc380c1b 100644 --- a/src/osd/modules/sound/js_sound.js +++ b/src/osd/modules/sound/js_sound.js @@ -2,7 +2,7 @@ // copyright-holders:Grant Galitz, Katelyn Gadd /*************************************************************************** - JSMAME web audio backend v0.3 + JSMAME web audio backend v0.4 Original by katelyn gadd - kg at luminance dot org ; @antumbral on twitter Substantial changes by taisel @@ -64,20 +64,26 @@ function init_event() { eventNode.onaudioprocess = tick; //Connect stream to volume control node: eventNode.connect(gain_node); - //WORKAROUND FOR FIREFOX BUG: - initializeWatchDogForFirefoxBug(); + //Workarounds for browser issues: + initializeWatchDog(); }; -function initializeWatchDogForFirefoxBug() { - //TODO: decide if we want to user agent sniff firefox here, - //since Google Chrome doesn't need this: +function initializeWatchDog() { watchDogDateLast = (new Date()).getTime(); if (watchDogTimerEvent === null) { watchDogTimerEvent = setInterval(function () { var timeDiff = (new Date()).getTime() - watchDogDateLast; if (timeDiff > 500) { + //WORKAROUND FOR FIREFOX BUG: + //TODO: decide if we want to user agent sniff Firefox here, + //since Google Chrome doesn't need this: disconnect_old_event(); init_event(); + + //Work around autoplay restrictions in Chrome 71+ https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio + if (context) { + context.resume(); + } } }, 500); } |