I'm trying to create an iOS app which can record audio and video while simultaneously outputting audio to the speakers.
To do the recording and preview, I'm using AVCaptureSession
, an AVCaptureConnection
each for both video and audio, and an AVAssetWriterInput
each for both video and audio. I basically achieved this by following the RosyWriter example code.
Prior to setting up recording in this fashion, I was using AVAudioPlayer
to play audio.
Now, if I am in the middle of capturing (not even recording, just capturing for preview), and attempt to use AVAudioPlayer
, my captureOutput
callbacks on my AVCaptureAudioDataOutputSampleBufferDelegate
class stop getting called.
Is there a workaround for this?
Is there another, lower level service I should use to be playing audio that won't stop my capture?
mc.
You first set the
AVAudioSession
and its category. For example inviewDidLoad
method,Therefore you can play BGM
and record the movie