microphone recording in background

Hello,


What is the right way to implement an application that records audio chunks from microphone, but not continuously ? (for example : record 10s once every 5 minutes).

If we use the audio background mode, the app might get suspended at any time as soon as the microphone recording stops...


Thank you in advance for your suggestions.

regards


(message reduced to the very minimum to avoid the "message contains invalid characters" error ...)

Replies

You would need to keep listening and then save off the 10s chunks of audio as needed.

We would like to reduce battery usage. Recording continuously will quickly drain the battery, and we only need a few seconds every few minutes.

Any way to do that without getting suspended ?

Or, would it be possible to reactivate the app at regular time intervals ? (we have taken a look at the "fetch" background mode but the time interval is decided by the system)

We would like to reduce battery usage. Recording continuously will quickly drain the battery, and we only need a few seconds every few minutes.

There is no good way to do this. The audio background support only allows you to continue using an audio session that you created in the foreground; it does not allow you to start a session from the background. To reduce battery life you’d have to stop the session so that you can go idle (or, better yet, suspend) but then you can’t start it again.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
  • Given the following situation: A user initiates a WebRTC audio call, but then puts the app in the background, for whatever reason, I cant get my app to continue to use the microphone - it gets disabled. Returning to the app, restores the mic. I have noticed that Safari have exactly the behaviour I'm looking for - when sent to the background, there appears a microphone icon with an orange background. This is great as it informs the user that they have an active microphone, and keeps the mic un-muted. How do I replicate this behaviour with WKWebView?

Add a Comment