How to detect unplugged headphone jack in WinRT?

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.

Detect plugged & unplugged event on headphone jack in Xamarin.iOS (iOS 7)

I’m trying to find a way to detect the plugged/unplugged event on headphone Jack in Xamarin.iOS, specifically on latest version (iOS 7). I’ve found posts that give solution for earlier versions, but t

Headphone Jack Listener Android

Does anyone know how I can detect if the headphone jack on a device is unplugged on Android? I have a music player and I need to pause the music when the headphones are unplugged. The closest thing I

How to detect something in headphone jack on a Mac?

Is there a way to detect if something is plugged into the headphone jack of a Mac using c or objective-c? Thanks



Event headphone jack ( Windows XP ) with Realtek ALC888

How to detect event headphone jack inserted/removed on Realtek ALC888? Is there any SDK or lib? Global question: how to detect this same event under Windows XP? Global answer: not exist universal solu

Bandwidth from headphone/microphone jack

I got interested in this after I saw Square use the headphone jack on the iPhone to send credit card data. What’s the average bandwidth of the headphone jack on the iPhone, average notebook, and aver

Audio input through headphone jack in Android?

I am trying to get audio input through the headphone jack for my final year project. It would be a great help if someone can share some code on how to capture the data. I have been trying but as I am

How to detect when an audio device has been plugged and unplugged?

How to detect when an audio device has been plugged and unplugged using C#?

Enable or disable Headphone Jack Connector of an iPhone

I want to know how to Enable or disable Headphone Jack Connector of an iPhone, with Xcode and Objective-C. Even if the device is plug on.

iOS audio output only to headphone jack

Is it possible to output audio only to the iOS device’s headphone jack and nowhere else? (e.g. not speakers nor bluetooth) We’re experimenting on a hardware add-on that receives input as tones from th

How to detect headphone plug event in “offline” mode

I know how to detect headphone plug in event if my application is running. You have to register broadcast receiver for ACTION_HEADSET_PLUG. But you can’t capture this action using Manifest declaration

Answers

The only way it should be possible is through WASAPI – Windows Audio Session API (see WASAPI sample).

Sadly, WASAPI isn’t exposed in c#, only in C++ (but I’m not sure if it covers jack detection or not. I honestly don’t believe that they expose jack detection at the API level…).

Hopes this help.

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.

Try the following:

Windows::Devices::Enumeration::DeviceInformation::CreateWatcher(Windows::Devices::Enumeration::DeviceClass::AudioRender);

This works on WinRT.

See MSDN for more detail on the method: http://msdn.microsoft.com/en-us/library/ie/windows.devices.enumeration.deviceinformation.createwatcher