Hi,
TWebCamera does not have such functionality by default. It's not exactly clear how widely the torch
constraint is supported, which could be used to activate and deactivate the phone's flash.
We did a small test but in our case we were not able to turn off the flash after activating it (it might not be an issue for you if you stop the camera right after reading a barcode). It is most likely related to this bug report: 1246938 - chromium - An open-source project to help move the web forward. - Monorail
You can try the following and see if it works for your use case:
implementation
type
TWebCameraOpen = class(TWebCamera);
{$R *.dfm}
procedure TForm1.WebButton1Click(Sender: TObject);
begin
WebCamera1.Start;
end;
procedure TForm1.HandleFlash(AActiveFlash: Boolean);
var
torch, constraints: TJSObject;
begin
torch := TJSObject.new;
torch['torch'] := AActiveFlash;
constraints := TJSObject.new;
constraints['advanced'] := TJSArray.new(torch);
TWebCameraOpen(WebCamera1).GetVideoTrack.applyConstraints(constraints);
end;
procedure TForm1.offBtnClick(Sender: TObject);
begin
//Not guaranteed to work
HandleFlash(False);
end;
procedure TForm1.onBtnClick(Sender: TObject);
begin
HandleFlash(True);
end;