Reputation: 2658
In my iOS game I notice the speaker volume automatically decreases while I'm recording with the mic. I'm using the following C# code in Unity 3D to record a short piece of input from the mic and then analyze audioSrc to see if there was any blowing. I repeat this for a short while.
audioSrc.clip = Microphone.Start (null, false, 5, FREQUENCY);
The whole time I'm also playing some background music, and it is during the execution of the above command that the music volume drops for a bit and then comes back right after recording stops.
I'm not sure if this is specific to Unity 3D on iOS only, or whether this is behaviour common to iOS applications. I haven't noticed the same behaviour on Android. Does anybody know of a way I can prevent this on iOS? If necessary I can execute Objective-C code from Unity to call the iOS APIs.
Upvotes: 2
Views: 3073
Reputation: 31
It's not so much that the volume is decreased, rather it is that iOS has switched the output to earphone, away from speakers. Unity has now included a "Player Setting" for iOS called "Force iOS Speakers when Recording" turn this on.
Upvotes: 3
Reputation: 3393
I'm pretty sure that decreasing the audio while recording is default iOS behaviour.
Upvotes: 2