对于我的Windows 8.1RT应用程序,我需要检测耳机是否已插入。
我发现这个问题回答了Windows 8.0和Windows 8.1 Silverlight应用程序的问题:Windows电话-音频终端设备
它在我的主视图的代码背后(实际上是从电话复制的)中尝试了这段代码。
AudioRoutingEndpoint currentAudioRoutingEndpoint = AudioRoutingManager.GetDefault().GetAudioEndpoint();
AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged_Handler;处理人员:
private void AudioEndpointChanged_Handler(AudioRoutingManager sender, object args)
{
var audioEndPoint = sender.GetAudioEndpoint();
switch (audioEndPoint)
{
case AudioRoutingEndpoint.Default:
{
//default audio devide
break;
}
case AudioRoutingEndpoint.Earpiece:
{
//Earpiece
break;
}
case AudioRoutingEndpoint.Speakerphone:
{
//Speakerphone
break;
}
case AudioRoutingEndpoint.Bluetooth:
{
//Bluetooth
break;
}
case AudioRoutingEndpoint.WiredHeadset:
{
//WiredHeadset
break;
}
case AudioRoutingEndpoint.WiredHeadsetSpeakerOnly:
{
//WiredHeadsetSpeakerOnly
break;
}
case AudioRoutingEndpoint.BluetoothWithNoiseAndEchoCancellation:
{
//BluetoothWithNoiseAndEchoCancellation
break;
}
default:
throw new ArgumentOutOfRangeException();
}
}如果我运行这段代码,就会得到这个异常: System.UnauthorizedAccessException被用户代码未处理,Message=Access =-2147024891被拒绝。(HRESULT例外: 0x80070005 (E_ACCESSDENIED))
我想这是因为缺少所需的功能(ID_CAP_VOIP和ID_CAP_AUDIOROUTING)。现在我的问题是,在我的Windows 8.1RT应用程序中,只有一个package.appxmanifest,没有WMAppManifest.xml,而且我似乎不能再定义这些功能了。
请注意,我的项目中确实没有WMAppManifest.xml,就像Windows 8.1 Silverlight项目中那样(事实上两者都可用)。
我真的很感激你的帮助!
编辑:将Windows 8.1 xaml更改为Windows 8.1 RT
发布于 2014-11-28 14:51:47
所以有两件事:
所以..。你可能无法在Windows上做你想做的事情(除非你正在构建一个VOIP应用程序)。
您试图用这个实现什么功能?也许还有别的选择。
发布于 2015-07-01 02:38:11
在WP8.1运行时,您可以使用以下代码创建一个xml文件WindowsPhoneReserveAppInfo.xml:
<?xml version="1.0" encoding="utf-8" ?>
<WindowsPhoneReservedAppInfo xmlns="http://schemas.microsoft.com/phone/2013/windowsphonereservedappinfo">
<SoftwareCapabilities>
<SoftwareCapability Id="ID_CAP_VOIP" />
</SoftwareCapabilities>
</WindowsPhoneReservedAppInfo>效果很好。祝好运!
https://stackoverflow.com/questions/27187503
复制相似问题