lavva.exalushome.webcams
Version:
Library implementing webcams and abstraction layers for webcams configuration API in ExalusHome system
44 lines (38 loc) • 1.79 kB
Markdown
WebCams library is a part of exalushome-webcams that allows you to manage web cameras added to TR7 controller.
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
```
If you have installed this package then you have to initialize this library first before usage. To do this, you have to call:
```typescript
import { IWebCamsService, WebCamConfiguration } from 'lavva.exalushome.webcams/build/js/IWebCamsService';
import { WebCamsService } from 'lavva.exalushome.webcams';
WebCamsService.Init();
```
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.
```typescript
let cams = Api.Get<IWebCamsService>(WebCamsService.ServiceName);
```
```html
<video id="webCam" autoPlay playsInline muted controls style="width: 100%"></video>
```
You can do this like that:
```typescript
// 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;
```