斯威夫特:如何设置了优雅与他人(又名POD)混合音频会议 [英] Swift: how to set up an audio session that gracefully mixes with others (aka Pod)

查看:181
本文介绍了斯威夫特:如何设置了优雅与他人(又名POD)混合音频会议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这code片段时,其他音频(又名iPod的)停止:

This code snippet makes the other audio (aka iPod) to stop:

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 。移动 audioSession.setActive 下面的if块,像这样:

I think it's because you're setting the audioSession.active before it's configured to MixWithOthers. Move audioSession.setActive below the if block like so:

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)

这篇关于斯威夫特:如何设置了优雅与他人(又名POD)混合音频会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆