npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-webrtc-lib

v18.1.0

Published

Angular microapp/library for video conference using agora-rtc-sdk-ng.

Downloads

493

Readme

ngx-webrtc-lib

https://nodei.co/npm/ngx-webrtc-lib.png?downloads=true&downloadRank=true&stars=true

npm version npm downloads Build Status codecov

Angular microapp/library for Agora WebRTC client from Agora.io using agora-rtc-sdk-ng.

This library was generated with Angular CLI version 12.2.0.

Prerequisites

To get started with Agora, follow this guide to retrieve the AppID.

Installation

Install ngx-webrtc-lib from npm:

npm install ngx-webrtc-lib --save

Standalone Component support

To use the library in standalone mode, follow these steps:

Provide WebRtc configuration in app.configs.ts file

import { provideWebRtc } from 'ngx-webrtc-lib';

export const appConfig: ApplicationConfig = {
  providers: [
    provideWebRtc({
      AppID: 'Agora AppID',
    }),
    // Other providers
  ],
};

Import WebRtcComponent into the host component's imports:

import { WebRtcComponent } from 'ngx-webrtc-lib';

@Component({
  standalone: true,
  imports: [
    WebRtcComponent,
  ],
  ...
})
export class HostComponent {
  // Host component logic
}

NgModule support

To use the library with NgModules, import WebRtcModule into your module's imports:

import { WebRtcModule } from 'ngx-webrtc-lib';

@NgModule({
  ...
  imports: [
    WebRtcModule.forRoot({
      AppID: 'Agora AppID',
    }),
  ]
  ...
})

Basic usage

Add WebRtcComponent to your component template:

<ngx-webrtc
  [channel]="channel"
  [displaySmallScreen]="true"
  [debug]="true"
  [uid]="uid"
  [token]="token"
  (callEnd)="onCallEnd()"
></ngx-webrtc>

Advanced usage

The library allows you to display a video call confirmation dialog. To use the dialog service:

  1. Inject VideoCallDialogService into your component or service.
  2. Call the open method with the required data.

This returns VideoCallDialog object with an API that allows you to:

  • Programmatically close the dialog
  • Accept the call, which will open WebRtcComponent
  • Subscribe to the dialog state
import { VideoCallDialogService, VideoCallDialogData } from 'ngx-webrtc-lib';

constructor(private dialogService: VideoCallDialogService) { }

onDialogOpen(): void {
  const dialog = this.dialogService.open({
    uid: this.uid,
    token: this.token,
    channel: this.channelId,
    outcome: this.outcome,
    user: this.user,
  });

  setTimeout(() => dialog.close(), 7000);
  dialog.afterConfirmation().subscribe((data: VideoCallDialogData) => console.log(data));
}

Import assets in your angular.json file

"assets": [
  {
    "glob": "**/*",
    "input": "./node_modules/ngx-webrtc-lib/src/assets/",
    "output": "./assets/"
  }
],

For real-life video call confirmation behavior with multiple clients, where one client declines the call, and the result immediately reflects on the other clients, you need to implement your own custom solution. This is an example of the implementation using web-sockets.

How to build lib for development

git clone https://github.com/TarasMoskovych/ngx-webrtc.git
cd ngx-webrtc
npm ci
npm start

Compatibility

To use this library, please follow the versioning specified in the following table.

| ngx-webrtc-lib| Angular | NodeJS | --------------- | ------------| --------------------------------------| | ~~1.x~~ | ^12.2.0 | ^12.14.0 || ^14.15.0 | | ~~2.x~~ | ^12.2.0 | ^12.14.0 || ^14.15.0 | | 3.x | ^12.2.0 | ^12.14.0 || ^14.15.0 | | 13.x | ~13.4.0 | ^12.20.0 || ^14.15.0 || ^16.10.0 | | 14.x | ^14.3.0 | ^14.15.0 || ^16.10.0 | | 15.x | ^15.2.10 | ^14.20.0 || ^16.13.0 || ^18.10.0 | | 16.x | ^16.2.10 | ^16.14.0 || ^18.10.0 | | 17.x | ^17.1.2 | ^18.13.0 || ^20.9.0 | | 18.x | ^18.2.10 | ^18.19.1 || ^20.11.1 || ^22.0.0 |

API reference

WebRtcComponent

| Name | Description | | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | @Input() uid: string | User identifier. | | @Input() token: string | Agora token for Secure Authentication. Default value null | | @Input() channel: string | Channel identifier. | | @Input() debug: boolean | Enable debugging. Default value false | | @Input() displaySmallScreen: boolean | Display small screen toggle. Default value false | | @Output() callEnd: EventEmitter | Event that is emitted when the call is ended. |

VideoCallDialogService

| Name | Description | | -------------------------------------------------- | -------------------------------------------- | | open: (VideoCallDialogData) => VideoCallDialog | Renders VideoCallComponent in the dialog. |

VideoCallDialogData

| Name | Description | | ---------------------| ----------------------------------------------------------------------------------------------------------------------------------------- | | uid: string | User identifier. | | channel: string | Channel identifier. | | token: string | Agora token for Secure Authentication. Default value null | | outcome: boolean | Defines the UI for incoming or outgoing call modes. | | user: User | User name and photo URL. |

VideoCallDialog

| Name | Description | | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | acceptCall: () => void | Closes the confirmation dialog and opens WebRtcComponent with passed data before. | | close: () => void | Closes the dialog with video-call confirmation component. | | afterConfirmation: () => Observable<VideoCallDialogData | null>; | Returns Observable with the data depends on accepting or declining the call. | | afterCallEnd: () => Observable; | Returns Observable with the value when the call is ended. |