TWebCamera and FlashLight

Hi,

Unfortunately it looks like TWebCamera.GetDeviceConstraints currently returns the applied constraints instead of the available constraints of the selected device.

We fixed this internally and the next version will be containing the necessary changes. After that, something like this should work:

procedure TForm1.WebCamera1CameraDevicesInitialized(Sender: TObject);
var
  I: Integer;
begin
  //Get a list of available camera devices, select the first one
  WebComboBox1.Clear;

  for I := 0 to WebCamera1.CameraDevices.Count - 1 do
    WebComboBox1.Items.Add(WebCamera1.CameraDevices.Items[I].Name);

  if WebCamera1.CameraDevices.Count > 0 then
  begin
    WebCamera1.CameraType := ctSelected;
    WebCamera1.SetSelectedCameraDevice(WebCamera1.CameraDevices.Items[0]);
    WebCamera1.Start;
    WebComboBox1.ItemIndex := 0;
  end;
end;

procedure TForm1.WebCamera1CameraStreamPlay(Sender: TObject;
  ACamera: TCameraDevice);
begin
  //If the selected device has the 'torch' constraint it means it supports
  //the flash
  if WebCamera1.GetDeviceConstraints.Text.Contains('torch') then
    WebCheckBox1.Enabled := True
  else
    WebCheckBox1.Enabled := False;
end;

procedure TForm1.WebCheckBox1Click(Sender: TObject);
var
  o: TJSObject;
begin
  //Turn flash on-off
  o := TJSObject.new;
  if WebCheckBox1.Checked then
    o.Properties['torch'] := True
  else
    o.Properties['torch'] := False;

  WebCamera1.ApplyConstraints(o);
end;

procedure TForm1.WebComboBox1Change(Sender: TObject);
begin
  //Start camera with selection
  WebCamera1.Stop;
  WebCamera1.SetSelectedCameraDevice(WebCamera1.CameraDevices.Items[WebComboBox1.ItemIndex]);
  WebCamera1.Start;
end;