From fb094f82b74aeabe14280b8713f70d78b3ea3e1c Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Sat, 30 Sep 2017 14:14:10 +0200 Subject: [PATCH] openvidu-browser speech events only for MediaStreams with audio tracks --- .../ts/OpenViduInternal/Stream.ts | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/openvidu-browser/ts/OpenViduInternal/Stream.ts b/openvidu-browser/ts/OpenViduInternal/Stream.ts index 7e05d867..8f48e594 100644 --- a/openvidu-browser/ts/OpenViduInternal/Stream.ts +++ b/openvidu-browser/ts/OpenViduInternal/Stream.ts @@ -54,7 +54,7 @@ export class Stream { public connection: Connection; private ee = new EventEmitter(); - private wrStream: any; + private wrStream: MediaStream; private wp: any; private id: string; private video: HTMLVideoElement; @@ -577,21 +577,25 @@ export class Stream { this.emitSrcEvent(this.wrStream); - this.speechEvent = kurentoUtils.WebRtcPeer.hark(this.wrStream, { threshold: this.room.thresholdSpeaker }); + if (this.wrStream.getAudioTracks()[0] != null) { - this.speechEvent.on('speaking', () => { - this.room.addParticipantSpeaking(participantId); - this.room.emitEvent('stream-speaking', [{ - participantId: participantId - }]); - }); + this.speechEvent = kurentoUtils.WebRtcPeer.hark(this.wrStream, { threshold: this.room.thresholdSpeaker }); - this.speechEvent.on('stopped_speaking', () => { - this.room.removeParticipantSpeaking(participantId); - this.room.emitEvent('stream-stopped-speaking', [{ - participantId: participantId - }]); - }); + this.speechEvent.on('speaking', () => { + this.room.addParticipantSpeaking(participantId); + this.room.emitEvent('stream-speaking', [{ + participantId: participantId + }]); + }); + + this.speechEvent.on('stopped_speaking', () => { + this.room.removeParticipantSpeaking(participantId); + this.room.emitEvent('stream-stopped-speaking', [{ + participantId: participantId + }]); + }); + + } } for (let videoElement of this.videoElements) { let thumbnailId = videoElement.thumb;