Clean up stream audio on ending stream

This commit is contained in:
2026-03-09 23:59:59 +01:00
parent dc6746c882
commit ca74836c52
5 changed files with 86 additions and 55 deletions

View File

@@ -141,9 +141,17 @@ export class ScreenShareViewerComponent implements OnDestroy {
// Subscribe to remote streams with video (screen shares)
// NOTE: We no longer auto-display remote streams. Users must click "Live" to view.
// This subscription is kept for potential future use (e.g., tracking available streams)
this.remoteStreamSub = this.webrtcService.onRemoteStream.subscribe(({ peerId, stream }) => {
// Do nothing on remote stream - user must explicitly click "Live" to view
// The stream is still stored in webrtcService.remoteStreams and can be accessed via getRemoteStream()
this.remoteStreamSub = this.webrtcService.onRemoteStream.subscribe(({ peerId }) => {
if (peerId !== this.watchingUserId() || this.isLocalShare()) {
return;
}
const stream = this.webrtcService.getRemoteScreenShareStream(peerId);
const hasActiveVideo = stream?.getVideoTracks().some((track) => track.readyState === 'live') ?? false;
if (!hasActiveVideo) {
this.stopWatching();
}
});
// Listen for focus events dispatched by other components