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

angular-openvidu

v0.8.0

Published

Simple, robust, OpenVidu room videochat component for Angular

Downloads

34

Readme

openvidu-template

Table of contents

About

openvidu-template is a directive which provides most of the logic behind AngularOpenVidu. It exports properties, methods and events to let you implement your own videochat layout.

Selector

  • openvidu-template

Properties

| Name | Type | Optional | Description | |---|---|---|---| | wsUrl | String | required | Websocket URL pointing to your [OpenVidu Server][openvidu-server] | | sessionId | String | required | An id for a session | | participantId | String | required | An id for the current participant joining the session | | micEnabled | Boolean | optional | A boolean to enable/disable the current participant's microphone | | camEnabled | Boolean | optional | A boolean to enable/disable the current participant's camera |

Methods

To call these methods, use the exported API named openviduApi.

| Name | Params | Description | |---|---|---| | sendMessage | (text: string) | Broadcast a text message to all participants (including the sender) | | leaveRoom | () | Disconnect from the room |

Events

These events are coming from openvidu-browser, AngularOpenVidu uses them to implement the logic.

These are the events AngularOpenVidu exposes for the user of the module.

| Name | Params | Description | |---|---|---| | onRoomConnected | ({session: Session}) | triggers when the client has established a session with the server | | onErrorRoom | ({error: any}) | triggers when there's an error, like a "time out" with the server | | onLeaveRoom | No params | triggers when the current user leaves the room | | onErrorMedia | ({error: any}) | triggers when an error occurs while trying to retrieve some media | | onLostConnection | No params | triggers when you can't establish a connection to the server | | onNewMessage | ({session: Session, participant: Participant, message: string}) | triggers when a message from a participant is received | | onParticipantJoined | ({participant: Participant}) | triggers when a participant has joined your room | | onParticipantLeft | ({participant: Participant}) | triggers when a participant has left your room | | onRoomClosed | No params | triggers when the admin closes the room | | onParticipantEvicted | ({participant: Participant}) | triggers when a participant is evicted | | onParticipantPublished | ({participant: Participant}) | triggers when a participant has published | | onStreamAdded | ({stream: Stream}) | triggers when a new stream has been added to the room | | onStreamRemoved | ({stream: Stream}) | triggers when a stream has been removed from the room | | onUpdateMainSpeaker | ({stream: Stream}) | triggers when a participant is set to be the main speaker, based on the audio | | onCustomNotification | (customObject) | triggers when a custom notification from a participant is received | | onServerConnected | No params | triggers when a the client has established a connection with the server | | onErrorServer | ({error: any}) | triggers when the client couldn't establish a connection with the server | | onCameraAccessChange | ({access: boolean, camera?: Stream, error?: any) | triggers when the access to the camera of the client has change. access is true if we have permissions to access the user's camera. If yes then camera will be sent. If not, error will be set with an object Error and camera will be null. |

Create your own layout

First, follow the installation steps at this README. Then continue with these steps:

  1. Add openvidu-template with the required properties to your current app template:

    <openvidu-template
    	[wsUrl]="wsUrl" [sessionId]="sessionId" [participantId]="participantId">
    	...
    </openvidu-template>
  2. You can now build your template between the openvidu-template tags.

    <openvidu-template
    	[wsUrl]="wsUrl" [sessionId]="sessionId" [participantId]="participantId"
    	(onRoomConnected)="myRoomConnectedHandler($event)">
    
    	<mat-toolbar>My app</mat-toolbar>
    
    	<my-custom-stream *ngFor="let s of streams" [stream]="s"></my-custom-stream>
    
    </openvidu-template>

    NOTE:

    When starting to create your own layout, keep in mind that you will need to show streams (videos) of the participants.

    To do this, the clean way is to create a new component to display each stream (with a separate stylesheet).

    You can get a WebRTC URL pointing to the participant's stream like this:

    let videoURL = URL.createObjectURL(this.streamObject.getWrStream())

    To display it, just insert that videoURL as src attribute in an HTML video tag.

    You can take a look at how OpenViduHangoutsComponent does it.

  3. Use the openviduApi in your template or in your code to implement your logic. For example:

    <openvidu-template
    	#openviduApi="openviduApi"
    	[wsUrl]="wsUrl" [sessionId]="sessionId" [participantId]="participantId"
    	(onRoomConnected)="myRoomConnectedHandler($event)">
    	...
    	<button (click)="openvdiuApi.micEnabled = !openviduApu.micEnabled">
    		<span [hidden]="!openviduApi.micEnabled">Mute mic</span>
    		<span [hidden]="openviduApi.micEnabled">Unmute mic</span>
    	</button>
    	...
    </openvidu-template>

    or

    import { OpenViduDirective } from 'angular-openvidu';
    
    export class MyComponent {
    	...
    	// OpenVidu api
    	@ViewChild('openviduApi') openviduApi: OpenViduDirective;
    
    	toggleMic() {
    		this.openvdiuApi.micEnabled = !this.openviduApu.micEnabled;
    	}
    	...
    }

For a real-world implementation of a custom component, take a look at the source for the OpenViduHangoutsComponent.

Example

This is an example of a template:

<openvidu-template
	#openviduApi="openviduApi"
	[wsUrl]="wsUrl" [sessionId]="sessionId" [participantId]="participantId"
	(eventName)="myEventHandler($event)">

	<mat-toolbar>My app</mat-toolbar>

	<my-custom-stream *ngFor="let s of streams" [stream]="s"></my-custom-stream>

	<button (click)="openvdiuApi.micEnabled = !openviduApu.micEnabled">
		<span [hidden]="!openviduApi.micEnabled">Mute mic</span>
		<span [hidden]="openviduApi.micEnabled">Unmute mic</span>
	</button>

</openvidu-template>