You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ngx-webrtc-lib

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-webrtc-lib

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

3.2.1
v3-lts
Source
npmnpm
Version published
Weekly downloads
10
-23.08%
Maintainers
1
Weekly downloads
 
Created
Source

ngx-webrtc-lib

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.

Installation

Install ngx-webrtc-lib from npm:

npm install ngx-webrtc-lib

Add wanted package to NgModule imports:

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

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

You can get started with Agora by following this guide and retrieve the Appid.

Basic usage

Add WebRtcComponent to your component template:

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

Advanced usage

The library allows you to display a video call confirmation dialog. Inject VideoCallDialogService into your component/service and call open method by passing the required data. It will return a dialog object VideoCallDialog with an API where you can programmatically close the dialog, accept the call (it will open WebRtcComponent) and 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,
    remoteUser: this.remoteUser,
    localUser: this.localUser,
  });

  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 the real-life video call confirmation behavior with multiple clients where one declines the call and it immediately reflects on the second client, 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.

Angular Versionngx-webrtc-lib Version
12.x1.x / 2.x / 3.x

API reference

AgoraConfig

NameDescription
AppIDThe App ID provided by Agora to initialize the Agora SDK.
debugEnable debugging for Agora SDK. Default value false
useVirtualBackgroundEnable Agora Virtual Background feature (only the "blur" is currently supported). Default value false

WebRtcComponent

NameDescription
@Input() uid: stringUser identifier.
@Input() token: stringAgora token for Secure Authentication. Default value null
@Input() channel: stringChannel identifier.
@Input() displaySmallScreen: booleanDisplay small screen toggle. Default value false
@Input() remoteUser: UserRepresents the remote user in the call. Optional, used for reference or display purposes.
@Input() localUser: UserRepresents the current user in the call. Optional, used for reference or display purposes.
@Output() callEnd: EventEmitterEvent that is emitted when the call is ended.

VideoCallDialogService

NameDescription
open: (VideoCallDialogData) => VideoCallDialogRenders VideoCallComponent in the dialog.

VideoCallDialogData

NameDescription
uid: stringUser identifier.
channel: stringChannel identifier.
token: stringAgora token for Secure Authentication. Default value null
outcome: booleanDefines the UI for incoming or outgoing call modes.
remoteUser: UserRepresents the remote user in the call. It replaces the user field and should be used instead.
localUser: UserRepresents the current user in the call. Optional, used for reference or display purposes.

VideoCallDialog

NameDescription
acceptCall: () => voidCloses the confirmation dialog and opens WebRtcComponent with passed data before.
close: () => voidCloses 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.

User

NameDescription
name: stringThe name of the user.
photoURL: stringThe URL of the user's profile photo.

Keywords

angular

FAQs

Package last updated on 18 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts