iOS Is it possible to play audio through speakers and headphones at the same time as of iOS 11? - ios

Is it possible to play audio through speakers and headphones at the same time as of iOS 11? As of right now I am trying to find an app on the store that can do this, so far I have had no luck. I have found a few other threads, but they don't seem to be working for me or they say you can't. Here are a few of the links,
https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategoriesandModes/AudioSessionCategoriesandModes.html
https://stackoverflow.com/a/35009801
https://apple.stackexchange.com/questions/48534/is-it-possible-to-play-sound-through-both-the-headphone-jack-and-my-internal-spe
iOS: Is it possible to send audio out both headphones and speakers at the same time?
Has anyone tried to play sounds through the speakers and headphones at the same time? Android + iOS
What is really strange is that I cannot find any official documentation saying whether this is possible only that 'The built-in speaker may be used only if no other eligible output ports (USB, HDMI, LineOut) are connected.'
If you need code let me know, but really I am just wondering if it is possible and what is the best route for doing this? The key thing is that I want to do it simultaneously. Thanks.

So after some further review, I would like to save everyone the headaches that I had to go through. Is it possible? Probably, however Apple as of right now does not supply any way to do this. There seems to be no official documentation as to if it can be done (please update this answer if you find some).
The best evidence I have to support my answer would that Apple states 'Important: The built-in speaker may be used only if no other eligible output ports (USB, HDMI, LineOut) are connected.' Also in the solutions posted here, neither method works. I have tested both with iPhone 7 on iOS 11.
NOTE* in the second method I think that the writer was confusing 'channels' with 'routes'. He is changing and selecting the channels (this would be like left, right, or middle speaker for devices that support it), whereas I was looking to change the route (play in the speaker, play in the headphones, HDMI, USB, and ect...). So, in my opinion, NO YOU CANNOT play on the headphones and the speaker at simultaneously (different sounds or the same), unless you are Apple or I am wrong.

Related

AVAudioSession.RouteChangeReason not detecting connected bluetooth headset/earphones

I'm working on a voice calling app for iOS in Swift and I need to enable auto detection and auto connection of wireless(bluetooth) headsets/earpeaces.
I'm using AVAudioSession RouteChangeReason but it's not detecting when airpods or some other wireless headset is connected via bluetooth. After connecting the device I can even see it in Bluetooth settings that it's connected, but the device is not listed in MPVolumeView as you can see in the screenshoot.
I've been looking for an answer on how to work this out all over the internet and even though there are a lot of similar questions here on StackOverFlow none of them is specifically related to my case so please give me a light on how to solve this.
I just read the code and finally found what was wrong with it. The problem was that I was setting the category more than once so for some reason this was causing wireless headset/earpeace to not connect directly to the app.
.allowBluetoothA2DP is not valid for playAndRecord. You can't record over A2DP. Remove that one. Note that when you do this, if the user is listening to music, the quality is going to drop dramatically (it's possible that AirPods have a proprietary work around for that; I haven't played with them in this mode). In order to record over Bluetooth you have to use HFP, which provides basically "telephone" quality audio.

How to prevent Web-Audio on iOS from switching to mono when accessing the microphone?

we are developing a web app, that is supposed to play high quality stereo in combination with accessing the microphone input. We got this to work on all android and pc browsers, but the iphone is refusing to do this properly. We nailed the problem down to the access of the microphone input by "getUserMedia". Web audio plays stereo, until the microphone is enabled. Then, the quality drops and the output goes to mono. I have researched this problem in the internet, but only found posts that are several years old. My hope is, that things have changed in the meantime and solutions have been found. It seems like the phone is switching into some kind of "call mode". I would like to avoid this by either overriding corresponding settings or maybe by using a different way than using web-audio to play the stereo signal. I am open for any ideas. The worst case seems that we have to develop a dedicated native app for ios. If there is any workaround to make this happening in a web app, this would be highly appreciated. If desired, I can provide code snipplets, but I think, at this moment the problem should be clear.
BTW, in android we had similar problems and found that "Dolby Atmos" setting is causing strange mixing down to mono under certain circumstances. Switching it off fixed the android issues. Maybe this helps somebody else and maybe there are global settings on the iphone as well that could cure the problem..
Thank you very much in advance!
Cheers,
Chris
The worst case seems that we have to develop a dedicated native app for ios.
Unfortunately, this is the path forward most likely to yield success for you (if you haven't already figured this problem out, since I'm answering your question almost a year later).
The audio I/O device landscape is complicated, and there are several standards and factors that play into the quality of audio input and output an application yields. For instance:
Is the audio input device the same as the audio output device?
If yes, is the audio I/O device Bluetooth?
If yes, it's unlikely that the Bluetooth audio device supports stereo audio out and simultaneous audio input. Few I/O devices support that, and few host devices support that.
If yes, which Bluetooth version does the I/O device support?
Which operating system is the host device running?
Does the host device's operating system support the selection of audio input and output devices separately?
How much access to the host operating system does your application have?
For example, if your application is running in a browser, your application will have significantly less control over the host device's operating system's audio subsystem.
I have been trying to work around this problem recently, too. Another developer did a detailed investigation of this using a spectrum analyser and scope, and didn't have any luck either: testing iOS audio play/record with scope.
I think building a native app will end up being inevitable, and would also fix the myriad other problems with Safari web audio. Either that or wait until Apple fixes the bugs or implements AudioWorklets.

How do I detect the presence of an Airplay AUDIO-ONLY device on the network?

I'm unable to find code online (yes, googled aplenty) that details how to discover devices that support the audio only version of Airplay. There doesn't seem to be anything on Apple's developer site either - I spent an hour scouring Google and searching through Apple's documentation. I'm clearly missing something here.
I did find this: "Using External Display", but that only describes how to discover and connect to devices that support Airplay mirroring. They essentially are recognized as another display and you just begin drawing to it.
I also found this: "Providing an AirPlay Picker", but it only describes how to create an AirPlay picker when a device is available, not how to know when a device is available in general (I'd like to do other logic in my app based on audio device availability).
My end goal here is to prevent the user from trying to use an audio-only Airplay device for my app, which requires video support. I planned to show a warning message when 1+ audio-only devices and 0 video-capable devices were detected.
I'm specifically interested in the code for audio-only devices, like the Apple TV 1st gen, AirPorts, and Airplay-enabled speakers. This is particularly important considering that Apple TVs don't look visibly different across generations, and a user might think they can use the app over Airplay when in fact they cannot.
Can someone point me towards the right resource?

Robotic voice through iphone 6s microphone

I am developing an app to do live video streaming and when I recently upgraded to an iPhone 6s, all noise going through the microphone sounds robotic (or like a cricket). I can reproduce this issue only using the skype app, but no other app have this similar output. The skype support forums say that this is a problem they're seeing on iPhone 6s [1] but don't give any details as to what's causing it.
The interesting thing is it doesn't have issues when I use the microphone jack via my headphones, only when the built in microphone is used. Is there a permission or a change I need to make to my app to fix this?
[1] - http://community.skype.com/t5/iOS-iPhone-and-iPad/iPhone-6s-Distorted-sound/td-p/4138308
The 6S is apparently locked to a 48000 sample rate when using the built in microphone. Maybe you tried to set the format to 44100. I think the only way to deal with this is to query an active AVAudioSession for it's sampleRate property and set your format's sample rate to that.
This is a know issue consumer users are seeing. It might be the iOS 9 update was not working properly.
Here's a source (might not be that trusted for some but it's a start)
http://9to5mac.com/2015/09/30/iphone-6s-touch-id-3d-touch-speaker-power-issues/
You can try a different app from the App Store, or call someone on speaker, to check if the issues is reproducible.

Disable audio route changes in an iOS App?

I have an audio app that plays for many hours throughout the night. Sometimes the iPhone changes routes and says the speaker is no longer available and stops playing audio. I'm not sure why but my theory is that it tried to connect to a Bluetooth device. I get the following in the log:
AVAudioSessionRouteChangeReasonCategoryChange
AVAudioSessionRouteChangeReasonOldDeviceUnavailable
And since the old device is no longer available it stops the audio. I'm playing audio through the iPhone speaker, so I'm not sure why the speaker would no longer be be available.
My question is what can I do to prevent this from happening in code? I advise people to turn on Airplane mode or disable Bluetooth which always fixes the issue. I'm wondering if something could be done in code to help solve this problem.

Resources