SimpleAudioEngine - playEffect not working after ADMOB video

The problem happened on cocos2d-x 3.16 on iOS platform.

The following are the steps to reproduce.

  1. Call [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error]; at start up.
  2. Open iTune, play a song.
  3. Enter game, you should still hear the song.
  4. Call CocosDenshion::SimpleAudioEngine::getInstance()->playEffect
    -> it works.
  5. Open an ADMOB ad with video.
  6. iTune music resume
  7. Call CocosDenshion::SimpleAudioEngine::getInstance()->playEffect
    -> it doesn’t work.

I trace the code and found that _sourceGroups[sourceGroupId].enabled is false. Do you think you could help? Thank you very much.

Just some updates. If I call the following in GADMobileAds, the playerEffect function works but the itune music stopped. It looks there are something conflict between GADMobileAds and Cocos2dx. The result is as below.

[[GADMobileAds sharedInstance] audioVideoManager].audioSessionIsApplicationManaged = YES;

  1. Call [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error]; at start up.
  2. Call [[GADMobileAds sharedInstance] audioVideoManager].audioSessionIsApplicationManaged = YES;
  3. Open iTune, play a song.
  4. Enter game, you should still hear the song.
  5. Call CocosDenshion::SimpleAudioEngine::getInstance()->playEffect
    -> it works.
  6. Open an ADMOB ad with video.
  7. iTune music stopped and cannot resume.
  8. Call CocosDenshion::SimpleAudioEngine::getInstance()->playEffect
    -> it works.