I'm playing an Audio in my app.
I can play the audio in the background mode in the simulator but when I test the app in a real device, the audio Stops as soon as the App goes in the background.
-
- Xcode 14
-
- iOS 16
-
- Device: iPhone 11
I have this in the background mode:
This is the code into .onAppear() view:
let path = Bundle.main.path(forResource: "timer.mp3", ofType:nil)!
let url = URL(fileURLWithPath: path)
timerEffect = try AVAudioPlayer(contentsOf: url) //@State var timerEffect: AVAudioPlayer?
timerEffect?.numberOfLoops = -1
timerEffect?.play()
Anyone can help me? Thanks!