3

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.

1 Answers1

0

You can read the article from Apple:

https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html

By the way, you can't use autoplay or trig to play function video or audio because of:

https://stackoverflow.com/a/12496184/2686143

Community
  • 1
  • 1
guvenckardas
  • 738
  • 4
  • 8
  • Thanks for the info @Guvenckardas. What is confusing is that in both cases in my code, the play method is triggered initially by a click event (pressing Start/Replay or Play All Sounds) by the user. Thus, I am not really sure why does one function behaves differently than the other one. – Nikolaos Alexiou Sep 09 '15 at 12:58
  • Actually, there is not a real different behaviour. Just play function for video or audio not working. You know that, all media activities are managed in QuickTime player for iOs so it can control all activities. – guvenckardas Sep 09 '15 at 13:02
  • Do you want to play all sounds in the same time? – guvenckardas Sep 09 '15 at 16:28
  • I do not need to - I just created that button/scenario to test/compare against the Start/Replay button that won't play the sounds. – Nikolaos Alexiou Sep 09 '15 at 20:45