/**
检测是否连接蓝牙
@return 是否为蓝牙音频输出
*/
-(BOOL)isBleToothOutput
{
AVAudioSessionRouteDescription *currentRount = [AVAudioSession sharedInstance].currentRoute;
AVAudioSessionPortDescription *outputPortDesc = currentRount.outputs[0];
if([outputPortDesc.portType isEqualToString:@"BluetoothA2DPOutput"]){
NSLog(@"当前输出的线路是蓝牙输出,并且已连接");
return YES;
}else{
NSLog(@"当前是spearKer输出");
return NO;
}
}
该博客介绍了一种方法来检查iOS系统是否通过蓝牙设备进行音频输出。通过AVAudioSession的currentRoute获取当前输出端口类型,如果为'BluetoothA2DPOutput'则表明已连接蓝牙设备。

3853

被折叠的 条评论
为什么被折叠?



