如何检测在WinRT中拔出耳机插孔? [英] How to detect unplugged headphone jack in WinRT?

查看:597
本文介绍了如何检测在WinRT中拔出耳机插孔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有得到通知,每当一个耳机插孔是在WinRT中的应用程序不插电的方式?我希望能够暂停MediaElement的播放,当它发生,以防止声音从扩音器泄漏。

Is there a way to get notified whenever a headphone jack is unplugged in a WinRT app? I want to be able to pause MediaElement playback when it happens to prevent the sound from leaking out through loudspeakers.

推荐答案

杰克检测的通知通过IMMNotificationClient暴露:: OnDeviceStateChanged。刚刚试了一下win8的桌面上,OnDeviceStateChanged被调用DEVICE_STATE_UNPLUGGED和DEVICE_STATE_ACTIVE时(UN)插入的设备。可悲的是WASAPI的一部分只所以我想有没有办法做到这一点在WinRT的记录为桌面。

Jack detection notification is exposed through IMMNotificationClient::OnDeviceStateChanged. Just tried it on win8 desktop, OnDeviceStateChanged gets called with DEVICE_STATE_UNPLUGGED and DEVICE_STATE_ACTIVE when (un)plugging a device. Sadly that part of wasapi is documented as desktop only so i guess there's no way to do it in WinRT.

这篇关于如何检测在WinRT中拔出耳机插孔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆