Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 连接耳机时静音_Ios_Xamarin_Audio_Avaudiosession_Red5pro - Fatal编程技术网

Ios 连接耳机时静音

Ios 连接耳机时静音,ios,xamarin,audio,avaudiosession,red5pro,Ios,Xamarin,Audio,Avaudiosession,Red5pro,我使用Xamarin的Red5Pro连接到音频广播。声音传到扬声器。一边听,一边连接蓝牙耳机。声音切换到他们,但很安静 对于声音,我将AVAudioSession与以下设置一起使用: 类别-播放和录制 类别选项-默认为Speaker | AllowBluetooth | AllowBluetooth A2DP 并激活会话 设置音频会话代码: private static void SetupAVSession() { AVAudioSession.SharedIn

我使用Xamarin的Red5Pro连接到音频广播。声音传到扬声器。一边听,一边连接蓝牙耳机。声音切换到他们,但很安静

对于声音,我将AVAudioSession与以下设置一起使用:

类别-播放和录制

类别选项-默认为Speaker | AllowBluetooth | AllowBluetooth A2DP

并激活会话

设置音频会话代码:

    private static void SetupAVSession()
    {
        AVAudioSession.SharedInstance().SetActive(false);
        AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.PlayAndRecord,
        AVAudioSessionCategoryOptions.DefaultToSpeaker | AVAudioSessionCategoryOptions.AllowBluetooth | AVAudioSessionCategoryOptions.AllowBluetoothA2DP);
        AVAudioSession.SharedInstance().SetActive(true);
    }

我使用值为16000的SetPreferredSampleRate和声音作品

AVAudioSession.SharedInstance().SetPreferredSampleRate(16000, out NSError sampleHardwareErr2);

你也可以发布代码吗?@Isma add init AVAudioSession code