我尝试过使用AudioRoutingManager类…但是我有一个未经授权的访问异常.
这是我的代码
这是我的代码
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()); }