当通话接通时如何暂停系统所有声音

huangapple go评论99阅读模式
英文:

How To Pause All The Sounds Of The System When The Call Is Connected

问题

我想创建一个UWP应用程序,当在Google Meet、Zoom等应用中接通电话时,应该暂停Windows系统的所有声音。

如何使用C#来实现这个功能。

英文:

I want to create an UWP app which should pause the all the sound of my Windows system when there is call is connected in the Google meet, Zoom etc.

How to do this by using C#.

答案1

得分: 1

从 UWP 方面来看,UWP 应用程序在沙盒中运行,与系统隔离,无法访问其他应用程序的进程,在访问系统资源时受到限制。因此,您无法通过 UWP 暂停 Windows 系统声音。

但有一个解决方案,您可以使用桌面桥启动桌面应用程序,调用 Win32 API keybd_event,使用 VK_MEDIA_PLAY_PAUSE 模拟暂停键输入。您可以参考 Stefan Wick 的博客 UWP with Desktop Extension – Part 2

英文:

Just from UWP side, UWP apps are running in sandbox which are isolated from system, it cannot access other app's process and is restricted when accessing system resources. So, you can't pause Windows system sound from UWP.

But there is a solution, you can use Desktop-bridge to start a desktop application, call Win32 API keybd_event with VK_MEDIA_PLAY_PAUS to simulate pause key input. You can refer to Stefan Wick's blog UWP with Desktop Extension – Part 2

huangapple
  • 本文由 发表于 2023年6月15日 16:20:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76480480.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定