我尝试过使用AudioRoutingManager类…但是我有一个未经授权的访问异常.
这是我的代码
原文链接:https://www.f2er.com/windows/371852.html这是我的代码
AudioRoutingManager audioRouting = AudioRoutingManager.GetDefault(); public AudioRoutingEndpoint ChangeAudioRoute() { var currentEndPoint= audioRouting.GetAudioEndpoint(); switch (currentEndPoint) { case AudioRoutingEndpoint.Earpiece: case AudioRoutingEndpoint.Default: return AudioRoutingEndpoint.Speakerphone; case AudioRoutingEndpoint.Speakerphone: return AudioRoutingEndpoint.Earpiece; default: throw new OperationCanceledException(); } } public void SetAudioRoute() { audioRouting.SetAudioEndpoint(this.ChangeAudioRoute()); }