AVCaptureSession,AVCaptureAudioData输出和背景音乐 [英] AVCaptureSession, AVCaptureAudioDataOutput and background Music

查看:100
本文介绍了AVCaptureSession,AVCaptureAudioData输出和背景音乐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用AVCaptureVideoDataOutputAVCaptureAudioDataOutputAVFoundation录制音频/视频.但是,当我将AVCaptureAudioDataOutput添加到AVCaptureSession时,AVFoundation停止背景音乐(以iPod app为例).

I record audio/video with AVFoundation using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput. But when I add my AVCaptureAudioDataOutput to my AVCaptureSession, AVFoundation stop background music (in my case from iPod app).

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

So I'm looking for a solution to let my music playing during my record ?

谢谢

阿拉

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

ps: I'm targeting iOS8 and I use Swift 2.0

推荐答案

    do {
      try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: [AVAudioSessionCategoryOptions.MixWithOthers, AVAudioSessionCategoryOptions.DefaultToSpeaker])
      try AVAudioSession.sharedInstance().setActive(true)

    } catch {
      print("error")
    }

    captureSession = AVCaptureSession()

这篇关于AVCaptureSession,AVCaptureAudioData输出和背景音乐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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