136
Views
7
Comments
[Camera.Reactive] How can we close the camera in Camera.Reactive?
Question
camera-reactive
Reactive icon
Forge asset by Fábio Fantato

Hi All,

I'm using the forge of Camera.Reactive, but I can't find how to close the web camera after using. The camera is still open even after I change screen.

I tried this forum's solution which uses javascript, but it doesn't work for me.

https://www.outsystems.com/forums/discussion/60151/close-reactive-camera/

How can we close the camera in Camera.Reactive?

2022-01-05 09-37-24
Faiz Khan

Hi Yusuke Oki,

Please enclose in container and use the visibility option and define where u want to show or collapse the container that contains Camera Reactive component.

Regards,

Faiz Khan. 


UserImage.jpg
Yusuke Oki

Hi Faiz Khan,


Thank you for your replying.


I've tried to enclose in container and define visibility option.

However, After a reactive camera component is visible at once, even if the camera component becomes invisible, my laptop's web camera remains working. 


What I'd like to do is turning off my laptop's web camera after a camera component becoming invisible.


Regards,


Yusuke

UserImage.jpg
Suriya Narayanan

Hi Yusuki,
I can turn the camera off with this script.

var mediaStream = video.srcObject;

var tracks = mediaStream.getTracks();

tracks[0].stop();

tracks.forEach(function(track) { track.stop()})

Please run this script through some button action.

Thanks.


UserImage.jpg
Yusuke Oki

Hi Suriya


Thank you for your replying.


I had tried the javascript you shared, but it didn't work basically.

However, after running the javascript and opening developer tools of Web browsers(Chrome and Microsoft Edge) in a few times, I can turns off my pc camera.


Do you have any ideas about this situation?


Best Regards, 


Yusuke

2022-09-29 23-59-46
Alexis Rodriguez


Hi Yusuke,

I use this Javascript code to close it:

stream.getTracks().forEach(function(track) {

    track.stop();

});



It works fine for me, hope work for you.

Best regards,

Alexis Rodriguez.

UserImage.jpg
ali bhai

hi all, as I have seen in the article here is the camera closing problem. Change the Switch Camera Icon to a Dropdown Menu to access all the device's cameras. Modify your IOS behavior. Fullscreen mode does not open when the Camera is opened. before some months I got the same problem so I took the monitor for better results.

2024-09-06 07-21-49
Avinash Shukla

Hello Yusuke Oki,

The solution mentioned by Alexis is the right solution as I also have used the same javascript to close the camera after clicking the picture and saving it.

Regards 
Avinash

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.