Qt Quick iOS: How to keep audio playing while app is in background
-
I'm developing a WebRadio application in qml for iOS devices. To play the audio stream I use the MediaPlayer type which works fine.
However, in iOS, when I switch to another application or go back to home, in other words when the app go to background, the sound is cut whereas I would like to keep it playing.
I know how to do it in objective-C by activating the AVAudioSession and add the audio background mode the info.plist file.
But I really don't know how to do it in qml.
Can someone help ?
-
Hi and welcome to devnet,
The modification of Info.plist is still a valid thing to do. As for AVAudioSession, you will have to write some native code (e.g. a little wrapper class)
-
Thanks for the welcome.
How can I do a little wrapper class with native iOS code.
Have you got some exemples ?
-
You can take a look at the qtmacextras module, it uses Objective-C++
-
Did you also setup the AVAudioSession ?
-
@SGaist ,I meet the same situation, would you like help me?
The info.plist added audio background mode already.
The QML by QT 5.5 is:Window { visible: true Audio{ id: playMusic source: "test.wav" } MainForm { anchors.fill: parent mouseArea.onClicked: { playMusic.play(); } } }
Thank you!
-
It can be solved by this link: