Add code to resume blocked AudioContexts
This commit is contained in:
parent
a33b0002ee
commit
7421ac9e24
@ -85,7 +85,8 @@ jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaB
|
||||
margin: 0;
|
||||
margin-top: 20px;
|
||||
margin-left: 20px;
|
||||
display: inline-block; vertical-align: top;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
-webkit-animation: rotation .8s linear infinite;
|
||||
-moz-animation: rotation .8s linear infinite;
|
||||
-o-animation: rotation .8s linear infinite;
|
||||
@ -253,8 +254,7 @@ jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaB
|
||||
progressElement.value = null;
|
||||
progressElement.max = null;
|
||||
progressElement.hidden = true;
|
||||
|
||||
if (!text) spinnerElement.hidden = true;
|
||||
if (!text) spinnerElement.style.display = 'none';
|
||||
}
|
||||
|
||||
statusElement.innerHTML = text;
|
||||
@ -263,7 +263,8 @@ jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaB
|
||||
monitorRunDependencies: function(left) {
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
||||
}
|
||||
},
|
||||
//noInitialRun: true
|
||||
};
|
||||
|
||||
Module.setStatus('Downloading...');
|
||||
@ -274,6 +275,48 @@ jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaB
|
||||
Module.setStatus = function(text) { if (text) Module.printErr('[post-exception status] ' + text); };
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- NOTE: This code snippet displays a button that resumes blocked AudioContexts by
|
||||
the autoplay policy. For more detail on the autoplay change in Chrome, check:
|
||||
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio. -->
|
||||
<script type='text/javascript'>
|
||||
/*
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
(function() {
|
||||
const list = [];
|
||||
self.AudioContext = new Proxy(self.AudioContext, {
|
||||
construct(target, args) {
|
||||
const result = new target(...args);
|
||||
list.push(result);
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
const btn = document.createElement('button');
|
||||
|
||||
btn.classList.add('unmute');
|
||||
btn.style.position = 'fixed';
|
||||
btn.style.bottom = '0';
|
||||
btn.style.right = '0';
|
||||
btn.textContent = '🔇 Unmute';
|
||||
btn.style.fontSize = '5em';
|
||||
btn.onclick = e => {
|
||||
list.forEach(ctx => ctx.resume());
|
||||
btn.remove();
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', _ => { document.body.appendChild(btn); });
|
||||
})();
|
||||
</script>
|
||||
{{{ SCRIPT }}}
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user