开发者

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

开发者 https://www.devze.com 2023-01-26 06:22 出处:网络
Is there any reason why this wouldn\'t w开发者_开发百科ork? I\'m testing for sound in the microphone and playing a looping sound effect as I\'m registering sound.

Is there any reason why this wouldn't w开发者_开发百科ork?

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消