Windows Phone音频路由/交换 [英] Windows Phone Audio Routing/Switching

查看:64
本文介绍了Windows Phone音频路由/交换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Windows手机应用程序,但无法找到一种方法将音频从耳机切换到扬声器,反之亦然,正如微软在其官方FM收音机应用中所做的那样。





shubham_sd

解决方案

你好shubham,



你可以使用
AudioRoutingManager.SetAudioEndpoint
API(Windows Phone 8.0或更高版本)或
AudioGraphSettings.PrimaryRenderDevice API。


< pre class ="prettyprint"> var audioRoutingManager = AudioRoutingManager.GetDefault();
audioRoutingManager.SetAudioEndpoint(AudioRoutingEndpoint.Speakerphone);


https://blogs.msdn.microsoft.com/matthew_van_eerde/2014/03/17/a-mental-model-for-the-windows-phone-audioroutingmanager-api  

 Windows.Devices.Enumeration.DeviceInformationCollection devices = 
等待Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Media.Devices.MediaDevice。 GetAudioRenderSelector());
//显示UI以允许用户选择设备
Windows.Devices.Enumeration.DeviceInformation selectedDevice = ShowMyDeviceSelectionUI(devices);
settings.PrimaryRenderDevice = selectedDevice;


https ://msdn.microsoft.com/en-us/windows/uwp/audio-video-camera/audio-graphs  
$


最好的问候,

David




hi, i am developing windows phone application, but unable to find a way to switching audio from earphones to speaker and vice versa as microsoft does in its official fm radio app.


shubham_sd

解决方案

Hi shubham,

You could use either AudioRoutingManager.SetAudioEndpoint API for phones (Windows Phone 8.0 or later) or AudioGraphSettings.PrimaryRenderDevice API for all Windows 10 devices.

var audioRoutingManager = AudioRoutingManager.GetDefault();
audioRoutingManager.SetAudioEndpoint(AudioRoutingEndpoint.Speakerphone);

https://blogs.msdn.microsoft.com/matthew_van_eerde/2014/03/17/a-mental-model-for-the-windows-phone-audioroutingmanager-api 

Windows.Devices.Enumeration.DeviceInformationCollection devices =
 await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Media.Devices.MediaDevice.GetAudioRenderSelector());
// Show UI to allow the user to select a device
Windows.Devices.Enumeration.DeviceInformation selectedDevice = ShowMyDeviceSelectionUI(devices);
settings.PrimaryRenderDevice = selectedDevice;

https://msdn.microsoft.com/en-us/windows/uwp/audio-video-camera/audio-graphs 

Best Regards,
David


这篇关于Windows Phone音频路由/交换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆