ov-components: add track subscription and manage room tracks published state

master
Carlos Santos 2025-07-17 13:23:22 +02:00
parent 55fd64c254
commit 8407363aaf
1 changed files with 30 additions and 2 deletions

View File

@ -99,12 +99,18 @@ export class RecordingActivityComponent implements OnInit {
*/
recordingError: any;
/**
* @internal
*/
hasRoomTracksPublished: boolean = false;
/**
* @internal
*/
mouseHovering: boolean = false;
private log: ILogger;
private recordingStatusSubscription: Subscription;
private tracksSubscription: Subscription;
/**
* @internal
@ -125,6 +131,7 @@ export class RecordingActivityComponent implements OnInit {
*/
ngOnInit(): void {
this.subscribeToRecordingStatus();
this.subscribeToTracksChanges();
}
/**
@ -132,13 +139,14 @@ export class RecordingActivityComponent implements OnInit {
*/
ngOnDestroy() {
if (this.recordingStatusSubscription) this.recordingStatusSubscription.unsubscribe();
if (this.tracksSubscription) this.tracksSubscription.unsubscribe();
}
/**
* @internal
*/
get hasRoomTracksPublished(): boolean {
return this.openviduService.hasRoomTracksPublished();
trackByRecordingId(index: number, recording: RecordingInfo): string | undefined {
return recording.id;
}
/**
@ -246,4 +254,24 @@ export class RecordingActivityComponent implements OnInit {
this.cd.markForCheck();
});
}
private subscribeToTracksChanges() {
this.hasRoomTracksPublished = this.openviduService.hasRoomTracksPublished();
this.tracksSubscription = this.participantService.localParticipant$.subscribe(() => {
const newValue = this.openviduService.hasRoomTracksPublished();
if (this.hasRoomTracksPublished !== newValue) {
this.hasRoomTracksPublished = newValue;
this.cd.markForCheck();
}
});
this.participantService.remoteParticipants$.subscribe(() => {
const newValue = this.openviduService.hasRoomTracksPublished();
if (this.hasRoomTracksPublished !== newValue) {
this.hasRoomTracksPublished = newValue;
this.cd.markForCheck();
}
});
}
}