简体   繁体   English

使用C#UWP应用程序控制Raspberry Pi的音量

[英]Control Volume of Raspberry Pi with C# UWP Application

我有一个在Raspberry Pi 3上使用Windows IoT Core的C#UWP应用程序。是否可以通过C#代码控制pi的主音量输出级别?

As far as i know, there is no API in UWP used to change the System's Volume directly. 据我所知,UWP中没有用于直接更改系统音量的API。 It's all about the ecosystem of the app itself being managed by the system. 这完全是由系统管理的应用程序本身的生态系统。 You may try to find Win32 API to control master volume. 您可以尝试找到Win32 API来控制主音量。

Here is an answer to changing the master volume from C++, also includes SetMute, etc. You can call the api in C#.Maybe it is helpful for you. 这是从C ++更改主音量的答案,还包括SetMute等。您可以在C#中调用api。也许对您有所帮助。 Changing master volume level 改变主音量

In addition, WASAPI provides client-specified volume and mute settings uniformly to all of the streams in the session. 另外, WASAPI统一为会话中的所有流提供客户端指定的音量和静音设置。 Users can adjust the volume and mute settings for all of the sessions in the system. 用户可以调整系统中所有会话的音量和静音设置。 But WASAPI is only available in C++. 但是WASAPI仅在C ++中可用。 if you want to do it from a C# UWP App, you can create a RuntimeComponent in C++CX that will provide this feature to your app. 如果要从C#UWP应用程序执行此操作,则可以在C ++ CX中创建一个RuntimeComponent,它将为您的应用程序提供此功能。

https://docs.microsoft.com/en-us/windows/desktop/coreaudio/audio-sessions https://docs.microsoft.com/zh-CN/windows/desktop/coreaudio/audio-sessions

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

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