简体   繁体   中英

HTML5 audio issue with Mobile Safari iOS

I have created a Simon Game here on Codepen: http://codepen.io/nalexiou/pen/rOaQOK

On the desktop, the audio/sound is playing fine. However, when I visit the site using my iPhone's Safari, the sound will not play.

I call the play() method on the sound variables (green, red, etc.) via this jQueryUI code:

......
 $('.' + items[0]).addClass('active', speed, function() {
    obj[items[0]].play();}).removeClass('active', speed, 
    function() {
    nextItemActivate(items.slice(1));
 });
......

However, if I trigger the play() methods first like this:

$('.test').on('click', function() {
  green.play();
  red.play();
  yellow.play();
  blue.play();
})

then the my addClass code does play the sounds.

Could this issue be related with the jQueryUI library or is there something special I need to consider for the Mobile Safari browser?

Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM