lavva.exalushome.webcams
v2.0.61
Published
Library implementing webcams and abstraction layers for webcams configuration API in ExalusHome system
Downloads
101
Readme
ExalusHome WebCams library for Lavva
WebCams library is a part of exalushome-webcams that allows you to manage web cameras added to TR7 controller.
Library implementation:
If you want to use this library in any JavaScript or TypeScript project you can use npm to install it as package from npm repository. For that you will have to use command:
npm install lavva.exalushome.webcams
or
yarn add lavva.exalushome.webcams
Initialization:
If you have installed this package then you have to initialize this library first before usage. To do this, you have to call:
import { IWebCamsService, WebCamConfiguration } from 'lavva.exalushome.webcams/build/js/IWebCamsService';
import { WebCamsService } from 'lavva.exalushome.webcams';
WebCamsService.Init();
Getting this service
The library is based on the DI of exalushome-library, so you need to load the base service from the API, then you can load WebCams Services.
let cams = Api.Get<IWebCamsService>(WebCamsService.ServiceName);
To add video control you have to add element in HTML DOM:
<video id="webCam" autoPlay playsInline muted controls style="width: 100%"></video>
To display video stream from this device you have to get media stream and set it as video tag's srcObject.
You can do this like that:
// Get web cam object
let cam = await cams.GetWebCamAsync(camDev);
// get miedia stream for given camera
let mediaStream = await cam.GetRTCMediaStreamAsync();
//set media stream to <video> tak by setting srcObject for example in this way:
(document.getElementById("webCam") as HTMLMediaElement).srcObject = mediaStream;