简体   繁体   English

在.NET Core或UWP中使用C#静音Windows 10主卷

[英]Mute windows 10 master volume using C# in .NET Core or UWP

Anyone know how to programmatically mute the Windows 10 Volume using C# in .NET Core or in Universal Windows platform. 任何人都知道如何在.NET Core或Universal Windows平台上使用C#以编程方式静音Windows 10卷。 I searched a lot but couldn't find any straight forward standard API for this in .NET Core for windows UWP Apps. 我搜索了很多,但在.NET Core for Windows UWP Apps中找不到任何直接的标准API。

Specifically about UWP, the following links might be of some value to you: 特别是关于UWP,以下链接可能对您有一定价值:

However as the links's description might indicate, it only explains how we can control the sound inside the application , either by controlling the integrated sound system in UWP, or the audio in a control such as MediaPlayer . 然而,正如链接的描述可能表明的那样,它只能解释我们如何通过控制UWP中的集成音响系统或控件(如MediaPlayer的音频来控制应用程序内部的声音。

For instance, imagining that it isn't desired to have any kind off sound in an UWP app, we could perform the following set : 例如,想象在UWP应用程序中不希望有任何类型的声音,我们可以执行以下设置

ElementSoundPlayer.State = ElementSoundPlayerState.Off;

However, when it comes to actually override the System's Volume, that does not seem possible. 但是,当涉及到实际覆盖系统的音量时,这似乎是不可能的。 As it is mentioned in the documentation, the app's sound can't get any louder than the system's sound. 正如文档中提到的那样,应用程序的声音不会比系统的声音更响亮。 In this example, 在这个例子中,

ElementSoundPlayer.Volume = 1.0;

The Volume property has been set to it's maximum value, but that only means that the sound volume will be the same as the system's volume. Volume属性已设置为最大值,但这仅表示音量与系统音量相同。

The API does not seem to provide a way to directly change the System's Volume. API似乎没有提供直接更改系统卷的方法。 It's all about the ecosystem of the app itself being managed by the system and not the opposite. 这完全是关于应用程序本身的生态系统由系统管理而不是相反。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM