Bug in SimpleAudioEngine::playEffect() on iOS

Bug in SimpleAudioEngine::playEffect() on iOS
0.0 0

#1

Hi

I have found a major bug in SimpleAudioEngine::playEffect() on iOS. It stops working after foreground-background transition on some iOS devices. How to reproduce:

  1. Create default cocos project:
    cocos new AudioBugTest -p com.company.audiotest -l cpp -d d:\MyProjects

  2. Add code to AppDelegate::applicationDidFinishLaunching:
    SimpleAudioEngine::getInstance()->preloadBackgroundMusic(“bk.mp3”);
    SimpleAudioEngine::getInstance()->preloadEffect(“click.caf”);
    SimpleAudioEngine::getInstance()->playBackgroundMusic(“bk.mp3”, true);

Replace code in HelloWorld::menuCloseCallback with
SimpleAudioEngine::getInstance()->playEffect(“click.caf”);

Uncomment #define USE_SIMPLE_AUDIO_ENGINE 1 in AppDelegate.cpp

Add bk.mp3 and click.caf to existing Resources folder and include them in XCode project

  1. Run project on device. Click button on the screen, click.caf should be working

  2. Click the Home button on device, application will go to background

  3. Click application icon, application will go to foreground. Click button on the screen. Background music is working, but click.caf IS NOT WORKING anymore!!!

I can reproduce this bug on iPod Touch 6 running iOS 10.3.1
On iPad 3 running iOS 8.4.1 all is working fine (no bug)
Using Cocos 3.15.1, XCode 9
Project files attached
AudioBugTest.zip (64.7 KB)

I have found the same issue here: