Ios loading html5 audio labels cannot be automatically played using js, ioshtml5
html5
audio
Tags cannot be automatically played in ios browsers. Android and pc are normal for a small project recently, but ios is not the case. I have read a lot of information, the following method may not be the best method. If you have a more convenient method, please leave a message:
Html section:
<Audio id = "audio"> <source src = "20161012102044_57fd9dfc044cd.pdf"> </audio>
<Script>
Audio = document. getElementById ('audio ');
Audio. play ();
</Script>
Js section:
// Function:
Function audioAutoPlay (id)
{
Var audio = document. getElementById (id );
Var play = function (){
Document. removeEventListener ("WeixinJSBridgeReady", play );
Document. removeEventListener ("YixinJSBridgeReady", play );
// Document. removeEventListener ("touchstart", play, false );
Audio. play ();
Audio. pause ();
};
Audio. play ();
Audio. pause ();
// Weixin document. addEventListener ("WeixinJSBridgeReady", play, false );
// Yixin document. addEventListener ('yixinjsbridgeready', play, false );
// Touch document. addEventListener ("touchstart", play, false );
}
// Call:
AudioAutoPlay ('audio1 ');