Sonu
Sonu

Reputation: 957

Audio playing and recording is not working with iOS 10

I'm unable to play any audio file in iOS 10, Even Default keyboard click sound also not playing.

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

In Video recording, (I'm using AVCaptureConnection), Sometimes it's record sound and sometime not.

I'm using LLSimpleCamera for record video.

Can anyone suggest me?

Regards

Upvotes: 4

Views: 532

Answers (1)

Bws Sluk
Bws Sluk

Reputation: 518

I had the same problem with LLSimpleCamera, with this code

@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*/ }

When I setup category much more earlier before calling startRecordingWithOutputUrl: the problem doesn't appear. So, put some code after setCategory: and check. I know that it is not a "true" solution, but it works for me after 6 hours of hard working.

Cannot reproduce the issue with this code:

[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*/ }

P.S. Reproduced only on iPhone 7

Upvotes: 3

Related Questions