Click here to Skip to main content
15,896,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone, I'm developing a application with voice commands and I'm looking for a way to detect when something is plugged into one of the audio jacks on a computer. It doesn't matter whether it's the headphone or microphone jack. I just need to know when SOMETHING gets plugged in or unplugged. I've searched all kinds of forums and everyone always answers that Mics aren't digital and they can't be detected. I know that. Like I said, I just need to know how to tell when something, it doesn't matter what it is, is plugged in or removed from any of the audio jacks. I hope I've been clear on what I need to do.
Posted
Updated 10-Oct-17 5:54am

What you've found online is right, you can't detect it.

The audio jacks are simple connectors that either send analog signals out, or receive them in. They function the same if something is connected to them as when something isn't. They don't have a method for detecting if the hardware is attached or not.

A microphone isn't too bad to detect through software, just listen on the port and if there is no signal at all (no noise) then you can assume that there is nothing connected. The speaker jack is different, since you can send sound out all you want and it just won't be heard if there is no speakers attached.

There's just no way to detect if speakers are there or not

It would be different if there were a method for measuring continuity through the speaker jack, but there isn't.
 
Share this answer
 
okay. it seems that I'm just going to have to put the SetInputToDefaultAudioDevice for the speech recognizer in a try/catch block. Thanks for your reply Ron Beyer.
 
Share this answer
 
There is a way to detect it.

Take a look here http://stackoverflow.com/questions/33872895/detect-if-headphones-are-plugged-in-or-not-via-c-sharp[^]


But the problem is how to difference Audio Device from the Integrated AUdio Device = Speackers.

And to resolve it we have to obtain the Jack Information. Well... I don kno whot to get this info.
 
Share this answer
 
Comments
CHill60 2-Dec-15 9:13am    
In other words you have added nothing to this 2 year old discussion

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900