原因: 因为各大浏览器都为了节省流量,做出了优化,在用户没有行为动作时(交互)不予许自动播放; /音频,写法一
<audio src= "Music/bg.mp3" AutoPlay loop controls> your browser is not yet supported Oh </audio>
//音频,写法二
<audio controls= "Controls" > <source src= "Music/bg.ogg" type= "Audio/ogg" ></source> < SOURCE src= "Music/bg.mp3" type= "Audio/mpeg" ></source> //Priority play Music Bg.ogg, not supported in play Bg.mp3</ Audio>
//JS绑定自动播放(操作window时,播放音乐)
function () { music.play (); })
//下兼容处理
function () { music.play (); false);
< Span class= "hljs-string" > summary: 1.audio element AutoPlay properties are not available on iOS and Android, normal on PC side; 2.audio element does not set controls when the iOS and Android will occupy space, while on the PC side Chrome will not occupy any space; 3. Note that you do not miss the compatibility of processing needs to reference JS;
Audio elements and video elements do not play automatically in iOS and Andriod