Ios loading html5 audio labels cannot be automatically played using js, ioshtml5

Source: Internet
Author: User

Ios loading html5 audio labels cannot be automatically played using js, ioshtml5

html5 audioTags 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 ');

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.