使用

iPhone的SDK 3.1.2。

反正知道,如果蓝牙耳机被连接到所述设备的?不需要,除非它的连接与否任何信息。这是不同的从知道如果一个在被插入或没有哪一个可以经由音频会话的属性监听器做的。

由于

没有正确的解决方案

其他提示

调用此方法找出蓝牙耳机连接与否。

首先导入该框架#import <AVFoundation/AVFoundation.h>

- (BOOL) isBluetoothHeadsetConnected
    {
        AVAudioSession *session = [AVAudioSession sharedInstance];
        AVAudioSessionRouteDescription *routeDescription = [session currentRoute];

        NSLog(@"Current Routes : %@", routeDescription);

        if (routeDescription)
        {
            NSArray *outputs = [routeDescription outputs];

            if (outputs && [outputs count] > 0)
            {
                AVAudioSessionPortDescription *portDescription = [outputs objectAtIndex:0];
                NSString *portType = [portDescription portType];

                NSLog(@"dataSourceName : %@", portType);

                if (portType && [portType isEqualToString:@"BluetoothA2DPOutput"])
                {
                    return YES;
                }
            }
        }

        return NO;
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top