【发布时间】:2016-05-25 18:17:33
【问题描述】:
我正在使用 UWP c# 中的 Flash 和相机 API。一切正常(参见下面的代码 sn-ps)。但是我想知道如何在关闭手机屏幕时保持手电筒开启。
因为当我按下手机右侧的电源按钮时,当我再次解锁设备时,闪光灯会自动关闭并且不会打开。即使屏幕关闭,我也希望手电筒处于活动状态。
var cameraID = await GetCameraDeviceInfoAsync(Windows.Devices.Enumeration.Panel.Back);
if (cameraID != null)
{
this.captureManager = new MediaCapture();
var settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Video;
settings.PhotoCaptureSource = PhotoCaptureSource.VideoPreview;
settings.AudioDeviceId = string.Empty;
settings.VideoDeviceId = cameraID.Id;
await this.captureManager.InitializeAsync(settings);
this.mediaPreview = new CaptureElement();
this.mediaPreview.Source = this.captureManager;
await this.captureManager.StartPreviewAsync();
}
var flash = this.captureManager.VideoDeviceController.FlashControl;
flash.Enabled = true;
【问题讨论】:
标签: c# uwp windows-phone led flashlight