Play pit audioSource with Google Chrome

Problem Description

In cocos creator cc.AudioSource function testing, we found a particularly strange phenomenon

Run Google browser from time, how could hear the sound, then F12 to see find such a warning

The AudioContext was not allowed to start. It must be resumed (or
created) after a user gesture on the page. https://goo.gl/7K7WLu

Then, I used to run the simulator can normally hear the sound

Then I use QQ browser tried to run, but also to hear the sound normal, but there are warnings

The Web Audio autoplay policy will be re-enabled in Chrome 71
(December 2018). Please check that your website is compatible with it.
https://goo.gl/7K7WLu

In fact, the meaning is the ultimate expression of more than two

Google Chrome 71 version from the beginning to open up Google's security policies , so the sound does not automatically lead to the player, it can play music must be in operation after the user has, for example, you can click back
https://goo.gl/7K7WLu
this link also can be triggered to play music.


Another way is to amend the Google security policy
input on Google browser:

chrome://flags/#autoplay-policy

See the following option, change it to a second term No user gesture is required
Here Insert Picture Description

So far the perfect solution!

Published 43 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_26542493/article/details/90582404