Skip to content

Audio stops playing after switching audio output route while app is in background #2479

@lucycycy

Description

@lucycycy
  • axmol version: 2.3.2
  • devices test on: iPhone
  • developing environments
    • Xcode version: 16.2
    • cmake version: 3.31.5

On iOS, if I play background music using AudioEngine::play2d, then send the app to the background and change the audio route (e.g., from speaker to headphones or vice versa), the audio does not resume when returning to the app.

In this situation, the following log message appears:

AURemoteIO.cpp:1666 AUIOClient_StartIO failed

Steps to Reproduce:

  1. Start playing audio using AudioEngine::play2d("bgm.mp3").
  2. Send the app to the background.
  3. Switch the audio output (e.g., plug in or unplug headphones).
  4. Return to the app.
    The background music is no longer audible.

Workaround:
If I comment out the following lines in AudioEngineImpl.cpp, the issue no longer occurs:
else if ([notification.name isEqualToString:AVAudioSessionRouteChangeNotification])
{ // replay
//// ccALPauseDevice();
//// ccALResumeDevice();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcocos2dxThe issue present in original cocos2dx

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions