2016-11-11 100 views
2

我無法播放iOS 10中的任何音頻文件,即使默認的鍵盤聲音也不能播放。音頻播放和錄製不適用於iOS 10

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError]; 

在視頻錄製中,(我正在使用AVCaptureConnection),有時它是錄製聲音,有時不是。

我正在使用LLSimpleCamera錄製視頻。

任何人都可以建議我嗎?

問候

+0

@KiritModi檢查代碼字符串,它的目標是c – Sonu

回答

1

我有同樣的問題LLSimpleCamera,與此代碼

@property(readonly, strong, nonatomic) LLSimpleCamera *camera; 
//... 
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; 
[[self camera] startRecordingWithOutputUrl:path didRecord:^(LLSimpleCamera *camera, NSURL *outputFileUrl, NSError *error) 
{ /*do something*/ } 

當我設置類別調用startRecordingWithOutputUrl: 以前更多更早的問題不會出現。所以,在setCategory:後面加一些代碼並檢查。 我知道這不是一個「真正的」解決方案,但它在6個小時的努力工作後對我有用。

[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; 

/* do some UI-related stuff, hide buttons, show bars, some animation */ 

[[self camera] startRecordingWithOutputUrl:path didRecord:^(LLSimpleCamera *camera, NSURL *outputFileUrl, NSError *error) 
{ /*do something*/ } 

附註:

無法使用此代碼重現問題轉載僅限iPhone 7