From b99f387b4ef2c79040952e5ce44b79896b82494b Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Thu, 7 Jul 2022 14:28:47 +0200 Subject: [PATCH] openvidu-browser: init hark events on Publisher#replaceTrack --- openvidu-browser/src/OpenVidu/Publisher.ts | 3 +++ openvidu-browser/src/OpenVidu/Stream.ts | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openvidu-browser/src/OpenVidu/Publisher.ts b/openvidu-browser/src/OpenVidu/Publisher.ts index eabb06cd..02e36740 100644 --- a/openvidu-browser/src/OpenVidu/Publisher.ts +++ b/openvidu-browser/src/OpenVidu/Publisher.ts @@ -786,6 +786,9 @@ export class Publisher extends StreamManager { } else if(track.kind === 'audio' && updateLastConstraints) { this.openvidu.sendTrackChangedEvent(this,'trackReplaced', trackInfo.oldLabel, trackInfo.newLabel, 'audioActive'); } + if (track.kind === 'audio') { + this.stream.initHarkEvents(); + } } /* Private methods */ diff --git a/openvidu-browser/src/OpenVidu/Stream.ts b/openvidu-browser/src/OpenVidu/Stream.ts index 7bad3bec..fe97d6cd 100644 --- a/openvidu-browser/src/OpenVidu/Stream.ts +++ b/openvidu-browser/src/OpenVidu/Stream.ts @@ -1388,7 +1388,10 @@ export class Stream { } } - private initHarkEvents(): void { + /** + * @hidden + */ + initHarkEvents(): void { if (!!this.mediaStream!.getAudioTracks()[0]) { // Hark events can only be set if audio track is available if (this.session.anySpeechEventListenerEnabled('publisherStartSpeaking', true, this.streamManager)) {