Share via


InfraredTorchControl Class

Definition

Provides functionality for controlling the infrared torch LED settings on a capture device.

public ref class InfraredTorchControl sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 524288)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class InfraredTorchControl final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 524288)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class InfraredTorchControl
Public NotInheritable Class InfraredTorchControl
Inheritance
Object Platform::Object IInspectable InfraredTorchControl
Attributes

Windows requirements

Device family
Windows 10, version 1903 (introduced in 10.0.18362.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v8.0)

Examples

using Windows.Media.Capture;

MediaCapture mediaCapture = new MediaCapture();

public MainPage()
{
    this.InitializeComponent();
}

protected override async void OnNavigatedTo(NavigationEventArgs e)
{
    await mediaCapture.InitializeAsync();

    // Preview is Windows.UI.Xaml.Controls.CaptureElement defined in XAML file
    // and used to render camera preview
    Preview.Source = mediaCapture;
    await mediaCapture.StartPreviewAsync();

    if (!TryIncrementInfraredPower())
    {
        Debug.WriteLine("Failed to increment InfraredTorch power");
    }
}

private bool TryIncrementInfraredPower()
{
    bool incrementSucceeded = false;

    if (mediaCapture.VideoDeviceController.InfraredTorchControl.IsSupported)
    {
        Debug.WriteLine("IR torch supported");
        InfraredTorchControl infraredTorchControl = mediaCapture.VideoDeviceController.InfraredTorchControl;
        var maxPower = infraredTorchControl.MaxPower;
        var powerStep = infraredTorchControl.PowerStep;
        var oldPower = infraredTorchControl.Power;

        if (oldPower < maxPower)
        {
            infraredTorchControl.Power = oldPower + powerStep;
            incrementSucceeded = true;
        }
        else
        {
            Debug.WriteLine("InfraredTorch is already at max power");
        }
    }

    return incrementSucceeded;
}

Remarks

The InfraredTorchControl enables apps to control the power and behavior of the Infrared LED.

You can find out if a device supports this control by checking InfraredTorchControl.IsSupported.

You can access the InfraredTorchControl for the capture device through MediaCapture.VideoDeviceController.

Properties

CurrentMode

Gets the current operation mode of the infrared LED.

IsSupported

Gets a value that indicates if the capture device supports the InfraredTorchControl.

MaxPower

Gets the maximum infrared LED power value supported by the capture device.

MinPower

Gets the minimum infrared LED power value supported by the capture device.

Power

Gets or sets the current infrared LED power value.

PowerStep

Gets the supported power step value.

SupportedModes

SupportedModes property is used to find out modes that the infrared LED supports.

Applies to

See also