How to detect unplugged headphone jack in WinRT? - c#

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.

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

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.

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.

Related

How to make the headphones hear the microphone in C# (not streaming)

Windows Sound mixer/settings can set the microphone to play over the speakers. I'm looking for a way to do that through C#. I'm assuming there is a DLL reference or .NET call that might be able to.
Everything I've been finding invariably goes back to streaming, which I don't want to do. Unless that's whats actually happening under the hood when changing the audio settings in windows.
If it helps, I'm using C# 3.5 (Unity App) and running on Windows 10 latest.
Thanks!
You can do this with Core Audio APIs link
For implementation you can refer
https://blog.sverrirs.com/2016/02/windows-coreaudio-api-in-c.html

UWP Real time audio on windows 10

I would like to ask you: In my company I should develop the communication app. Something like Skype etc. We have our custom SIP implementation. Data are encrypted by RSA, or something like that. Now, I'm looking for some solution, how to implement capturing audio on windows 10 (desktop, phone)
I found something about WASAPI, XAudio2. I think, the best option is WASAPI. But It will be working on Windows 10 Mobile? Or would you recommend me any third part libraries like SharpDX, NAudio? I need echo cancellation, and Im not sure, if WASAPI supports echo cancellation.
All advices will be appreciated.
WASAPI is definitely available on windows mobile 10.
but you could capture the audio directly with the "voice capture dsp"
https://msdn.microsoft.com/en-us/library/ff819492(v=VS.85).aspx
i found no info about its availability on win mobile 10, but it's really probable you can use it there too.

Monitor microphone changes

Is there any way to monitor microphone changes (plug in and plug out events)? Shouldn't matter if the mic is bluetooth / usb / or plugged directly to sound card.
Application is built with C# but if there isn't any good way to get the events using C# then C++/CLI might be also option.
I found also IMMNotificationClient from WASAPI which should work.
Seems NAudio is not exposing this, but after customization I'm able to use it and get plugin / plugout events. Although it doesn't seem really stable - duplicated events / missing events and etc. Is there any proper implementation example in managed level?
Interface description :: IMMNotificationClient interface
This link may help:
http://blogs.msdn.com/b/coding4fun/archive/2009/10/08/9905168.aspx
The post includes instructions on capturing the microphone level, etc.
Original post. Microphone Input
EDIT: Blog moved here: https://channel9.msdn.com/coding4fun/articles/NET-Voice-Recorder

Bluetooth support in C#

I am looking for a Bluetooth stack for C# that will allow me to route audio from my phone to my computer, as well as use my microphone on my computer(Windows 7) as an input device for phone calls on my phone. I've looked at 32Feet.NET, but it does not seem to support audio channels. If I am wrong on this, someone please correct me. Otherwise, if there an alternate library for C# that I can use for Bluetooth support?
I'm afraid this probably doesn't really answer your question, but maybe adds some alternative perspective: The issues you're trying to solve seem to be supported by standard Bluetooth audio profiles. As such, there are chances they're provided by the OS's (or other vendor's) Bluetooth stack in a transparent manner, i.e. as audio device like the system's sound card.
If there is no urgent reason for a custom implementation of these Bluetooth profiles, you might be better off looking for .NET methods that configure the audio devices your code uses for audio input/output. You would then use Bluetooth audio in the same way you access other audio devices, basically reducing your code to proxy audio from one audio device (sound card) to another (Bluetooth audio).

Windows mobile, how do I receive callbacks from the camera?

I am developing an C# app in WM 6. I am using CameraCaptureDialog to open the camera.
I would need to receive callbacks from the camera, I know this method is not implemented by CameraCaptureDialog.
I would need for Windows Mobile, sth similar to this method in Android:
camera.setOneShotPreviewCallback(previewCallback);
Do you know any other library I can use to do this?
The CameraCaptureDialog isn't going to be of much use at all. To get access to the camera on a WinMo device, you need to use a DirectShow filtergraph. There's a reasonably good article on CodeGuru that covers WinMo specifically.

Categories

Resources