C# Windows 10以C获取系统音频静音状态#
我尝试使用winmm.dll,但没有效果,我使用了我发现的其他几个类似的项目,但除了getVolume方法返回的-1和其他方法返回的无意义值之外,我没有得到任何东西 有图书馆可以用吗?有没有更现代的例子(这是2010年以前的)?我已经查看了IdiooDooPositBooT接口,但它不能通过.NET而获得,我不是C++的家伙。p>C# Windows 10以C获取系统音频静音状态#,c#,.net,windows,winmm,C#,.net,Windows,Winmm,我尝试使用winmm.dll,但没有效果,我使用了我发现的其他几个类似的项目,但除了getVolume方法返回的-1和其他方法返回的无意义值之外,我没有得到任何东西 有图书馆可以用吗?有没有更现代的例子(这是2010年以前的)?我已经查看了IdiooDooPositBooT接口,但它不能通过.NET而获得,我不是C++的家伙。p> 非常感谢您的帮助。IAudioEndpointVolume在中提供 您可以通过调用int-GetMute([Out][marshallas(UnmanagedType
非常感谢您的帮助。
IAudioEndpointVolume
在中提供
您可以通过调用int-GetMute([Out][marshallas(UnmanagedType.Bool)]Out-Boolean-ismute)获取主卷是否被静音。
方法:
// http://netcoreaudio.codeplex.com/SourceControl/latest#trunk/Code/CoreAudio/Interfaces/IAudioEndpointVolume.cs
[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAudioEndpointVolume
{
/// <summary>
/// Gets the muting state of the audio stream.
/// </summary>
/// <param name="isMuted">The muting state. True if the stream is muted, false otherwise.</param>
/// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
[PreserveSig]
int GetMute([Out] [MarshalAs(UnmanagedType.Bool)] out Boolean isMuted);
}
bool isMuted = AudioManager.GetMasterVolumeMute();
用法:
调用GetMasterVolumeMute()
方法:
// http://netcoreaudio.codeplex.com/SourceControl/latest#trunk/Code/CoreAudio/Interfaces/IAudioEndpointVolume.cs
[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAudioEndpointVolume
{
/// <summary>
/// Gets the muting state of the audio stream.
/// </summary>
/// <param name="isMuted">The muting state. True if the stream is muted, false otherwise.</param>
/// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
[PreserveSig]
int GetMute([Out] [MarshalAs(UnmanagedType.Bool)] out Boolean isMuted);
}
bool isMuted = AudioManager.GetMasterVolumeMute();
IAudioEndpointVolume
在中可用
您可以通过调用int-GetMute([Out][marshallas(UnmanagedType.Bool)]Out-Boolean-ismute)获取主卷是否被静音。
方法:
// http://netcoreaudio.codeplex.com/SourceControl/latest#trunk/Code/CoreAudio/Interfaces/IAudioEndpointVolume.cs
[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAudioEndpointVolume
{
/// <summary>
/// Gets the muting state of the audio stream.
/// </summary>
/// <param name="isMuted">The muting state. True if the stream is muted, false otherwise.</param>
/// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
[PreserveSig]
int GetMute([Out] [MarshalAs(UnmanagedType.Bool)] out Boolean isMuted);
}
bool isMuted = AudioManager.GetMasterVolumeMute();
用法:
调用GetMasterVolumeMute()
方法:
// http://netcoreaudio.codeplex.com/SourceControl/latest#trunk/Code/CoreAudio/Interfaces/IAudioEndpointVolume.cs
[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAudioEndpointVolume
{
/// <summary>
/// Gets the muting state of the audio stream.
/// </summary>
/// <param name="isMuted">The muting state. True if the stream is muted, false otherwise.</param>
/// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
[PreserveSig]
int GetMute([Out] [MarshalAs(UnmanagedType.Bool)] out Boolean isMuted);
}
bool isMuted = AudioManager.GetMasterVolumeMute();
你正在创建什么样的项目?一个想法是创建一个媒体播放器(在后台)并测试媒体播放音量
_mediaPlayer = new MediaPlayer();
_systemMediaTransportControls = _mediaPlayer.SystemMediaTransportControls;
double volume = _systemMediaTransportControls.Volume;
你正在创建什么样的项目?一个想法是创建一个媒体播放器(在后台)并测试媒体播放音量
_mediaPlayer = new MediaPlayer();
_systemMediaTransportControls = _mediaPlayer.SystemMediaTransportControls;
double volume = _systemMediaTransportControls.Volume;
C#
和VB.Net
。答案大致相同。带上一些你可能感兴趣的笔记。链接到C#
和VB.Net
。答案大致相同。带上一些你可能感兴趣的笔记。链接到。