iOS Question Play audio from background

IamTrying

Active Member
Licensed User
When the app is in backgrond, how do i still play the ring? it only playing when the app is active in foreground.

B4X:
#PlistExtra: <key>UIBackgroundModes</key><array><string>audio</string></array>

Sub CreatePlayer(url As String) As NativeObject
    Dim u As NativeObject
    u = u.Initialize("NSURL").RunMethod("URLWithString:", Array(url))
    Dim player As NativeObject
    player = player.Initialize("AVPlayer").RunMethod("alloc", Null) _
     .RunMethod("initWithURL:", Array(u))
    Return player   
End Sub

Sub playAudio()
    player1 = CreatePlayer("ring.wav")
    player1.RunMethod("play", Null)
End Sub


Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav

    playAudio()

End Sub

Private Sub Application_Background
   
  playAudio()

End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…