此代码片段使其他音频(又名 iPod)停止:
func setSessionPlayer() {
var audioSessionError: NSError?
let audioSession = AVAudioSession.sharedInstance()
audioSession.setActive(true, error: nil)
if audioSession.setCategory(AVAudioSessionCategoryPlayback, withOptions:AVAudioSessionCategoryOptions.MixWithOthers,
error: &audioSessionError) {
println("Successfully set the audio session")
} else {
println("Could not set the audio session")
}
}
我缺少什么?
我认为这是因为你正在设置audioSession.active
在配置为之前MixWithOthers
. Move audioSession.setActive
在 if 块下面,如下所示:
if audioSession.setCategory(AVAudioSessionCategoryPlayback, withOptions:AVAudioSessionCategoryOptions.MixWithOthers,
error: &audioSessionError) {
println("Successfully set the audio session")
} else {
println("Could not set the audio session")
}
audioSession.setActive(true, error: nil)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)