Access iOS microphone without muting audio? - ios

If a user runs Spotify or another audio app in the background while playing my game, the audio is fine until I access the microphone, at which point audio gets muted.
The release notes for AIR 15.0.0.27 state that one of the fixed issues is:
[iOS8] Requesting microphone access terminates all further audio.
However, I'm experiencing this with AIR 15.0.0.356.
Can this be avoided? And if not, what do I do to restore audio again after the user is done using the microphone?

Related

Audio stopped when starting a song while broadcasting on Ant Media Server using iOS SDK

While making a broadcast with iOS SDK, everything is working fine and viewers can listen to what broadcaster is saying.
But, after sometime when I am starting a mp3 song from broadcaster mobile library, viewer should be able to listen what broadcaster is saying as well as song which is being played, but no audio is getting send to viewer once I start the song.
Ideally, broadcaster’s audio should mix with song and viewer should be able to listen to both.
I'm using below codes to play the audio song.
Please let me know what should I do as I want to play audio file in background while I am doing streaming.
Yes, it's an expected behavior. I mean when playing the mp3 file, you're setting "shared audio session instance" in iOS mode to playback and it closes the microphone.
try
AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category(rawValue: AVAudioSession.Category.playback.rawValue))
​
After that you need to change it to record mode again to let it capture the audio from microphone.
The category should be set to playandrecord and mode can be set to voicechat.

Tokbox iOS: Video call disconnects when phone lock

I am using tokbox for video calling in my iOS application. I am getting the issue when while video calling, when I lock the app, the stream gets disconnected and the call ends.
This documentation outlines running TokBox in the background, i.e. when the phone is locked. The following is an excerpt from the limitations of running TokBox in the background:
Apps cannot do the following while in the background state:
Use the camera as a video source for a publisher.
The documentation goes on to explain that you can keep an audio-only session active when running in the background, but not a video session.

How sonos IOS app works streaming in background?

How sonos IOS app works streaming in background?
They are using Airplay or another technique?
Sonos is not sending the audio from the device to the speaker - the speaker makes the request directly. This passes the "beer run test" which allows you to leave with you phone with interrupting the music that others are listening to.

How do I start a Record iOS audio session in the background?

I'm trying to start a kAudioSessionCategory_RecordAudio after my app is woken up in the background but not forefront (like during a significant location change, I have seen other apps in the store do this so I know it is possible). However whenever I try to start the audio session like so
CheckError(AudioQueueStart(queue,
NULL),
"AudioQueueStart failed");
I get this error:
Error: AudioQueueStart failed (-12985)
So I read up on that but only suggestion is setting the audio session to active AudioSessionSetActive(YES) but that also fails with a '!cat' error. Apparently you can try to toggle the active state of the audio session but that hasn't worked for me.
I have the audio background mode plist flag set and starting an audio session while my app is forefront then switching to another app works (shows the red bar showing that it is recording). Its just starting the audio session while the app isn't forefront is the issue.
Does anyone have a sample project I could look at demonstrating starting a recording audio session in the background?
Note: I am looking for a solution that uses audio queues as I need the audio in buffers, not a file.
It turns out that Apple's SpeakHere sample code with some modifications will start recording audio in the background if you just add the audio multitasking flag to info.plist and add the appropriate significant location change APIs. You might look https://github.com/benvium/SpeakHere for an updated version of SpeakHere since Apple hasn't updated it in awhile.
Currently, iOS does not allow starting an audio session or audio recording in the background. An app has to start audio in the foreground, but can just throw away any recorded audio data until needed, which could be in the background when using the appropriate background modes and audio session.

play sound while recording fails

I have a 3rd party SDK that handles an audio recording. It has a callback when the recording starts. In the callback I'm trying to play a sound to indicate to the user that the device is now listening (like Siri, or any other speech recognition tends to do), but when I try I get the following error:
AURemoteIO::ChangeHardwareFormats: error -10875
I have tried playing the sound using AudioServicesPlaySystemSound as well as an AVAudioPlayer both with the same result. The sound plays fine at other times, and per the error my assumption is there's an incompatibility between the playback and recording on the hardware level. Can anyone clarify this error, or give me a hint as to a possible workaround?
Make sure that the Audio Session is initialised and configured for Play_and_Record before you start the RemoteIO Audio Unit recording.
You shouldn't and likely can't start playing a sound in a RemoteIO recording callback. Only set a boolean flag in the callback to indicate that a sound should be played. Play your sound from the main UI run loop.
My problem is related specifically to the external SDK and how they handle the audio interface. They override everything when you ask the SDK to start recording, if you take control back you break the recording session. So within the context of that SDK there's no way to work around it unless they fix the SDK.

Resources