0
我正在製作音樂應用程序。iOS支持從其他音樂應用程序返回後播放音頻
這裏是我想修復的情況: 我打開AppleMusic應用程序>玩東西>打開我的應用程序>點擊播放>音樂不播放。爲什麼以及如何解決它?
我用,但仍然無法正常工作
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
try AVAudioSession.sharedInstance().setActive(true)
} catch let error as NSError {
print(error.localizedDescription)
}
UIApplication.shared.beginReceivingRemoteControlEvents()
}