AVAudioPlayer is really quiet on the iPhone, but quite loud on iPod touch

I have a sound that plays in a loop when noise is recorded using AVAudioRecorder.

Here is my code:

NSString *pathToFile = [[NSBundle mainBundle] pathForResource:@"foghornRepeat2" ofType:@"aif"];
        foghornRepeat =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:pathToFile] error:nil];
        //foghornRepeat.delegate = self;
        [foghornRepeat prepareToPlay];

        foghornRepeat.numberOfLoops = -1;
        [foghornRepeat setVolume:1];

Then playback and stop occurs when recording sound through a microphone. Any idea why it would be really quiet on the iphone? This is good on my iPod touch.

Is there any other way I can do this?

Thanks tom

+3
source share
1 answer

, , , , iphone . , :

   UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
 AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
+4

Source: https://habr.com/ru/post/1776413/


All Articles