Post

Replies

Boosts

Views

Activity

Reply to When iOS17 has a bug and cannot record audio, play the audio to a Bluetooth device
AVAudioSession *audioSession = [AVAudioSession sharedInstance]; // 设置为内置麦克风采集 [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord mode:AVAudioSessionModeVideoRecording options:nil error:nil]; // 切换输入麦克风 AVAudioSessionPortDescription *builtInMicPort = nil; for (AVAudioSessionPortDescription *portDescription in audioSession.availableInputs) { if ([portDescription.portType isEqualToString:AVAudioSessionPortBuiltInMic]) { builtInMicPort = portDescription; break; } } if (builtInMicPort) { NSError *inputError = nil; [audioSession setPreferredInput:builtInMicPort error:&inputError]; if (inputError) { NSLog(@"切换输入麦克风失败:%@", inputError); }else{ NSLog(@"内置麦克风"); } } else { NSLog(@"找不到内置麦克风"); } [audioSession setActive:YES error:nil]; work normal
Dec ’23
Reply to How to make sound output from Bluetooth instead of speakers in IOS 17
AVAudioSession *audioSession = [AVAudioSession sharedInstance]; // 设置为内置麦克风采集 [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord mode:AVAudioSessionModeVideoRecording options:nil error:nil]; // 切换输入麦克风 AVAudioSessionPortDescription *builtInMicPort = nil; for (AVAudioSessionPortDescription *portDescription in audioSession.availableInputs) { if ([portDescription.portType isEqualToString:AVAudioSessionPortBuiltInMic]) { builtInMicPort = portDescription; break; } } if (builtInMicPort) { NSError *inputError = nil; [audioSession setPreferredInput:builtInMicPort error:&inputError]; if (inputError) { NSLog(@"切换输入麦克风失败:%@", inputError); }else{ NSLog(@"内置麦克风"); } } else { NSLog(@"找不到内置麦克风"); } [audioSession setActive:YES error:nil]; set mode AVAudioSessionModeVideoRecording normall
Dec ’23