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