iOS to save user traffic, preload and autopaly tags for audio and video tags are automatically blocked,
This is done unless the user clicks the interaction manually.
But for the background music, it must be loaded when the time to execute, how to do, directly call JS from the dynamic trigger.
<audio id= "Bgaudio" src= "./media/bg-music.mp3" loop= "loop" ></audio><script type= "Text/javascript" >document.getelementbyid (' Bgaudio '). Play ();</script>
No doubt, just a few lines of code, compatible with iOS and Android
Of course there are special iOS settings are not compatible, we can use the following way, but note only in the browser open
<audio preload= "preload" Controls id= "Car_audio" src= "./media/bg-music.mp3" loop></audio><script> SetTimeout (function () { $ (window). scrolltop (1);},0); document.getElementById (' Car_audio '). Play (); Document.addeventlistener ("Weixinjsbridgeready", function () {Weixinjsbridge.invoke (' Getnetworktype ', {}, function ( e) { document.getElementById (' Car_audio '). Play ();}); }, False);</script>
Automatic playback of background music (compatible with iOS and Android)