我想創建一個簡單的應用程序,它將具有打開和關閉Windows媒體設備中閃光燈的功能。 我已經初始化相機如下:控制寡婦媒體設備閃光燈
var devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
var rearCamera = devices.FirstOrDefault(item => item.EnclosureLocation != null &&
item.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back);
if (rearCamera != null)
{
DeviceName.Content = rearCamera.Name;
FlashButton.Visibility = System.Windows.Visibility.Visible;
mediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
{
VideoDeviceId = rearCamera.Id
});
LowLagPhotoCapture lowLagCaptureMgr = null;
// Image properties
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
// Create LowLagPhotoCapture object
lowLagCaptureMgr = await mediaCapture.PrepareLowLagPhotoCaptureAsync(imgFormat);
}
而且對我寫了下面的代碼閃光燈開關:
var MyVideoDeviceController = mediaCapture.VideoDeviceController;
var MyTorch = MyVideoDeviceController.TorchControl;
var MyFlash = MyVideoDeviceController.FlashControl;
if (MyTorch.Supported)
{
MyTorch.PowerPercent = 100;
MyTorch.Enabled = true;
}
else
{
if (MyFlash.Supported)
{
MyFlash.PowerPercent = 100;
MyFlash.Enabled = true;
}
else
{
MessageBox.Show("No Flash and Torch Support", "Flash and Torch");
}
}
,但似乎都TorchControl和FlashControl在代碼中不支持。我不確定是否也使用正確的API。我想在運動F5M運行此 - 平板電腦
在此先感謝
謝謝@Mike,這是非常翔實的。只是供參考,我的意圖是保持光源作爲火炬。我會嘗試你的鏈接。再次感謝您的信息。保持良好的工作。 –
嗨@Mike,你知道任何可以將設備暴露給Windows的驅動程序嗎? –
驅動程序通常不可互換,特別是如果您希望啓用某些功能。現在,Microsoft提供了一個通用相機驅動程序,因此您可以嘗試恢復到該驅動程序(通過在設備管理器中卸載相機並刪除驅動程序軟件),或者如果您已經在運行Microsoft驅動程序,則安裝由生產廠家。製造商是否提供可以使用閃光燈的應用程序?內置相機中沒有閃光燈嗎?如果是這樣,你應該聯繫他們要求更好的司機。 – Mike