Windows Phone音频路由/交换 [英] Windows Phone Audio Routing/Switching
问题描述
我正在开发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);
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);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屋!