iPhone – Recording block audio on iOS background

I’m trying to figure out a way to record audio in the background of an iOS application and stream it to the server.

When the application is in When in the foreground, I almost got this feature. I use AVAudioRecorder to record X seconds of input. Once I get the completed callback, I record for X seconds. Each recording session is stored in a different file, and I send these files asynchronously To the server.

However, when my app enters background mode, this does not seem to work.

When entering the background, the current recording session continues to record until X seconds start , But my application is suspended before I can start another recording session.

Any ideas?

This is my callback code:

- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)aRecorder successfully:(BOOL)flag {
NSLog(@"hello");

[self initRecorder];

[recorder recordForDuration:5];

}

< /div>

You cannot restart recording in the background.

So please use audio queue or Audio unit RemoteIO API, which will provide you with smaller “chunks” (callback buffer blocks) audio without stopping the recording.

If your network protocol requires it, connect the small audio callback block into Larger file blocks.

I am trying to figure out a way to record audio in the background of an iOS app and stream it to the server.

< /p>

When the application is in the foreground, I almost get this feature. I use AVAudioRecorder to record X seconds of input. Once I get the completion callback, I record X seconds again. Each recording session is stored to a different In the files, I send these files to the server asynchronously.

However, when my app enters background mode, this does not seem to work.

When entering the background, The current recording session continues to record until X seconds start, but my application is suspended before another recording session can be started.

Any ideas?

This is my callback code:

- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)aRecorder successfully:(BOOL)flag {
NSLog(@"hello");

[self initRecorder];

[recorder recordForDuration:5];

}

< /p>

You cannot restart recording in the background.

So, please use audio queue or audio unit RemoteIO API, which will provide you with smaller “Block” (callback buffer block) audio without stopping the recording.

If your network protocol requires it, connect the small audio callback block into a larger file block.

p>

Leave a Comment

Your email address will not be published.