[]webaudio 在iframe中使用, android chrome中没声音
在android chrome上,直接在192.168.188.253:8080/index.html访问是可以播放webaudio的,但是通过iframe src="192.168.188.253:8080/index.html"却不行。经过搜索,是chrome禁止iframe中的跨域webaudio自动播放。参考Block Web Audio autoplay on cross origin iframes https://bugs.chromium.org/p/ch ... 14115
为了解决这个问题,我又参考了https://github.com/photonstorm/phaser/issues/2913
在引擎WebAudioSound源码中添加了几行,解决了问题。官方要不要修复一下这个BUG?
WebAudioSound._playEmptySound=function(){
if (WebAudioSound.ctx==null){
return;
};
var source=WebAudioSound.ctx.createBufferSource();
source.buffer=WebAudioSound._miniBuffer;
source.connect(WebAudioSound.ctx.destination);
source.start(0,0,0);
//Hello Chrome 55!
if (source.context.state === 'suspended') {
source.context.resume();
}
}
为了解决这个问题,我又参考了https://github.com/photonstorm/phaser/issues/2913
在引擎WebAudioSound源码中添加了几行,解决了问题。官方要不要修复一下这个BUG?
WebAudioSound._playEmptySound=function(){
if (WebAudioSound.ctx==null){
return;
};
var source=WebAudioSound.ctx.createBufferSource();
source.buffer=WebAudioSound._miniBuffer;
source.connect(WebAudioSound.ctx.destination);
source.start(0,0,0);
//Hello Chrome 55!
if (source.context.state === 'suspended') {
source.context.resume();
}
}
要回复问题请先登录
1 个回复
ymsdandan
赞同来自: