audio works fine on Android but on iOS the background music doesn’t play and just one effect plays. This effect, which is the button click effect, plays after a delay of few seconds the first time but after that delay it sounds ok.
I’ve tested my game on an iPad2 and iPhone $s running iOS7 and an iPhone 3GS with iOS6.
1st you might need to preload the file into res
at first i have the delay as well but after preload, there should be no more delay.
about the music and effect, i found there are some issue on IOS browser (Safari and Chrome)
if i play 1 effect first on the start scene. all other music and effect works like a charm
if i don’t play that effect, later on the other scene are just silent.
This problem is a limitation on iOS mobile navigators: audios can only be played in an event handling circle, like in event handler for touch begin. If you only play the audio with javascript API in your own game loop, the audio won’t get played. It’s a limitation decided by Apple and widely complained by web developers, for now, we are also looking for other walk around for this problem.
You can still play a sound when user interact with your page, for example, when user click on “Start Game” button, you can call the play function of your game scene background sound, and when user tap to make the role jump, you can also play an effect sound of jump.
What you can’t and probably very annoying, is that you may fail to play an effect sound when the role touches a wall or drop down from the scene without a user interaction.
If you finally find some walk around, I’ll appreciate that you can make a note here.
Thanks
Actually, the recent change to CocosDenshion/SimpleAudioEngine.js when we went from 2.2 to 2.2.1 is what is causing this. RavelMatic is correct. Audio on iOS used to work on 2.2 and there were many changes to the audio engine. Whoever made those extensive changes has broken playback on iOS. I have done direct A/B tests with the exact same code to verify this.
Please let me know how we can either rollback the audio engine code, or fix the new file to work on arguably the most important device platform out there.
My tests show that 2.2.1 audio works on Android, just not on iOS.
I think we do have audio play issues on iOS for the version 2.2.1.
Don’t worry, it has been fixed on develop branch and the solution will be released in the next version 2.2.2
Or if you can’t wait, you can just use the develop branch.
I’ve tried with v2.2.2. It works fine on Android but on iOS isn’t possible to play effects and the soundtrack simultaneously. I am doing anything wrong?
Sadly, on iPhone, it’s not possible to play two sound in the same time.
And there is still no walk around for playing audio without triggering from an event.
Sorry I made a serious mistake.
It was an issue that it can’t work. We do support simultaneous sound play on iOS with WebAudio API.
The issue has been fixed here: https://github.com/cocos2d/cocos2d-html5/pull/1510