【发布时间】:2017-08-04 12:27:58
【问题描述】:
我正在开发音乐应用程序。
这是我要解决的情况: 我打开 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()
}
【问题讨论】:
标签: ios swift uiviewcontroller avaudioplayer audio-player