Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to play and record audio at the same time not using AVAudioSessionCategoryPlayAndRecord

The idea comes from this app (Keezy) : http://keezy.net/

Basically, I'm trying to allow a user to listen to audio and record at the same time. I am aware of the category AVAudioSessionCategoryPlayAndRecord, BUT this category forces the volume of the AVAudioPlayer to be reduced heavily.

Trying to record audio while at the AVAudioSessionCategoryPlayback does not work (doesn't record anything) and the other categories don't seem relevant. I'm wondering if there is way to achieve what is done in Keezy - audio playback at high volume while allowing a user to record audio at the same time.

(Couldn't find any examples/topics about that solve this without the playback category.)

like image 536
royherma Avatar asked Nov 22 '13 04:11

royherma


People also ask

Can you record audio and play music at the same time?

Visit Google Play Store and download the Together app. Launch your music app and play the desired track. Launch the Together app and tap the video camera icon at the bottom to start recording. The music should continue playing.

Can I record audio playing on my phone?

Many newer phones have started to have built-in screen record functions or apps that allow you to record internal audio. Android 10 is a version of the Android operating system that came out in 2019. It allows for internal audio recording, so you don't have to get an app to screen-record.


1 Answers

Although the solution still involved the PlayAndRecord category, what needed to be added was the "AVAudioSessionCategoryOptionDefaultToSpeaker" to the category options - that allowed the audio to be played at normal volume and record as well.

Example:

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
like image 79
royherma Avatar answered Oct 29 '22 00:10

royherma