According to company needs, a holiday promotion campaign was written in WeChat official account. Demand is similar to a micro scene statistics. What happened to users in a certain month or so….emmmmmm.
In order to make the atmosphere get the appropriate setting off, music needs are added.
And to saveApp developmentEngineers develop resources that they needNest my H5 page。
So here’s the question~~This page can play music automatically in wechat browser and android app, but not in Apple App.
So… Let’s see how I can solve this problem. Code it directly~~~~~
musicAutoplayIos () {
wx.config ({// wechat configuration information
debug: false,
appId: "",
timestamp: 1,
nonceStr: "",
signature: "",
jsApiList: []
})
wx.ready(function() {
document.getElementById("audio").play();
});
}
After the method has been declared, the next step is to call it
const oAudio = document.getElementById ("audio"); // must be obtained natively
this.musicAutoplayIos (); // compatible with IOS mobile phone, written by wechat browser
oAudio.play (); // compatible with Android phones, written in wechat browser
So far ~ ~ the above code can be compatible with IOS mobile phones, so that audio tags can also play music automatically in Apple App