mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: new event documentation
parent
58edee6b97
commit
c30091ee06
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* (C) Copyright 2017-2020 OpenVidu (https://openvidu.io)
|
* (C) Copyright 2017-2022 OpenVidu (https://openvidu.io)
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,8 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Event as Event } from '../OpenViduInternal/Events/Event';
|
import { Event as Event } from '../OpenViduInternal/Events/Event';
|
||||||
import { SessionEventMap } from '../OpenViduInternal/Events/EventMap/SessionEventMap';
|
import { EventMap } from '../OpenViduInternal/Events/EventMap/EventMap';
|
||||||
import { StreamManagerEventMap } from '../OpenViduInternal/Events/EventMap/StreamManagerEventMap';
|
|
||||||
|
|
||||||
import EventEmitter = require('wolfy87-eventemitter');
|
import EventEmitter = require('wolfy87-eventemitter');
|
||||||
import { OpenViduLogger } from '../OpenViduInternal/Logger/OpenViduLogger';
|
import { OpenViduLogger } from '../OpenViduInternal/Logger/OpenViduLogger';
|
||||||
|
@ -43,21 +42,21 @@ export abstract class EventDispatcher {
|
||||||
*
|
*
|
||||||
* @returns The EventDispatcher object
|
* @returns The EventDispatcher object
|
||||||
*/
|
*/
|
||||||
abstract on<K extends keyof (SessionEventMap | StreamManagerEventMap)>(type: K, handler: (event: (SessionEventMap | StreamManagerEventMap)[K]) => void): this;
|
abstract on<K extends keyof (EventMap)>(type: K, handler: (event: (EventMap)[K]) => void): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds function `handler` to handle event `type` just once. The handler will be automatically removed after first execution
|
* Adds function `handler` to handle event `type` just once. The handler will be automatically removed after first execution
|
||||||
*
|
*
|
||||||
* @returns The object that dispatched the event
|
* @returns The object that dispatched the event
|
||||||
*/
|
*/
|
||||||
abstract once<K extends keyof (SessionEventMap | StreamManagerEventMap)>(type: K, handler: (event: (SessionEventMap | StreamManagerEventMap)[K]) => void): this;
|
abstract once<K extends keyof (EventMap)>(type: K, handler: (event: (EventMap)[K]) => void): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a `handler` from event `type`. If no handler is provided, all handlers will be removed from the event
|
* Removes a `handler` from event `type`. If no handler is provided, all handlers will be removed from the event
|
||||||
*
|
*
|
||||||
* @returns The object that dispatched the event
|
* @returns The object that dispatched the event
|
||||||
*/
|
*/
|
||||||
abstract off<K extends keyof (SessionEventMap | StreamManagerEventMap)>(type: K, handler?: (event: (SessionEventMap | StreamManagerEventMap)[K]) => void): this;
|
abstract off<K extends keyof (EventMap)>(type: K, handler?: (event: (EventMap)[K]) => void): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
|
|
|
@ -39,17 +39,9 @@ const logger: OpenViduLogger = OpenViduLogger.getInstance();
|
||||||
let platform: PlatformUtils;
|
let platform: PlatformUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packs local media streams. Participants can publish it to a session. Initialized with [[OpenVidu.initPublisher]] method
|
* Packs local media streams. Participants can publish it to a session. Initialized with [[OpenVidu.initPublisher]] method.
|
||||||
*
|
*
|
||||||
* ### Available event listeners (and events dispatched)
|
* See available event listeners at [[PublisherEventMap]].
|
||||||
*
|
|
||||||
* - accessAllowed
|
|
||||||
* - accessDenied
|
|
||||||
* - accessDialogOpened
|
|
||||||
* - accessDialogClosed
|
|
||||||
* - streamCreated ([[StreamEvent]])
|
|
||||||
* - streamDestroyed ([[StreamEvent]])
|
|
||||||
* - _All events inherited from [[StreamManager]] class_
|
|
||||||
*/
|
*/
|
||||||
export class Publisher extends StreamManager {
|
export class Publisher extends StreamManager {
|
||||||
|
|
||||||
|
|
|
@ -67,24 +67,7 @@ let platform: PlatformUtils;
|
||||||
* Participants who publish their videos to a session can be seen by the rest of users connected to that specific session.
|
* Participants who publish their videos to a session can be seen by the rest of users connected to that specific session.
|
||||||
* Initialized with [[OpenVidu.initSession]] method.
|
* Initialized with [[OpenVidu.initSession]] method.
|
||||||
*
|
*
|
||||||
* ### Available event listeners (and events dispatched)
|
* See available event listeners at [[SessionEventMap]].
|
||||||
*
|
|
||||||
* - connectionCreated ([[ConnectionEvent]])
|
|
||||||
* - connectionDestroyed ([[ConnectionEvent]])
|
|
||||||
* - connectionPropertyChanged ([[ConnectionPropertyChangedEvent]]) <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
|
|
||||||
* - sessionDisconnected ([[SessionDisconnectedEvent]])
|
|
||||||
* - streamCreated ([[StreamEvent]])
|
|
||||||
* - streamDestroyed ([[StreamEvent]])
|
|
||||||
* - streamPropertyChanged ([[StreamPropertyChangedEvent]])
|
|
||||||
* - publisherStartSpeaking ([[PublisherSpeakingEvent]])
|
|
||||||
* - publisherStopSpeaking ([[PublisherSpeakingEvent]])
|
|
||||||
* - signal ([[SignalEvent]])
|
|
||||||
* - recordingStarted ([[RecordingEvent]])
|
|
||||||
* - recordingStopped ([[RecordingEvent]])
|
|
||||||
* - networkQualityLevelChanged ([[NetworkQualityLevelChangedEvent]])
|
|
||||||
* - reconnecting
|
|
||||||
* - reconnected
|
|
||||||
* - exception ([[ExceptionEvent]])
|
|
||||||
*/
|
*/
|
||||||
export class Session extends EventDispatcher {
|
export class Session extends EventDispatcher {
|
||||||
|
|
||||||
|
|
|
@ -45,16 +45,7 @@ let platform: PlatformUtils;
|
||||||
* want to directly manage your own video elements (even more than one video element per Stream). This scenario is pretty common in
|
* want to directly manage your own video elements (even more than one video element per Stream). This scenario is pretty common in
|
||||||
* declarative, MVC frontend frameworks such as Angular, React or Vue.js
|
* declarative, MVC frontend frameworks such as Angular, React or Vue.js
|
||||||
*
|
*
|
||||||
* ### Available event listeners (and events dispatched)
|
* See available event listeners at [[StreamManagerEventMap]].
|
||||||
*
|
|
||||||
* - videoElementCreated ([[VideoElementEvent]])
|
|
||||||
* - videoElementDestroyed ([[VideoElementEvent]])
|
|
||||||
* - streamPlaying ([[StreamManagerEvent]])
|
|
||||||
* - streamPropertyChanged ([[StreamPropertyChangedEvent]])
|
|
||||||
* - publisherStartSpeaking ([[PublisherSpeakingEvent]])
|
|
||||||
* - publisherStopSpeaking ([[PublisherSpeakingEvent]])
|
|
||||||
* - streamAudioVolumeChange ([[StreamManagerEvent]])
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
export class StreamManager extends EventDispatcher {
|
export class StreamManager extends EventDispatcher {
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,7 @@ const logger: OpenViduLogger = OpenViduLogger.getInstance();
|
||||||
/**
|
/**
|
||||||
* Packs remote media streams. Participants automatically receive them when others publish their streams. Initialized with [[Session.subscribe]] method
|
* Packs remote media streams. Participants automatically receive them when others publish their streams. Initialized with [[Session.subscribe]] method
|
||||||
*
|
*
|
||||||
* ### Available event listeners (and events dispatched)
|
* See available event listeners at [[StreamManagerEventMap]].
|
||||||
*
|
|
||||||
* - _All events inherited from [[StreamManager]] class_
|
|
||||||
*/
|
*/
|
||||||
export class Subscriber extends StreamManager {
|
export class Subscriber extends StreamManager {
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ import { Session } from '../../OpenVidu/Session';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the following events:
|
* Triggered by:
|
||||||
* - `connectionCreated`: dispatched by [[Session]] after a new user has connected to the session
|
* - [[connectionCreated]]
|
||||||
* - `connectionDestroyed`: dispatched by [[Session]] after a new user has left the session
|
* - [[connectionDestroyed]]
|
||||||
*/
|
*/
|
||||||
export class ConnectionEvent extends Event {
|
export class ConnectionEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,7 @@ import { Event } from './Event';
|
||||||
/**
|
/**
|
||||||
* **This feature is part of OpenVidu Pro tier** <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
|
* **This feature is part of OpenVidu Pro tier** <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
|
||||||
*
|
*
|
||||||
* Defines event `connectionPropertyChanged` dispatched by [[Session]] object.
|
* Triggered by [[connectionPropertyChanged]]
|
||||||
* This event is fired when any property of the local [[Connection]] object changes.
|
|
||||||
* The properties that may change are [[Connection.role]] and [[Connection.record]].
|
|
||||||
*
|
|
||||||
* The only way the Connection properties may change is by updating them through:
|
|
||||||
*
|
|
||||||
* - [API REST](/en/stable/reference-docs/REST-API/#patch-connection)
|
|
||||||
* - [openvidu-java-client](/en/stable/reference-docs/openvidu-java-client/#update-a-connection)
|
|
||||||
* - [openvidu-node-client](/en/stable/reference-docs/openvidu-node-client/#update-a-connection)<br><br>
|
|
||||||
*/
|
*/
|
||||||
export class ConnectionPropertyChangedEvent extends Event {
|
export class ConnectionPropertyChangedEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2017-2022 OpenVidu (https://openvidu.io)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All OpenVidu Browser events inherit from this interface
|
||||||
|
*/
|
||||||
|
export interface EventMap { }
|
|
@ -1,11 +1,71 @@
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2017-2022 OpenVidu (https://openvidu.io)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
import { StreamEvent } from '../StreamEvent';
|
import { StreamEvent } from '../StreamEvent';
|
||||||
import { StreamManagerEventMap } from './StreamManagerEventMap';
|
import { StreamManagerEventMap } from './StreamManagerEventMap';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events dispatched by [[Publisher]] object. Manage event listeners with
|
||||||
|
* [[Publisher.on]], [[Publisher.once]] and [[Publisher.off]] methods.
|
||||||
|
*/
|
||||||
export interface PublisherEventMap extends StreamManagerEventMap {
|
export interface PublisherEventMap extends StreamManagerEventMap {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the [[Publisher]] has been published to the session (see [[Session.publish]]).
|
||||||
|
*/
|
||||||
streamCreated: StreamEvent;
|
streamCreated: StreamEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the [[Publisher]] has been unpublished from the session.
|
||||||
|
*/
|
||||||
streamDestroyed: StreamEvent;
|
streamDestroyed: StreamEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a Publisher tries to access some media input device and has the required permissions to do so.
|
||||||
|
*
|
||||||
|
* This happens when calling [[OpenVidu.initPublisher]] or [[OpenVidu.initPublisherAsync]] and the application
|
||||||
|
* has permissions to use the devices. This usually means the user has accepted the permissions dialog that the
|
||||||
|
* browser will show when trying to access the camera/microphone/screen.
|
||||||
|
*/
|
||||||
accessAllowed: never;
|
accessAllowed: never;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a Publisher tries to access some media input device and does NOT have the required permissions to do so.
|
||||||
|
*
|
||||||
|
* This happens when calling [[OpenVidu.initPublisher]] or [[OpenVidu.initPublisherAsync]] and the application
|
||||||
|
* lacks the required permissions to use the devices. This usually means the user has NOT accepted the permissions dialog that the
|
||||||
|
* browser will show when trying to access the camera/microphone/screen.
|
||||||
|
*/
|
||||||
accessDenied: never;
|
accessDenied: never;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the pop-up shown by the browser to request permissions for the input media devices is opened.
|
||||||
|
*
|
||||||
|
* You can use this event to alert the user about granting permissions for your website. Note that this event is artificially
|
||||||
|
* generated based only on time intervals when accessing media devices. A heavily overloaded client device that simply takes more
|
||||||
|
* than usual to access the media device could produce a false trigger of this event.
|
||||||
|
*/
|
||||||
accessDialogOpened: never;
|
accessDialogOpened: never;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched after the user clicks on "Allow" or "Block" in the pop-up shown by the browser to request permissions
|
||||||
|
* for the input media devices.
|
||||||
|
*
|
||||||
|
* This event can only be triggered after an [[accessDialogOpened]] event has been previously triggered.
|
||||||
|
*/
|
||||||
accessDialogClosed: never;
|
accessDialogClosed: never;
|
||||||
}
|
}
|
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2017-2022 OpenVidu (https://openvidu.io)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { EventMap } from './EventMap';
|
||||||
import { ConnectionEvent } from '../ConnectionEvent';
|
import { ConnectionEvent } from '../ConnectionEvent';
|
||||||
import { ConnectionPropertyChangedEvent } from '../ConnectionPropertyChangedEvent';
|
import { ConnectionPropertyChangedEvent } from '../ConnectionPropertyChangedEvent';
|
||||||
import { ExceptionEvent } from '../ExceptionEvent';
|
import { ExceptionEvent } from '../ExceptionEvent';
|
||||||
|
@ -9,25 +27,148 @@ import { SignalEvent } from '../SignalEvent';
|
||||||
import { StreamEvent } from '../StreamEvent';
|
import { StreamEvent } from '../StreamEvent';
|
||||||
import { StreamPropertyChangedEvent } from '../StreamPropertyChangedEvent';
|
import { StreamPropertyChangedEvent } from '../StreamPropertyChangedEvent';
|
||||||
|
|
||||||
export interface SessionEventMap {
|
/**
|
||||||
|
* Events dispatched by [[Session]] object. Manage event listeners with
|
||||||
|
* [[Session.on]], [[Session.once]] and [[Session.off]] methods.
|
||||||
|
*/
|
||||||
|
export interface SessionEventMap extends EventMap {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a new user has connected to the session.
|
||||||
|
*
|
||||||
|
* It is fired for both the local user and remote users.
|
||||||
|
*/
|
||||||
connectionCreated: ConnectionEvent;
|
connectionCreated: ConnectionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a remote user has left the session.
|
||||||
|
*
|
||||||
|
* For the local user see [[sessionDisconnected]].
|
||||||
|
*/
|
||||||
connectionDestroyed: ConnectionEvent;
|
connectionDestroyed: ConnectionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* **This feature is part of OpenVidu Pro tier** <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
|
||||||
|
*
|
||||||
|
* Event dispatched when a property of the local [[Connection]] object changes.
|
||||||
|
*
|
||||||
|
* It is fired only for the local user.
|
||||||
|
*
|
||||||
|
* The properties that may change are [[Connection.role]] and [[Connection.record]].
|
||||||
|
* The only way the Connection properties may change is by updating them through:
|
||||||
|
*
|
||||||
|
* - [API REST](/en/stable/reference-docs/REST-API/#patch-connection)
|
||||||
|
* - [openvidu-java-client](/en/stable/reference-docs/openvidu-java-client/#update-a-connection)
|
||||||
|
* - [openvidu-node-client](/en/stable/reference-docs/openvidu-node-client/#update-a-connection)<br><br>
|
||||||
|
*/
|
||||||
connectionPropertyChanged: ConnectionPropertyChangedEvent;
|
connectionPropertyChanged: ConnectionPropertyChangedEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the local user has left the session.
|
||||||
|
*
|
||||||
|
* For remote users see [[connectionDestroyed]].
|
||||||
|
*/
|
||||||
sessionDisconnected: SessionDisconnectedEvent;
|
sessionDisconnected: SessionDisconnectedEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a user has started publishing media to the session (see [[Session.publish]]).
|
||||||
|
*
|
||||||
|
* It is fired for both the local user and remote users.
|
||||||
|
*/
|
||||||
streamCreated: StreamEvent;
|
streamCreated: StreamEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a user stops publishing media to the session.
|
||||||
|
*
|
||||||
|
* It is fired for both the local user and remote users.
|
||||||
|
*/
|
||||||
streamDestroyed: StreamEvent;
|
streamDestroyed: StreamEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a Stream undergoes any change in any of its mutable properties
|
||||||
|
* (see [[StreamPropertyChangedEvent.changedProperty]]).
|
||||||
|
*
|
||||||
|
* It is fired for both remote streams (owned by a [[Subscriber]]) or local streams (owned by a [[Publisher]]).
|
||||||
|
*/
|
||||||
streamPropertyChanged: StreamPropertyChangedEvent;
|
streamPropertyChanged: StreamPropertyChangedEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a user has started speaking.
|
||||||
|
*
|
||||||
|
* It is fired for both the local user and remote users.
|
||||||
|
*
|
||||||
|
* Extra information:
|
||||||
|
* - This event will only be triggered for **streams that have audio tracks** ([[Stream.hasAudio]] must be true).
|
||||||
|
* - Further configuration can be applied on how the event is dispatched by setting property `publisherSpeakingEventsOptions` in the call of [[OpenVidu.setAdvancedConfiguration]].
|
||||||
|
*/
|
||||||
publisherStartSpeaking: PublisherSpeakingEvent;
|
publisherStartSpeaking: PublisherSpeakingEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a user has stopped speaking.
|
||||||
|
*
|
||||||
|
* It is fired for both the local user and remote users.
|
||||||
|
*
|
||||||
|
* Extra information:
|
||||||
|
* - This event will only be triggered for **streams that have audio tracks** ([[Stream.hasAudio]] must be true).
|
||||||
|
* - Further configuration can be applied on how the event is dispatched by setting property `publisherSpeakingEventsOptions` in the call of [[OpenVidu.setAdvancedConfiguration]].
|
||||||
|
*/
|
||||||
publisherStopSpeaking: PublisherSpeakingEvent;
|
publisherStopSpeaking: PublisherSpeakingEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
[key: `signal:${string}`]: SignalEvent;
|
[key: `signal:${string}`]: SignalEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a signal is received (see [Send text messages between users](/en/stable/cheatsheet/send-messages)).
|
||||||
|
*
|
||||||
|
* If the listener is added as **`signal:TYPE`**, only signals of type **`TYPE`** will trigger the event.
|
||||||
|
*/
|
||||||
signal: SignalEvent;
|
signal: SignalEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the session has started being recorded.
|
||||||
|
*
|
||||||
|
* Property **`OPENVIDU_RECORDING_NOTIFICATION`** of [OpenVidu Server configuration](/en/stable/reference-docs/openvidu-config/)
|
||||||
|
* defines which users should receive this events (by default, only users with role `PUBLISHER` or `MODERATOR`)
|
||||||
|
*/
|
||||||
recordingStarted: RecordingEvent;
|
recordingStarted: RecordingEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the session has stopped being recorded.
|
||||||
|
*
|
||||||
|
* Property **`OPENVIDU_RECORDING_NOTIFICATION`** of [OpenVidu Server configuration](/en/stable/reference-docs/openvidu-config/)
|
||||||
|
* defines which users should receive this events (by default, only users with role `PUBLISHER` or `MODERATOR`)
|
||||||
|
*/
|
||||||
recordingStopped: RecordingEvent;
|
recordingStopped: RecordingEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* **This feature is part of OpenVidu Pro tier** <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
|
||||||
|
*
|
||||||
|
* Event dispatched when the network quality level of a [[Connection]] changes. See [network quality](/en/stable/advanced-features/network-quality/).
|
||||||
|
*/
|
||||||
networkQualityLevelChanged: NetworkQualityLevelChangedEvent;
|
networkQualityLevelChanged: NetworkQualityLevelChangedEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the local user has lost its connection to the session, and starts the automatic reconnection process.
|
||||||
|
*
|
||||||
|
* See [Reconnection events](/en/stable/advanced-features/automatic-reconnection/#reconnection-events).
|
||||||
|
*/
|
||||||
reconnecting: never;
|
reconnecting: never;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the local user has successfully recovered its connection to the session after losing it.
|
||||||
|
*
|
||||||
|
* If the connection was recovered but OpenVidu Server already evicted the user due to timeout, then this event will
|
||||||
|
* not be dispatched. A [[sessionDisconnected]] event with reason `networkDisconnect` will be triggered instead.
|
||||||
|
*
|
||||||
|
* See [Reconnection events](/en/stable/advanced-features/automatic-reconnection/#reconnection-events).
|
||||||
|
*/
|
||||||
reconnected: never;
|
reconnected: never;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This event acts as a global handler for asynchronous errors that may be triggered for multiple reasons and from multiple origins.
|
||||||
|
* To see the different types of exceptions go to [[ExceptionEventName]].
|
||||||
|
*/
|
||||||
exception: ExceptionEvent;
|
exception: ExceptionEvent;
|
||||||
}
|
}
|
|
@ -1,14 +1,81 @@
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2017-2022 OpenVidu (https://openvidu.io)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { EventMap } from './EventMap';
|
||||||
import { PublisherSpeakingEvent } from '../PublisherSpeakingEvent';
|
import { PublisherSpeakingEvent } from '../PublisherSpeakingEvent';
|
||||||
import { StreamManagerEvent } from '../StreamManagerEvent';
|
import { StreamManagerEvent } from '../StreamManagerEvent';
|
||||||
import { StreamPropertyChangedEvent } from '../StreamPropertyChangedEvent';
|
import { StreamPropertyChangedEvent } from '../StreamPropertyChangedEvent';
|
||||||
import { VideoElementEvent } from '../VideoElementEvent';
|
import { VideoElementEvent } from '../VideoElementEvent';
|
||||||
|
|
||||||
export interface StreamManagerEventMap {
|
/**
|
||||||
|
* Events dispatched by [[StreamManager]] object. Manage event listeners with
|
||||||
|
* [[StreamManager.on]], [[StreamManager.once]] and [[StreamManager.off]] methods.
|
||||||
|
*/
|
||||||
|
export interface StreamManagerEventMap extends EventMap {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a new HTML video element has been inserted into DOM by OpenVidu Browser library. See
|
||||||
|
* [Manage video players](/en/stable/cheatsheet/manage-videos) section.
|
||||||
|
*/
|
||||||
videoElementCreated: VideoElementEvent;
|
videoElementCreated: VideoElementEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when an HTML video element has been removed from DOM by OpenVidu Browser library. See
|
||||||
|
* [Manage video players](/en/stable/cheatsheet/manage-videos) section.
|
||||||
|
*/
|
||||||
videoElementDestroyed: VideoElementEvent;
|
videoElementDestroyed: VideoElementEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the media stream starts playing (one of its videos has media and has begun to play).
|
||||||
|
* This event will be dispatched when these 3 conditions are met:
|
||||||
|
* 1. The StreamManager has no video associated in the DOM.
|
||||||
|
* 2. It is associated to one video.
|
||||||
|
* 3. That video starts playing. Internally the expected Web API event is [HTMLMediaElement.canplay](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canplay_event).
|
||||||
|
*/
|
||||||
streamPlaying: StreamManagerEvent;
|
streamPlaying: StreamManagerEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the volume of the media stream's audio track changes. Only applies if [[Stream.hasAudio]] is `true`.
|
||||||
|
* The frequency this event is fired with is defined by property `interval` of
|
||||||
|
* [[OpenViduAdvancedConfiguration.publisherSpeakingEventsOptions]] (default 100ms)
|
||||||
|
*/
|
||||||
streamAudioVolumeChange: StreamManagerEvent;
|
streamAudioVolumeChange: StreamManagerEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when a Stream undergoes any change in any of its mutable properties
|
||||||
|
* (see [[StreamPropertyChangedEvent.changedProperty]]).
|
||||||
|
*/
|
||||||
streamPropertyChanged: StreamPropertyChangedEvent;
|
streamPropertyChanged: StreamPropertyChangedEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the user owning the stream has started speaking.
|
||||||
|
*
|
||||||
|
* Extra information:
|
||||||
|
* - This event will only be triggered for **streams that have audio tracks** ([[Stream.hasAudio]] must be true).
|
||||||
|
* - Further configuration can be applied on how the event is dispatched by setting property `publisherSpeakingEventsOptions` in the call of [[OpenVidu.setAdvancedConfiguration]].
|
||||||
|
*/
|
||||||
publisherStartSpeaking: PublisherSpeakingEvent;
|
publisherStartSpeaking: PublisherSpeakingEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event dispatched when the user owning the stream has stopped speaking.
|
||||||
|
*
|
||||||
|
* Extra information:
|
||||||
|
* - This event will only be triggered for **streams that have audio tracks** ([[Stream.hasAudio]] must be true).
|
||||||
|
* - Further configuration can be applied on how the event is dispatched by setting property `publisherSpeakingEventsOptions` in the call of [[OpenVidu.setAdvancedConfiguration]].
|
||||||
|
*/
|
||||||
publisherStopSpeaking: PublisherSpeakingEvent;
|
publisherStopSpeaking: PublisherSpeakingEvent;
|
||||||
}
|
}
|
|
@ -84,10 +84,7 @@ export enum ExceptionEventName {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines event `exception` dispatched by [[Session]] object.
|
* Triggered by [[SessionEventMap.exception]]
|
||||||
*
|
|
||||||
* This event acts as a global handler for asynchronous errors that may be triggered for multiple reasons and from multiple origins. To see the different
|
|
||||||
* types of exceptions go to [[ExceptionEventName]].
|
|
||||||
*/
|
*/
|
||||||
export class ExceptionEvent extends Event {
|
export class ExceptionEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,7 @@ import { Session } from '../../OpenVidu/Session';
|
||||||
import { Connection } from '../../OpenVidu/Connection';
|
import { Connection } from '../../OpenVidu/Connection';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* **This feature is part of OpenVidu Pro tier** <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
|
* Triggered by [[networkQualityLevelChanged]]
|
||||||
*
|
|
||||||
* Defines event `networkQualityLevelChanged` dispatched by [[Session]].
|
|
||||||
* This event is fired when the network quality level of a [[Connection]] changes. See [network quality](/en/stable/advanced-features/network-quality/)
|
|
||||||
*/
|
*/
|
||||||
export class NetworkQualityLevelChangedEvent extends Event {
|
export class NetworkQualityLevelChangedEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,9 @@ import { StreamManager } from '../../OpenVidu/StreamManager';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the following events:
|
* Triggered by:
|
||||||
* - `publisherStartSpeaking`: dispatched by [[Session]] and [[StreamManager]] when a user has started speaking
|
* - `publisherStartSpeaking` (available for [Session](/en/stable/api/openvidu-browser/interfaces/SessionEventMap.html#publisherStartSpeaking) and [StreamManager](/en/stable/api/openvidu-browser/interfaces/StreamManagerEventMap.html#publisherStartSpeaking) objects)
|
||||||
* - `publisherStopSpeaking`: dispatched by [[Session]] and [[StreamManager]] when a user has stopped speaking
|
* - `publisherStopSpeaking` (available for [Session](/en/stable/api/openvidu-browser/interfaces/SessionEventMap.html#publisherStopSpeaking) and [StreamManager](/en/stable/api/openvidu-browser/interfaces/StreamManagerEventMap.html#publisherStopSpeaking) objects)
|
||||||
*
|
|
||||||
* More information:
|
|
||||||
* - This events will only be triggered for **streams that have audio tracks** ([[Stream.hasAudio]] must be true)
|
|
||||||
* - You can further configure how the events are dispatched by setting property `publisherSpeakingEventsOptions` in the call of [[OpenVidu.setAdvancedConfiguration]]
|
|
||||||
*/
|
*/
|
||||||
export class PublisherSpeakingEvent extends Event {
|
export class PublisherSpeakingEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,9 @@ import { Session } from '../../OpenVidu/Session';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the following events:
|
* Triggered by:
|
||||||
* - `recordingStarted`: dispatched by [[Session]] after the session has started being recorded
|
* - [[recordingStarted]]
|
||||||
* - `recordingStopped`: dispatched by [[Session]] after the session has stopped being recorded
|
* - [[recordingStopped]]
|
||||||
*
|
|
||||||
* Property **`OPENVIDU_RECORDING_NOTIFICATION`** of [OpenVidu Server configuration](/en/stable/reference-docs/openvidu-config/)
|
|
||||||
* defines which users should receive these events (by default, only users with role `PUBLISHER` or `MODERATOR`)
|
|
||||||
*/
|
*/
|
||||||
export class RecordingEvent extends Event {
|
export class RecordingEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ const logger: OpenViduLogger = OpenViduLogger.getInstance();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines event `sessionDisconnected` dispatched by [[Session]] after the local user has left the session. This is the local version of the `connectionDestroyed` event, which is only dispatched by remote users
|
* Triggered by [[sessionDisconnected]]
|
||||||
*/
|
*/
|
||||||
export class SessionDisconnectedEvent extends Event {
|
export class SessionDisconnectedEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,7 @@ import { Session } from '../../OpenVidu/Session';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the following events:
|
* Triggered by [[SessionEventMap.signal]]
|
||||||
* - `signal`: dispatched by [[Session]] when a signal is received
|
|
||||||
* - `signal:TYPE`: dispatched by [[Session]] when a signal of type TYPE is received
|
|
||||||
*/
|
*/
|
||||||
export class SignalEvent extends Event {
|
export class SignalEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@ import { OpenViduLogger } from '../Logger/OpenViduLogger';
|
||||||
const logger: OpenViduLogger = OpenViduLogger.getInstance();
|
const logger: OpenViduLogger = OpenViduLogger.getInstance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the following events:
|
* Triggered by:
|
||||||
* - `streamCreated`: dispatched by [[Session]] and [[Publisher]] after some user has started publishing to the session
|
* - `streamCreated` (available for [Session](/en/stable/api/openvidu-browser/interfaces/SessionEventMap.html#streamCreated) and [Publisher](/en/stable/api/openvidu-browser/interfaces/PublisherEventMap.html#streamCreated) objects)
|
||||||
* - `streamDestroyed`: dispatched by [[Session]] and [[Publisher]] after some user has stopped publishing to the session
|
* - `streamDestroyed]` (available for [Session](/en/stable/api/openvidu-browser/interfaces/SessionEventMap.html#streamDestroyed) and [Publisher](/en/stable/api/openvidu-browser/interfaces/PublisherEventMap.html#streamDestroyed) objects)
|
||||||
*/
|
*/
|
||||||
export class StreamEvent extends Event {
|
export class StreamEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,9 @@ import { Event } from './Event';
|
||||||
import { StreamManager } from '../../OpenVidu/StreamManager';
|
import { StreamManager } from '../../OpenVidu/StreamManager';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the following events:
|
* Triggered by:
|
||||||
* - `streamPlaying`: dispatched by [[StreamManager]] ([[Publisher]] and [[Subscriber]]) whenever its media stream starts playing (one of its videos has media
|
* - [[streamPlaying]]
|
||||||
* and has begun to play). This event will be dispatched when these 3 conditions are met:
|
* - [[streamAudioVolumeChange]]
|
||||||
* 1. The StreamManager has no video associated in the DOM
|
|
||||||
* 2. It is associated to one video
|
|
||||||
* 3. That video starts playing. Internally the expected Web API event is [HTMLMediaElement.canplay](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canplay_event)
|
|
||||||
* - `streamAudioVolumeChange`: dispatched by [[StreamManager]] ([[Publisher]] and [[Subscriber]]) when the volume of its Stream's audio track
|
|
||||||
* changes. Only applies if [[Stream.hasAudio]] is `true`. The frequency this event is fired with is defined by property `interval` of
|
|
||||||
* [[OpenViduAdvancedConfiguration.publisherSpeakingEventsOptions]] (default 100ms)
|
|
||||||
*/
|
*/
|
||||||
export class StreamManagerEvent extends Event {
|
export class StreamManagerEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,7 @@ import { Stream } from '../../OpenVidu/Stream';
|
||||||
import { StreamManager } from '../../OpenVidu/StreamManager';
|
import { StreamManager } from '../../OpenVidu/StreamManager';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines event `streamPropertyChanged` dispatched by [[Session]] as well as by [[StreamManager]] ([[Publisher]] and [[Subscriber]]).
|
* Triggered by `streamPropertyChanged` (available for [Session](/en/stable/api/openvidu-browser/interfaces/SessionEventMap.html#streamPropertyChanged) and [StreamManager](/en/stable/api/openvidu-browser/interfaces/StreamManagerEventMap.html#streamPropertyChanged) objects)
|
||||||
* This event is fired when any remote stream (owned by a Subscriber) or local stream (owned by a Publisher) undergoes
|
|
||||||
* any change in any of its mutable properties (see [[changedProperty]]).
|
|
||||||
*/
|
*/
|
||||||
export class StreamPropertyChangedEvent extends Event {
|
export class StreamPropertyChangedEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,9 @@ import { StreamManager } from '../../OpenVidu/StreamManager';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the following events:
|
* Triggered by:
|
||||||
* - `videoElementCreated`: dispatched by [[Publisher]] and [[Subscriber]] whenever a new HTML video element has been inserted into DOM by OpenVidu Browser library. See
|
* - [[videoElementCreated]]
|
||||||
* [Manage video players](/en/stable/cheatsheet/manage-videos) section.
|
* - [[videoElementDestroyed]]
|
||||||
* - `videoElementDestroyed`: dispatched by [[Publisher]] and [[Subscriber]] whenever an HTML video element has been removed from DOM by OpenVidu Browser library.
|
|
||||||
*/
|
*/
|
||||||
export class VideoElementEvent extends Event {
|
export class VideoElementEvent extends Event {
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ export { SignalOptions } from './OpenViduInternal/Interfaces/Public/SignalOption
|
||||||
export { StreamManagerVideo } from './OpenViduInternal/Interfaces/Public/StreamManagerVideo';
|
export { StreamManagerVideo } from './OpenViduInternal/Interfaces/Public/StreamManagerVideo';
|
||||||
export { SubscriberProperties } from './OpenViduInternal/Interfaces/Public/SubscriberProperties';
|
export { SubscriberProperties } from './OpenViduInternal/Interfaces/Public/SubscriberProperties';
|
||||||
|
|
||||||
|
export { EventMap } from './OpenViduInternal/Events/EventMap/EventMap';
|
||||||
export { SessionEventMap } from './OpenViduInternal/Events/EventMap/SessionEventMap';
|
export { SessionEventMap } from './OpenViduInternal/Events/EventMap/SessionEventMap';
|
||||||
export { StreamManagerEventMap } from './OpenViduInternal/Events/EventMap/StreamManagerEventMap';
|
export { StreamManagerEventMap } from './OpenViduInternal/Events/EventMap/StreamManagerEventMap';
|
||||||
export { PublisherEventMap } from './OpenViduInternal/Events/EventMap/PublisherEventMap';
|
export { PublisherEventMap } from './OpenViduInternal/Events/EventMap/PublisherEventMap';
|
||||||
|
|
Loading…
Reference in New Issue