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