Thomas Clayson
Thomas Clayson

Reputation: 29925

Using AVAudioRecorder and AVAudioPlayer at the same time (or alternative ways of listening for sound and playing sound)

Is there any reason why this wouldn't work?

I'm testing for sound in the microphone and playing a looping sound effect as I'm registering sound.

On the iPod touch this seems to work fine - on the iPhone though the sound effect either doesn't play at all, or is very quiet.

Any ideas? Or any alternative?

Thanks

Upvotes: 1

Views: 1190

Answers (1)

Thomas Clayson
Thomas Clayson

Reputation: 29925

for some reason had to put this code before I played the sound:

UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
        AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);    
        UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
        AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);

to stop it playing through the earpiece.

Upvotes: 2

Related Questions