Hi,
When I start camera on the web I have queston about access to the camera.
How can I catch an error if somebody clicks denied?
When I try in this way.
exception is not catched.
but in the browser dev tools I have info.
Hi,
When I start camera on the web I have queston about access to the camera.
How can I catch an error if somebody clicks denied?
When I try in this way.
exception is not catched.
but in the browser dev tools I have info.
Hi,
This is caused by the underlying getUserMedia
promise that is being rejected. Unfortunately rejected promises cannot be caught with a JavaScript try..catch
structure.
I see two options here:
Start
variant that returns a promise so that you can catch the errors yourself by doing something like WebCamera1.StartP.catch(@RejectHandler)
OnError
event that will be triggered whenever calling TWebCamera.Start
fails.Hi,
For me, the second option is more transparent :)
Btw ... we have a problem with catching exceptions in TMS Web Core, especially for the promise method ... see my different reported issue
any news concerning this?
This is a browser related technical issue/limitation for which no workaround so far was found.
Ok .. than If changes will be made to the TWebCamera anyway, is it possible to add
control the camera light/torch on the mobile?.
I see that it is option for the getUserMedia used in the current TWebCamera solution.
We've added the OnError
event as well as the StartP
method, they will be available with the next update.
We didn't add a property/method to interact with the torch directly because of the limited support. Apart from that, we were not able to trigger the torch for all camera modules on the mobile device we tested with, which means not all modules are capable of accessing the flashlight from the browser.
However, here you can find some code snippets that can get you started. It includes checking the currently selected device for the torch
capability and turning the flashlight on and off:
Ok ... thx, it helps
Hi @Tunde other question to the camera constraints.
I tried change image resolution by doing like this
procedure TfrmCameraView.setHighResolution(camera: TWebCamera);
var
JSONConstraints: TJSObject;
begin
JSONConstraints := TJSObject.new;
JSONConstraints.Properties['width'] := 1024;
JSONConstraints.Properties['height'] := 768;
camera.ApplyConstraints(JSONConstraints);
end;
but without success ... still I got an image in 640x480 resolution.
Any idea how to do this?
Hi,
I tested this here. Your snippet works, but it needs a second or two to switch the resolution.
See the difference on the camera we have here, just by calling ApplyConstraints:
The code snippet basically tells the camera to use a fixed resolution (that it might not support).
See the 4th snippet in the examples here: MediaDevices: getUserMedia() method - Web APIs | MDN
The browser will try to honor this, but may return other resolutions if an exact match is not available, or the user overrides it.
It very well could be that the 1024x768 resolution is not supported so the browser picks something else that happens to be 640x480 or something close to it.
However, the width and height constraints have more options. You could try to define the min
or ideal
resolution.
procedure TForm1.WebButton2Click(Sender: TObject);
var
JSONConstraints: TJSObject;
begin
JSONConstraints := TJSObject.new;
JSONConstraints.Properties['width'] := new(['min', 1024]);
JSONConstraints.Properties['height'] := new(['min', 768]);
WebCamera1.ApplyConstraints(JSONConstraints);
end;
min
: This will try to get the resolution or select the closest higher resolution if the defined width/height is not supported. Mind you, this can cause an error (you cannot demand a 4k resolution from a HD camera)ideal
this will try to pick the closest resolution to your defined one