I want screen always light when playing audio, and turn dark when complete the audio and I do not tap the screen after two minutes(i have set auto-lock in setting), implement code as the following.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIApplication.shared.isIdleTimerDisabled = true
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
UIApplication.shared.isIdleTimerDisabled = false
}
But the result is screen turn dark immediately when finish one audio which is more than two minutes.
How to fix it ,or is this ios bug?
Thanks