AudioSession input from bluetooth output to line out or speaker
as of iOS 5 this behaviour is not possible, quoting apple technical support
Bluetooth devices are not "Jacked In" devices and therefore any other
audio routing must be user picked and cannot be changed in code. To do
this, you can use the functionality of the MPVolumeView which will
have an extra routing widget viewable allowing the user to specify the
routing of the output.There's a older thread on the Core Audio mailing list regarding this
functionality but behavior hasn't changed:http://lists.apple.com/archives/coreaudio-api/2009/Oct/msg00030.html
MPVolumeView reference:
http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPVolumeView_Class/Reference/Reference.html
However the MPVolumeView does not allow you to route the input and output independently.
Cordova detect switch audio mode - built-in speaker to bluetooth speaker
This Cordova plugin might be what you are looking for? https://github.com/saghul/cordova-plugin-audioroute
It's supposed to hook onto AVAudioSessionRouteChangeNotification and detect when the system audio route changes. According to the README You should be able to add the plugin and then place an event listener inside your project like so:
document.addEventListener('audioroute-changed',
function(event) {
console.log('Audio route changed: ' + event.reason);
// code for stuff you want to do
}
);
AVAudioSessionRouteChangeNotification is also mentioned here in a similar question:
Detect (listen to) audio route change in iOS 7
AVAudioSessionRouteChangeNotification documentation:
https://developer.apple.com/documentation/avfoundation/avaudiosessionroutechangenotification
How to use internal mic for input and bluetooth for output
Get rid of allowBluetooth
and use allowBluetoothA2DP
. You also don't want defaultToSpeaker
here.
"Allow Bluetooth" actually means "prefer HFP" which is why the audio is so bad. HFP is a low-bandwidth bidirectional protocol used generally for phone calls. The enum name is very confusing IMO. People get confused about it all the time.
A2DP is a high-bandwidth unidirectional protocol (it doesn't support a microphone). When you request that, the headset's microphone will be disabled, and you'll get the iPhone's microphone by default (provided there isn't some other wired microphone available, but that's very unlikely).
Related Topics
Objective C- Trouble Updating UI on Main Thread
A Lighter Way of Discovering Text Writing Direction
How to Unit Test an App Extension on Xcode 6
How to Get MAC Address from Cbperipheral and Cbcenter
Which Phassetcollection to Use for Saving an Image
How to Register Undomanager in Swift
Xcode 5 - "No Application Records Were Found" When Trying to Validate an Archive
Game Engine Collison Bitmask... Why 0X01 etc
How to Detect the Scroll Direction from the Uicollectionview
Swift Unsafemutablepointer<Unmanaged<Cfstring>> Allocation and Print
Change Pin Image on Mkmapview in Swift
Using Two Versions of a Cocoapod Dependency
Xcode5 Simulator: Unknown Option Character 'X' In: -Xlinker
iOS 11 Search Bar Jumping to Top of Screen
iOS 8.3 and Later, Facebook Share Text Not Inserted
iOS Xcode Swift Autocomplete Broken
Assertion Failure in Void _Uiperformresizeoftextviewfortextcontainer