I'm currently building a metronome app with SwiftUI to play audio at a desired BPM.
I’ve active background mode and if the screen is on, the sound will be constant even if I leave the app.
However, when I turn off the screen, the sound stops and starts to delay or slow down.
1.AVAudioSession's rate value is not applied.
2.Timer.scheduledTimer(withTimeInterval: interval, repeats: true) { _ in
audioPlayer?.play()
}
I don't know if the interval value (60.0 / tempo) of this timer doesn't apply.
If anyone has encountered a case like this and solved it, please give me some advice.