1
我要檢測的下面的事件時,有從iOS裝置的任何呼入/呼出:如何檢查在iOS通話期間音頻是否路由至藍牙免提?
- 無論任何藍牙耳機裝置被連接。
- 音頻是否路由到任何藍牙耳機設備。
我是新來的藍牙配件編程,有沒有辦法做到這一點?
我要檢測的下面的事件時,有從iOS裝置的任何呼入/呼出:如何檢查在iOS通話期間音頻是否路由至藍牙免提?
我是新來的藍牙配件編程,有沒有辦法做到這一點?
我解決了它下面給出:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err;
// close down our current session...
[audioSession setActive:NO error:nil];
AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, &AudioSessionManager_audioRouteChangedListener, self);
void AudioSessionManager_audioRouteChangedListener (void *inClientData, AudioSessionPropertyID inID, UInt32 inDataSize, const void *inData)
{
NSLog(@"AudioSessionManager_audioRouteChangedListener");
MyAppDelegate *instance = (MyAppDelegate *)inClientData;
CFDictionaryRef routeChangeDictionary = inData;
// extract the route change reason...
CFNumberRef routeChangeReasonRef = CFDictionaryGetValue (routeChangeDictionary, CFSTR(kAudioSession_AudioRouteChangeKey_Reason));
SInt32 routeChangeReason = kAudioSessionRouteChangeReason_Unknown;
if (routeChangeReasonRef)
CFNumberGetValue (routeChangeReasonRef, kCFNumberSInt32Type, &routeChangeReason);
// extract the old route..
CFStringRef newRoute;
if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 5.0)
{
newRoute = CFDictionaryGetValue(routeChangeDictionary, @"OutputDeviceDidChange_NewRoute");
}
else
{
newRoute = CFDictionaryGetValue(routeChangeDictionary, @"OutputDeviceDidChange_NewRoute");
}
CFStringRef oldRoute;
oldRoute = CFDictionaryGetValue(routeChangeDictionary, @"OutputDeviceDidChange_OldRoute");
NSLog(@"newRouteString:%@ oldRoute:%@",newRoute,oldRoute);
[instance onAudioRouteChangedWithReason:routeChangeReason newRoute:(NSString *)newRoute oldRoute:(NSString *)oldRoute];
}
在下面的代碼中,檢查「micConnected」的值以查看是否連接了耳機。
AudioSessionInitialize(NULL, NULL, NULL, NULL);
UInt32 propertySize, micConnected;
AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &propertySize, &micConnected);
我解決它使用下面的代碼: –