Priority: P3: Somewhat important
Affects Version/s: 5.12.4
Fix Version/s: 5.15.1
Commits:b5a55492a63cb2cda75d6f980acb7fc5ae8dfc22 (qt/qtmultimedia/dev) 956fbd3f352f8bba5b8bf985b1787fc7b71aff24 (qt/qtmultimedia/5.15)
When I launch an empty Qt app while music is playing on my iOS device, the music continues to play in backgronud
However, when I add the the following line to main.cpp, the music stops playing after starting the ap
QAudioDeviceInfo m_deviceInfo = QAudioDEviceInfo::defaultInputDevice();
I think this is because the default iOS AVAudioSession is used (as I found here https://code.woboq.org/qt5/qtmultimedia/src/plugins/coreaudio/coreaudiosessionmanager.mm.html)
The default AVAudioSession has the following behavior (from https://developer.apple.com/documentation/avfoundation/avaudiosession)
- When the app plays audio, it silences any other background audio.
- In iOS, locking a device silences the app’s audio.
The first item is what we observe in this issue (the second item implies that we can't run our app in background, not even when setting UIBackgroundMode to audio)
Possible solution (not tested): configure the AVAudioSession by adding lines like
[session setCategory:AVAudioSessionPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]
[session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil]