在Python中是否可以检测是否有东西插入音频插孔?
我正在尝试用 python 检测是否有设备连接到音频插孔。这是在 Windows 7 中。
I'm trying to detect if there is a device hooked into the audio jack with python. This is in Windows 7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅https://superuser.com/questions /110933/how-does-a-sound-card-define-if-headphones-are-plugged-in
答案是:这取决于您的硬件。在过去的十年里,我没有看到任何操作系统检测耳机,但一些廉价的声卡确实支持它。 (编辑:根据 Larry Osterman 的评论,它们现在是标准的。)
如果您的声卡支持它,我相信您会发现以下内容就是您正在寻找的答案: 检测耳机何时插入(python 可能需要询问一些系统 API)
see https://superuser.com/questions/110933/how-does-a-sound-card-determine-if-headphones-are-plugged-in
The answer is: It depends on your hardware. I have not seen any operating system detect headphones in the past decade, but some cheap soundcards do support it. (edit: According to Larry Osterman's comment, they are now standard.)
If your soundcard supports it, I believe you will find the following to be the answer you are looking for: Detecting when head phones are plugged in (python will probably need to ask some system API)