From c30091ee066a9bb72eca40f23e18345f3a5baf3e Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Thu, 13 Jan 2022 13:54:34 +0100 Subject: [PATCH] openvidu-browser: new event documentation --- .../src/OpenVidu/EventDispatcher.ts | 11 +- openvidu-browser/src/OpenVidu/Publisher.ts | 12 +- openvidu-browser/src/OpenVidu/Session.ts | 19 +-- .../src/OpenVidu/StreamManager.ts | 11 +- openvidu-browser/src/OpenVidu/Subscriber.ts | 4 +- .../Events/ConnectionEvent.ts | 6 +- .../Events/ConnectionPropertyChangedEvent.ts | 10 +- .../Events/EventMap/EventMap.ts | 21 +++ .../Events/EventMap/PublisherEventMap.ts | 60 ++++++++ .../Events/EventMap/SessionEventMap.ts | 143 +++++++++++++++++- .../Events/EventMap/StreamManagerEventMap.ts | 69 ++++++++- .../OpenViduInternal/Events/ExceptionEvent.ts | 5 +- .../Events/NetworkQualityLevelChangedEvent.ts | 5 +- .../Events/PublisherSpeakingEvent.ts | 10 +- .../OpenViduInternal/Events/RecordingEvent.ts | 9 +- .../Events/SessionDisconnectedEvent.ts | 2 +- .../OpenViduInternal/Events/SignalEvent.ts | 4 +- .../OpenViduInternal/Events/StreamEvent.ts | 6 +- .../Events/StreamManagerEvent.ts | 12 +- .../Events/StreamPropertyChangedEvent.ts | 4 +- .../Events/VideoElementEvent.ts | 7 +- openvidu-browser/src/index.ts | 1 + 22 files changed, 326 insertions(+), 105 deletions(-) create mode 100644 openvidu-browser/src/OpenViduInternal/Events/EventMap/EventMap.ts diff --git a/openvidu-browser/src/OpenVidu/EventDispatcher.ts b/openvidu-browser/src/OpenVidu/EventDispatcher.ts index cb298681..49c467e7 100644 --- a/openvidu-browser/src/OpenVidu/EventDispatcher.ts +++ b/openvidu-browser/src/OpenVidu/EventDispatcher.ts @@ -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"); * 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 { SessionEventMap } from '../OpenViduInternal/Events/EventMap/SessionEventMap'; -import { StreamManagerEventMap } from '../OpenViduInternal/Events/EventMap/StreamManagerEventMap'; +import { EventMap } from '../OpenViduInternal/Events/EventMap/EventMap'; import EventEmitter = require('wolfy87-eventemitter'); import { OpenViduLogger } from '../OpenViduInternal/Logger/OpenViduLogger'; @@ -43,21 +42,21 @@ export abstract class EventDispatcher { * * @returns The EventDispatcher object */ - abstract on(type: K, handler: (event: (SessionEventMap | StreamManagerEventMap)[K]) => void): this; + abstract on(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 * * @returns The object that dispatched the event */ - abstract once(type: K, handler: (event: (SessionEventMap | StreamManagerEventMap)[K]) => void): this; + abstract once(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 * * @returns The object that dispatched the event */ - abstract off(type: K, handler?: (event: (SessionEventMap | StreamManagerEventMap)[K]) => void): this; + abstract off(type: K, handler?: (event: (EventMap)[K]) => void): this; /** * @hidden diff --git a/openvidu-browser/src/OpenVidu/Publisher.ts b/openvidu-browser/src/OpenVidu/Publisher.ts index 6eb3c390..f943ee95 100644 --- a/openvidu-browser/src/OpenVidu/Publisher.ts +++ b/openvidu-browser/src/OpenVidu/Publisher.ts @@ -39,17 +39,9 @@ const logger: OpenViduLogger = OpenViduLogger.getInstance(); 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) - * - * - accessAllowed - * - accessDenied - * - accessDialogOpened - * - accessDialogClosed - * - streamCreated ([[StreamEvent]]) - * - streamDestroyed ([[StreamEvent]]) - * - _All events inherited from [[StreamManager]] class_ + * See available event listeners at [[PublisherEventMap]]. */ export class Publisher extends StreamManager { diff --git a/openvidu-browser/src/OpenVidu/Session.ts b/openvidu-browser/src/OpenVidu/Session.ts index dc738a1a..a69aba03 100644 --- a/openvidu-browser/src/OpenVidu/Session.ts +++ b/openvidu-browser/src/OpenVidu/Session.ts @@ -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. * Initialized with [[OpenVidu.initSession]] method. * - * ### Available event listeners (and events dispatched) - * - * - connectionCreated ([[ConnectionEvent]]) - * - connectionDestroyed ([[ConnectionEvent]]) - * - connectionPropertyChanged ([[ConnectionPropertyChangedEvent]]) PRO - * - sessionDisconnected ([[SessionDisconnectedEvent]]) - * - streamCreated ([[StreamEvent]]) - * - streamDestroyed ([[StreamEvent]]) - * - streamPropertyChanged ([[StreamPropertyChangedEvent]]) - * - publisherStartSpeaking ([[PublisherSpeakingEvent]]) - * - publisherStopSpeaking ([[PublisherSpeakingEvent]]) - * - signal ([[SignalEvent]]) - * - recordingStarted ([[RecordingEvent]]) - * - recordingStopped ([[RecordingEvent]]) - * - networkQualityLevelChanged ([[NetworkQualityLevelChangedEvent]]) - * - reconnecting - * - reconnected - * - exception ([[ExceptionEvent]]) + * See available event listeners at [[SessionEventMap]]. */ export class Session extends EventDispatcher { diff --git a/openvidu-browser/src/OpenVidu/StreamManager.ts b/openvidu-browser/src/OpenVidu/StreamManager.ts index 2770ef83..4b517aa6 100644 --- a/openvidu-browser/src/OpenVidu/StreamManager.ts +++ b/openvidu-browser/src/OpenVidu/StreamManager.ts @@ -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 * declarative, MVC frontend frameworks such as Angular, React or Vue.js * - * ### Available event listeners (and events dispatched) - * - * - videoElementCreated ([[VideoElementEvent]]) - * - videoElementDestroyed ([[VideoElementEvent]]) - * - streamPlaying ([[StreamManagerEvent]]) - * - streamPropertyChanged ([[StreamPropertyChangedEvent]]) - * - publisherStartSpeaking ([[PublisherSpeakingEvent]]) - * - publisherStopSpeaking ([[PublisherSpeakingEvent]]) - * - streamAudioVolumeChange ([[StreamManagerEvent]]) - * + * See available event listeners at [[StreamManagerEventMap]]. */ export class StreamManager extends EventDispatcher { diff --git a/openvidu-browser/src/OpenVidu/Subscriber.ts b/openvidu-browser/src/OpenVidu/Subscriber.ts index 4a5b9e03..9e43c9f0 100644 --- a/openvidu-browser/src/OpenVidu/Subscriber.ts +++ b/openvidu-browser/src/OpenVidu/Subscriber.ts @@ -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 * - * ### Available event listeners (and events dispatched) - * - * - _All events inherited from [[StreamManager]] class_ + * See available event listeners at [[StreamManagerEventMap]]. */ export class Subscriber extends StreamManager { diff --git a/openvidu-browser/src/OpenViduInternal/Events/ConnectionEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/ConnectionEvent.ts index 67e33e22..69ca9ac2 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/ConnectionEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/ConnectionEvent.ts @@ -21,9 +21,9 @@ import { Session } from '../../OpenVidu/Session'; /** - * Defines the following events: - * - `connectionCreated`: dispatched by [[Session]] after a new user has connected to the session - * - `connectionDestroyed`: dispatched by [[Session]] after a new user has left the session + * Triggered by: + * - [[connectionCreated]] + * - [[connectionDestroyed]] */ export class ConnectionEvent extends Event { diff --git a/openvidu-browser/src/OpenViduInternal/Events/ConnectionPropertyChangedEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/ConnectionPropertyChangedEvent.ts index 7548e6de..32fdbf96 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/ConnectionPropertyChangedEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/ConnectionPropertyChangedEvent.ts @@ -22,15 +22,7 @@ import { Event } from './Event'; /** * **This feature is part of OpenVidu Pro tier** PRO * - * Defines event `connectionPropertyChanged` dispatched by [[Session]] object. - * 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)

+ * Triggered by [[connectionPropertyChanged]] */ export class ConnectionPropertyChangedEvent extends Event { diff --git a/openvidu-browser/src/OpenViduInternal/Events/EventMap/EventMap.ts b/openvidu-browser/src/OpenViduInternal/Events/EventMap/EventMap.ts new file mode 100644 index 00000000..e381108a --- /dev/null +++ b/openvidu-browser/src/OpenViduInternal/Events/EventMap/EventMap.ts @@ -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 { } \ No newline at end of file diff --git a/openvidu-browser/src/OpenViduInternal/Events/EventMap/PublisherEventMap.ts b/openvidu-browser/src/OpenViduInternal/Events/EventMap/PublisherEventMap.ts index c90a7393..eb21f666 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/EventMap/PublisherEventMap.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/EventMap/PublisherEventMap.ts @@ -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 { 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 { + + /** + * Event dispatched when the [[Publisher]] has been published to the session (see [[Session.publish]]). + */ streamCreated: StreamEvent; + + /** + * Event dispatched when the [[Publisher]] has been unpublished from the session. + */ 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; } \ No newline at end of file diff --git a/openvidu-browser/src/OpenViduInternal/Events/EventMap/SessionEventMap.ts b/openvidu-browser/src/OpenViduInternal/Events/EventMap/SessionEventMap.ts index 1663df30..d1af74b9 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/EventMap/SessionEventMap.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/EventMap/SessionEventMap.ts @@ -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 { ConnectionPropertyChangedEvent } from '../ConnectionPropertyChangedEvent'; import { ExceptionEvent } from '../ExceptionEvent'; @@ -9,25 +27,148 @@ import { SignalEvent } from '../SignalEvent'; import { StreamEvent } from '../StreamEvent'; 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; + + /** + * Event dispatched when a remote user has left the session. + * + * For the local user see [[sessionDisconnected]]. + */ connectionDestroyed: ConnectionEvent; + + /** + * **This feature is part of OpenVidu Pro tier** PRO + * + * 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)

+ */ connectionPropertyChanged: ConnectionPropertyChangedEvent; + + /** + * Event dispatched when the local user has left the session. + * + * For remote users see [[connectionDestroyed]]. + */ 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; + + /** + * Event dispatched when a user stops publishing media to the session. + * + * It is fired for both the local user and remote users. + */ 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; + + /** + * 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; + + /** + * 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; + /** * @hidden */ [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; + + /** + * 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; + + /** + * 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; + + /** + * **This feature is part of OpenVidu Pro tier** PRO + * + * Event dispatched when the network quality level of a [[Connection]] changes. See [network quality](/en/stable/advanced-features/network-quality/). + */ 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; + + /** + * 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; + + /** + * 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; } \ No newline at end of file diff --git a/openvidu-browser/src/OpenViduInternal/Events/EventMap/StreamManagerEventMap.ts b/openvidu-browser/src/OpenViduInternal/Events/EventMap/StreamManagerEventMap.ts index 704d9f37..815a2b92 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/EventMap/StreamManagerEventMap.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/EventMap/StreamManagerEventMap.ts @@ -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 { StreamManagerEvent } from '../StreamManagerEvent'; import { StreamPropertyChangedEvent } from '../StreamPropertyChangedEvent'; 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * Event dispatched when a Stream undergoes any change in any of its mutable properties + * (see [[StreamPropertyChangedEvent.changedProperty]]). + */ 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; + + /** + * 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; } \ No newline at end of file diff --git a/openvidu-browser/src/OpenViduInternal/Events/ExceptionEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/ExceptionEvent.ts index 0f8d3ad5..5d923284 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/ExceptionEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/ExceptionEvent.ts @@ -84,10 +84,7 @@ export enum ExceptionEventName { } /** - * Defines event `exception` dispatched by [[Session]] object. - * - * 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]]. + * Triggered by [[SessionEventMap.exception]] */ export class ExceptionEvent extends Event { diff --git a/openvidu-browser/src/OpenViduInternal/Events/NetworkQualityLevelChangedEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/NetworkQualityLevelChangedEvent.ts index 39ca1cc3..fe79c2e3 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/NetworkQualityLevelChangedEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/NetworkQualityLevelChangedEvent.ts @@ -20,10 +20,7 @@ import { Session } from '../../OpenVidu/Session'; import { Connection } from '../../OpenVidu/Connection'; /** - * **This feature is part of OpenVidu Pro tier** PRO - * - * 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/) + * Triggered by [[networkQualityLevelChanged]] */ export class NetworkQualityLevelChangedEvent extends Event { diff --git a/openvidu-browser/src/OpenViduInternal/Events/PublisherSpeakingEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/PublisherSpeakingEvent.ts index 01ba4d3e..89f82370 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/PublisherSpeakingEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/PublisherSpeakingEvent.ts @@ -22,13 +22,9 @@ import { StreamManager } from '../../OpenVidu/StreamManager'; /** - * Defines the following events: - * - `publisherStartSpeaking`: dispatched by [[Session]] and [[StreamManager]] when a user has started speaking - * - `publisherStopSpeaking`: dispatched by [[Session]] and [[StreamManager]] when a user has stopped speaking - * - * 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]] + * Triggered by: + * - `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` (available for [Session](/en/stable/api/openvidu-browser/interfaces/SessionEventMap.html#publisherStopSpeaking) and [StreamManager](/en/stable/api/openvidu-browser/interfaces/StreamManagerEventMap.html#publisherStopSpeaking) objects) */ export class PublisherSpeakingEvent extends Event { diff --git a/openvidu-browser/src/OpenViduInternal/Events/RecordingEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/RecordingEvent.ts index 4e8d2d41..c1c366f6 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/RecordingEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/RecordingEvent.ts @@ -20,12 +20,9 @@ import { Session } from '../../OpenVidu/Session'; /** - * Defines the following events: - * - `recordingStarted`: dispatched by [[Session]] after the session has started being recorded - * - `recordingStopped`: dispatched by [[Session]] after 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 these events (by default, only users with role `PUBLISHER` or `MODERATOR`) + * Triggered by: + * - [[recordingStarted]] + * - [[recordingStopped]] */ export class RecordingEvent extends Event { diff --git a/openvidu-browser/src/OpenViduInternal/Events/SessionDisconnectedEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/SessionDisconnectedEvent.ts index b5f70d72..986e1c72 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/SessionDisconnectedEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/SessionDisconnectedEvent.ts @@ -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 { diff --git a/openvidu-browser/src/OpenViduInternal/Events/SignalEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/SignalEvent.ts index 52ff02fb..02fe723e 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/SignalEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/SignalEvent.ts @@ -21,9 +21,7 @@ import { Session } from '../../OpenVidu/Session'; /** - * Defines the following events: - * - `signal`: dispatched by [[Session]] when a signal is received - * - `signal:TYPE`: dispatched by [[Session]] when a signal of type TYPE is received + * Triggered by [[SessionEventMap.signal]] */ export class SignalEvent extends Event { diff --git a/openvidu-browser/src/OpenViduInternal/Events/StreamEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/StreamEvent.ts index 17857ea2..cbb0e0a1 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/StreamEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/StreamEvent.ts @@ -27,9 +27,9 @@ import { OpenViduLogger } from '../Logger/OpenViduLogger'; const logger: OpenViduLogger = OpenViduLogger.getInstance(); /** - * Defines the following events: - * - `streamCreated`: dispatched by [[Session]] and [[Publisher]] after some user has started publishing to the session - * - `streamDestroyed`: dispatched by [[Session]] and [[Publisher]] after some user has stopped publishing to the session + * Triggered by: + * - `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]` (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 { diff --git a/openvidu-browser/src/OpenViduInternal/Events/StreamManagerEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/StreamManagerEvent.ts index 13a3f201..30c25bfb 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/StreamManagerEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/StreamManagerEvent.ts @@ -19,15 +19,9 @@ import { Event } from './Event'; import { StreamManager } from '../../OpenVidu/StreamManager'; /** - * Defines the following events: - * - `streamPlaying`: dispatched by [[StreamManager]] ([[Publisher]] and [[Subscriber]]) whenever its 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) - * - `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) + * Triggered by: + * - [[streamPlaying]] + * - [[streamAudioVolumeChange]] */ export class StreamManagerEvent extends Event { diff --git a/openvidu-browser/src/OpenViduInternal/Events/StreamPropertyChangedEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/StreamPropertyChangedEvent.ts index a3f29d9d..db5f7a29 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/StreamPropertyChangedEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/StreamPropertyChangedEvent.ts @@ -21,9 +21,7 @@ import { Stream } from '../../OpenVidu/Stream'; import { StreamManager } from '../../OpenVidu/StreamManager'; /** - * Defines event `streamPropertyChanged` dispatched by [[Session]] as well as by [[StreamManager]] ([[Publisher]] and [[Subscriber]]). - * 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]]). + * 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) */ export class StreamPropertyChangedEvent extends Event { diff --git a/openvidu-browser/src/OpenViduInternal/Events/VideoElementEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/VideoElementEvent.ts index 33c004ca..e8010bf8 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/VideoElementEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/VideoElementEvent.ts @@ -20,10 +20,9 @@ import { StreamManager } from '../../OpenVidu/StreamManager'; /** - * Defines the following events: - * - `videoElementCreated`: dispatched by [[Publisher]] and [[Subscriber]] whenever a new HTML video element has been inserted into DOM by OpenVidu Browser library. See - * [Manage video players](/en/stable/cheatsheet/manage-videos) section. - * - `videoElementDestroyed`: dispatched by [[Publisher]] and [[Subscriber]] whenever an HTML video element has been removed from DOM by OpenVidu Browser library. + * Triggered by: + * - [[videoElementCreated]] + * - [[videoElementDestroyed]] */ export class VideoElementEvent extends Event { diff --git a/openvidu-browser/src/index.ts b/openvidu-browser/src/index.ts index 3fc5c894..8554eeb9 100644 --- a/openvidu-browser/src/index.ts +++ b/openvidu-browser/src/index.ts @@ -38,6 +38,7 @@ export { SignalOptions } from './OpenViduInternal/Interfaces/Public/SignalOption export { StreamManagerVideo } from './OpenViduInternal/Interfaces/Public/StreamManagerVideo'; export { SubscriberProperties } from './OpenViduInternal/Interfaces/Public/SubscriberProperties'; +export { EventMap } from './OpenViduInternal/Events/EventMap/EventMap'; export { SessionEventMap } from './OpenViduInternal/Events/EventMap/SessionEventMap'; export { StreamManagerEventMap } from './OpenViduInternal/Events/EventMap/StreamManagerEventMap'; export { PublisherEventMap } from './OpenViduInternal/Events/EventMap/PublisherEventMap';