杰克感应C# [英] Jack Sensing in C#
问题描述
我正在编写一个能够录制麦克风音频的应用程序。我的问题是我需要知道用户何时插入插孔并拔出插孔。
I am writing an application that will record audio from microphone. My problem is I need to know when the user plug in the jack and remove the jack out.
我查看了 Win32_SoundDevice
WMI类,在我看来没有这样的属性我可以查看状态杰克
I looked into Win32_SoundDevice
WMI class and seems to me there is no such a property that I can check the status of the Jack.
然后我在 IMMDeviceEnumerator
中找到 RegisterEndpointNotificationCallback
做我需要的但我不知道如何在C#中做到这一点。有谁知道如何使用 MMDeviceEnumerator
方法来检查音频端口状态?任何帮助高度赞赏。
Then I found RegisterEndpointNotificationCallback
in IMMDeviceEnumerator
which seems to do what I need but I have no clue how to do this in C#. Does anyone know how to use MMDeviceEnumerator
methods to check for audio port status ? Any help highly appreciated.
推荐答案
你可能想看看当时的开源 NAudio 项目。
You might want to take a look at then open source NAudio project.
我浏览了他们的代码,看起来他们有一个.Net包装器您的 IMMDeviceEnumerator
界面。
I've browsed their code and it appears they have a .Net wrapper for your IMMDeviceEnumerator
interface.
由于此项目属于Microsoft公共许可证,因此它可能在您的项目中可用。
As this project is under Microsoft Public License, it'll probably be usable in your project.
这篇关于杰克感应C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!