iOS Question Background sound stopping when app is in background


Well-Known Member
Licensed User
Longtime User
Following this example I'm trying to keep playing a sound when the app is sent in background.
Since I only need a sound, and the onscreen page is not always the same, I'm using MediaPlayer instead of VideoPlayer.

So I added
#PlistExtra: <key>UIBackgroundModes</key><array><string>audio</string></array>

    Public BackgroundSound As MediaPlayer
    BackgroundSound.Initialize(File.DirAssets, "backgroundsound.wav", "BackgroundSound")
    BackgroundSound.Looping = True

The sound starts playing with the app in foreground, but a soon as I press the home button, the sound stops.
Bringing the app back to foreground, causes the sound to resume playing.

What's the correct way to keep playing also when the home screen is displayed?