Issues based on iOS not playing

Source: Internet
Author: User

Because of the big monopoly game, need background music, fortunately is on the original basis, but the problem is that the music above the iOS can not play, that is. Play () is not valid, then I went online to find a piece of code

 function   Audioautoplay (id) { var  audio = document.getElementById (ID), play  = function   () {audio.play (); Document.removeeventlistener ( "Touchstart", play, false  );        };        Audio.play (); Document.addeventlistener ( "Weixinjsbridgeready", function   () {play ();        },  false  ); Document.addeventlistener ( "Touchstart", play, false  ); } audioautoplay ( ' audio_bg '); 

This addition, the background music can be loaded after the page automatically play, but there is a problem, the original page inside the. Play () will appear stacked, that is, no matter what button will execute the dice sound. This only removes the use of the above.

Then I saw in one place that theiOS music needed a trigger switch , and I added a judgment to the dice button to perform the music. Play () can be executed.

later they add demand , failure and correct answer also add sound, because to call Ajax, do not know whether it is because of the Click event Problem, here the. Play () can be executed, but the following lottery inside the. Play () actually does not execute , the dog coins!!!

After many tests, in my answer to the wrong, re-answer the question, I found that the lottery failed to be called ( because the answer is wrong and did not draw the same sound ), and then I think is because I have to pre-call first.

Audio has a parameter is mute (muted), I put the inside of the dice mute, and then call all the sound, so that all can be called from the beginning, the back of the need for the sound of the Unmute (with Prop can be solved)!

Based on an issue with iOS not playing

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.