How do you turn the flash on for scanning qr and bar codes?
Is there a torch light ability on the camera
Hi,
It depends on the device. The camera is hosted by an embedded browser and iOS for example does not implement the torch capability. Android usually supports it, but for some reason not all camera devices can be used together with the available flashlight.
You can check if the browser itself supports the torch by implementing the OnGetSupportedConstraints
event:
procedure TForm5.TMSFNCWXCamera1GetSupportedConstraints(Sender: TObject);
begin
if TMSFNCWXCamera1.SupportedConstraints.IndexOf('torch') <> -1 then
begin
//embedded browser supports torch
FHasTorchCapability := True;
end;
end;
Then you can try applying the torch constraint to the camera, but it's not guaranteed to work:
procedure TForm5.Button1Click(Sender: TObject);
begin
TMSFNCWXCamera1.Start;
end;
procedure TForm5.TMSFNCWXCamera1Start(Sender: TObject);
begin
if FHasTorchCapability then
SetFlash(True);
end;
procedure TForm5.SetFlash(AActivate: Boolean);
var
torch: TJSONObject;
begin
torch := TJSONObject.Create;
try
torch.AddPair('torch', AActivate);
TMSFNCWXCamera1.ApplyConstraints(torch);
finally
torch.Free;
end;
end;