So I fired up one of our applications today in chrome (version 66) and mysteriously there was no audio. The applications worked fine in other browsers and sites like youtube played audio fine in Chrome. So what gives? Well I checked the console and…
I guess there’s no way around this huh? This is probably “by design” according to Chrome. Is there a way that unity could let us “restart” the AudioContext as a callback to an event listener? I really don’t know how we will get around this issue…
Do you have a workaround or a fixe ready for the 2018.x version?
It look that chrome will release the version 66 in a week : https://www.chromestatus.com/features/schedule
So what we do if the audio do not work?
Thank you
Like the google update is planned for the next week and that i doubt that like per magic you will release a patch for that, can you tell us if a workaround is possible on the Audio.js file present on Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib ?
If you click the page where the game is loading, then we do not get the warning message in the console and the audio should work.
If you do not click the page (just do not click the page or move your mouse till loading is complete), then we get the warning message in the console and the audio should not work.
Tested on chrome canary 67.0.3394.0
The both build do not contain any audio.
The result is the same in the both build. It’s maybe a window focus problem?
If the user do not interact with the page where the game is loading, then chrome shut down the audio and we have no way to get it back (we have to refresh the page).
For me, it’s a critical issue as chrome is used by 80% of our players.
This problem has been reported 2 months ago by kognito and we are at the same point. I’m sorry, but the unity team are doing something wrong somewhere in term of communication.
The unity staff said working or been in contact with the google team but google have annouced this audio change in September 2017 and we are still talking about that…
First of all apologies for the inconvenience. This issue clearly fell through the cracks.
Adding a button per-se is not hard but this is probably something you want to customize based on your content anyway. Ideally, you have your own WebGL template which implements such flow.
Having said that we understand this is a problem, especially for first-time users, and we are going to provide a solution as soon as possible.
function _JS_Sound_Init() {
try {
window.AudioContext = window.AudioContext || window.webkitAudioContext;
WEBAudio.audioContext = new AudioContext();
var tryToResumeAudioContext = function() {
if (WEBAudio.audioContext.state === 'suspended')
WEBAudio.audioContext.resume();
else {
clearInterval(resumeInterval);
}
};
var resumeInterval = setInterval(tryToResumeAudioContext, 400);
WEBAudio.audioWebEnabled = 1;
} catch (e) {
alert("Web Audio API is not supported in this browser");
}
}
with the above code, audio should start as soon as the user interacts with the page. If that works you can patch your Unity installation by changing the source code in PlaybackEngines/WebGLSupport/BuildTools/lib/Audio.js
Ideally, we should also display a message to the user.
Can we update the live games(non development) without needing to rebuild from unity? We have a lot of games with web license bought from the developers(ofc without source code), so wanted to know if we can have this workaround without the needing of extra “Play” button ahead. @Marco-Trivellato