【问题标题】:AVCaptureSession, AVCaptureAudioDataOutput and background MusicAVCaptureSession、AVCaptureAudioDataOutput 和背景音乐
【发布时间】:2015-09-09 13:20:52
【问题描述】:

我用AVFoundationAVCaptureVideoDataOutputAVCaptureAudioDataOutput 录制音频/视频。但是当我将我的AVCaptureAudioDataOutput 添加到我的AVCaptureSession 时,AVFoundation 停止背景音乐(在我的情况下来自 iPod 应用程序)。

所以我正在寻找一种解决方案,让我的音乐在我的录音过程中播放?

谢谢,

阿拉克

ps:我的目标是 iOS8,我使用的是 Swift 2.0

【问题讨论】:

    标签: ios swift avfoundation avcapturesession


    【解决方案1】:
        do {
          try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: [AVAudioSessionCategoryOptions.MixWithOthers, AVAudioSessionCategoryOptions.DefaultToSpeaker])
          try AVAudioSession.sharedInstance().setActive(true)
    
        } catch {
          print("error")
        }
    
        captureSession = AVCaptureSession()
    

    【讨论】:

    • 我知道这个答案真的很老了,但这会使音乐在开始/停止捕获会话时结结巴巴。有没有办法让AVCaptureAudioDataOutput 在开始视频录制前不久即时激活音频会话? Snapchat 应用程序设法做到了这一点,在打开/关闭相机时不会导致音乐中断,但只有在开始录制时才会中断。
    • 我在这里创建了一个新的 SO 问题:stackoverflow.com/q/67807394/5281431
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-19
    • 1970-01-01
    • 2011-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多