//录音之前,先调用下面的语句,询问用户是否可以访问他的 隐私设备麦克风

    [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted)

     {}];



 if ([[[AVAudioSession sharedInstancecategoryisEqualToString:AVAudioSessionCategoryPlayback])

    {

        //切换为听筒播放

        [[AVAudioSession sharedInstancesetCategory:AVAudioSessionCategoryPlayAndRecord error:nil];

        [self showTipInfo:@"切换为听筒模式"];

        

    }

    else

    {

        //切换为扬声器播放

        [[AVAudioSession sharedInstancesetCategory:AVAudioSessionCategoryPlayback error:nil];

        [self showTipInfo:@"切换为扬声器模式"];

    }