[英]iOS record video and play MP3 at the same time
我需要從iPhone攝像頭錄制視頻,同時播放MP3文件。
我開始使用AVCam示例代碼,我相信你們都有。 它非常適合錄制視頻。
但是,我添加了以下代碼來播放MP3。 這個MP3播放代碼在我的不同應用程序中工作,但是當我將其插入到此示例代碼中時,MP3不僅不會播放,AVCamCaptureManager的recordingDidFinishToOutputFileURL永遠不會被調用,因此視頻永遠不會被保存。
這就像音頻播放代碼與視頻捕獲代碼沖突。 有任何想法嗎?
這是我放入AVCam的音頻播放代碼:
AVAudioPlayer *audioPlayer = nil;
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/soundeffect.mp3", [[NSBundle mainBundle] resourcePath]]];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
[audioPlayer setVolume:1.0];
[audioPlayer prepareToPlay];
[m_audioPlayer play];
這里的代碼非常簡單。 不知道為什么這個音頻播放代碼會導致recordingDidFinishToOutputFileURL永遠不會被調用...
謝謝你的任何想法。
我想通了:我只需要刪除AVCam中分配了AVCaptureDeviceInput - audioInput的一些代碼。 這是不必要的,並與我的音頻播放代碼沖突。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.