How to detect the audio endpoint device in Windows Phone 8 App ?

This blog post will explain how to detect the audio endpoint device that is connected to the Windows Phone 8 device .

How to detect the audio endpoint device in Windows Phone 8 App ?

The Windows Phone 8 SDK provides the VOIP AudioRoutingManager API which can be used to determine the connected audio endpoint device.

The AudioRoutingManager has the method GetAudioEndpoint which returns the AudioRoutingEndpoint . The AudioRoutingEndpoint is a enum which contains one of the values (Earpiece,Speakerphone,Bluetooth,WiredHeaset,WiredHeadsetSpeakerOnly,BluetoothWithNoiseAndEchoCancellation,Default).

image

Here’s a codesnippet to get the audio endpoint device that is connected.

AudioRoutingEndpoint current = AudioRoutingManager.GetDefault().GetAudioEndpoint();           
MessageBox.Show(current.ToString());

image

Note that you need to add the ID_CAP_VOIP capability in your WMAppManifest file or else you will receive the following error when trying to access the endpoint.

image

An exception of type ‘System.UnauthorizedAccessException’ occurred in MobileOSGeekApps.DLL but was not handled in user code

Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Leave a Reply