On Safari 12, I am trying everything I can to get audio to have sound. It was working on Safari 11, but not on Safari 12. In the app, calling resume() on the audioContext after a user interaction gets the audio context out of suspended and into running in all cases. So I am assuming that it is "allowed to start" per Web Audio API. However, if user interaction is within ~5 seconds of loading the page, sound comes out. If after 5 seconds, no sound. Thanks. function fixAudioContext() { console.log("1: " + audioContext.state); return audioContext.resume().then(function() { console.log("2: " + audioContext.state); var buffer = audioContext.createBuffer(1, 1, 22050); var source = audioContext.createBufferSource(); source.buffer = buffer; // Connect to output (speakers) source.connect(audioContext.destination); // Play sound if (source.start) { source.start(0); } else if (source.play) { source.play(0); } else if (source.noteOn) { source.noteOn(0); } console.log("3: " + audioContext.state); audioContextDeferred.resolve(audioContext.state); }) .catch(function() { }); } After 5 seconds console still prints, "1: suspended, 2: running, 3: running" but no sound. The creating buffer stuff is an attempt to play a silent sound to warm up the context. Honestly just a shot in the dark.
<rdar://problem/45177309>
Created attachment 352003 [details] webaudio-after-5s.html Hi Jordan, I fleshed out your example a bit, and used an oscillatorNode instead of a audioSourceBufferNode, just so I could hear the results, and it definitely seems to be audible, no matter how long I wait before hitting the button. Could you post a more complete version of your test case?
Jer Noble, I setup a mini example demo myself to try to reproduce, but it was working as expected. I finally found the bug in my application code that was causing the strange time dependent behavior. This ticket can be closed out because there is nothing wrong. Thank you so much for responding. Sincerely, Jordan