c# – 触发音量按钮拍照UWP

我尝试使用自拍杆,但由于Windows 10相机应用程序不提供拍照和录制视频的可能性,我想知道是否有可能触发和处理用户按下音量和/或UWP应用程序内的向下按钮

有没有人能够做到这一点?

I was wondering if there is a possibility to trigger and handle when the user presses the volume up and/or down button inside an UWP app

不,硬件音量控制需要特殊的开发权限,如果您是普通开发人员,则无法访问这些硬件控件,您可以参考Start, Back, Search, Power, and Volume control behavior.

I try to use a selfie stick, but as windows 10 camera app does not provide the possibility to take picture and record video with it.

我不确定为什么自拍杆不支持拍照和录制,有些Windows手机没有相机硬件按钮,如Lumia 640.但对于像Lumia 950这样的设备有摄像头硬件按钮,相机硬件按钮可在UWP应用程序中访问.从官方Basic camera app sample可以看出,它为Camera的硬件按钮注册事件处理程序,如下所示:

if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
    HardwareButtons.CameraPressed += HardwareButtons_CameraPressed;
}

使用此API时,您需要在项目中引用用于Universal App Platform的Microsoft Mobile Extension SDK.

如果访问摄像头硬件按钮对您来说还不够,我的建议是您可以通过Windows反馈工具提交添加此新功能以进行开发的请求.

https://stackoverflow.com/questions/39005968/trigger-volume-buttons-to-take-picture-uwp

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:c# – 触发音量按钮拍照UWP