csantosm 53d54a682e openvidu-components: Removed unnecessary code after fixed hark
openvidu-browser hark events bug has been fixed so it is not necessary to resubscribe again after audio track is replaced.
2022-07-07 17:47:27 +02:00

42 lines
1.0 KiB
TypeScript

import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { PublisherSpeakingEvent, StreamManager } from 'openvidu-browser';
/**
* @internal
*/
@Component({
selector: 'ov-audio-wave',
templateUrl: './audio-wave.component.html',
styleUrls: ['./audio-wave.component.css']
})
export class AudioWaveComponent implements OnInit, OnDestroy {
isSpeaking: boolean = false;
@Input() streamManager: StreamManager;
constructor() {}
ngOnInit(): void {
this.subscribeSpeakingEvents();
}
ngOnDestroy(): void {
this.unsubscribeSpeakingEvents();
}
private subscribeSpeakingEvents() {
if (this.streamManager) {
this.streamManager.on('publisherStartSpeaking', (event: PublisherSpeakingEvent) => (this.isSpeaking = true));
this.streamManager.on('publisherStopSpeaking', (event: PublisherSpeakingEvent) => (this.isSpeaking = false));
}
}
private unsubscribeSpeakingEvents() {
if (this.streamManager) {
this.streamManager.off('publisherStartSpeaking');
this.streamManager.off('publisherStopSpeaking');
}
}
}