We have an app playing music, if not set play background
mode, when screen turn off, music off too. Let add these lines in to
viewDidLoad.
do {
tryAVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
//print("AVAudioSession Category Playback OK")
do {
tryAVAudioSession.sharedInstance().setActive(true)
// print("AVAudioSession is Active")
} catchlet error asNSError {
print(error.localizedDescription)
}
} catchlet error asNSError {
print(error.localizedDescription)
}
Click to top folder, choose Capabilities, find Backgroud
modes, click to small triangle to show more, click to turn On and check to
Audio, Airplay and Picture in Picture.
No comments:
Post a Comment