Fix missing screen share player

This commit is contained in:
illusia committed 2026-10-12 08:25:57 +08:00
1 parent 42190909e3
commit acdc7a2330
6 files changed
+70 -38

No files matched your search

+2 -10
View File
@@ -1,4 +1,4 @@
import { reactive, ref } from "vue";
import { computed, reactive, ref } from "vue";
import { parseScreenShareStream, parseScreenShareViewers, type ServerMessage } from "../../../src/shared/server-messages.js";
import { normalizeScreenShareIceServers, type ScreenShareIceServer, type ScreenShareClientMessage, type ScreenShareStreamDescription as ScreenShareStream, type ScreenSharePeerSignal as ScreenShareSignal } from "../../../src/shared/screen-share.js";
@@ -56,8 +56,8 @@ export function createScreenShareController(transport: ScreenShareTransport) {
const screenShareActive = ref(false);
const screenShareStarting = ref(false);
const screenShareActiveStreamId = ref("");
const screenShareViewing = ref(false);
const screenShareViewingStreamId = ref("");
const screenShareViewing = computed(() => Boolean(screenShareViewingStreamId.value));
const screenShareRemoteStream = ref<MediaStream | null>(null);
const screenShareError = ref("");
const screenShareErrorCode = ref("");
@@ -290,7 +290,6 @@ export function createScreenShareController(transport: ScreenShareTransport) {
if (viewingStream) sendScreenShareMessage({ type: "screenShareLeave", streamId: viewingStream.streamId });
closeScreenSharePeer(peerId);
if (viewingStream) {
screenShareViewing.value = false;
screenShareViewingStreamId.value = "";
screenShareRemoteStream.value = null;
}
@@ -340,7 +339,6 @@ export function createScreenShareController(transport: ScreenShareTransport) {
if (!event.streams[0]) remote.addTrack(event.track);
screenSharePeerStreams.set(peerId, remote);
screenShareRemoteStream.value = remote;
screenShareViewing.value = true;
};
peer.onconnectionstatechange = () => {
if (!isCurrentPeer(peerId, peer)) return;
@@ -413,7 +411,6 @@ export function createScreenShareController(transport: ScreenShareTransport) {
async function startScreenShareViewer(stream: ScreenShareStream): Promise<void> {
closeAllScreenSharePeers();
screenShareRemoteStream.value = null;
screenShareViewing.value = true;
screenShareViewingStreamId.value = stream.streamId;
screenShareErrorCode.value = "";
screenShareError.value = "";
@@ -467,7 +464,6 @@ export function createScreenShareController(transport: ScreenShareTransport) {
if (signal.kind === "close") {
closeScreenSharePeer(fromPeerId);
if (screenShareViewingStreamId.value === streamId) {
screenShareViewing.value = false;
screenShareViewingStreamId.value = "";
screenShareRemoteStream.value = null;
}
@@ -647,7 +643,6 @@ export function createScreenShareController(transport: ScreenShareTransport) {
function leaveScreenShare(): void {
if (screenShareViewingStreamId.value) sendScreenShareMessage({ type: "screenShareLeave", streamId: screenShareViewingStreamId.value });
closeAllScreenSharePeers();
screenShareViewing.value = false;
screenShareViewingStreamId.value = "";
screenShareRemoteStream.value = null;
}
@@ -665,7 +660,6 @@ export function createScreenShareController(transport: ScreenShareTransport) {
screenShareStartCancelled = false;
screenShareActive.value = false;
screenShareActiveStreamId.value = "";
screenShareViewing.value = false;
screenShareViewingStreamId.value = "";
screenShareRemoteStream.value = null;
screenShareStreams.length = 0;
@@ -730,7 +724,6 @@ export function createScreenShareController(transport: ScreenShareTransport) {
}
if (screenShareViewingStreamId.value === streamId) {
closeAllScreenSharePeers();
screenShareViewing.value = false;
screenShareViewingStreamId.value = "";
screenShareRemoteStream.value = null;
}
@@ -772,7 +765,6 @@ export function createScreenShareController(transport: ScreenShareTransport) {
if (screenShareViewing.value) {
if (screenShareViewingStreamId.value) sendScreenShareMessage({ type: "screenShareLeave", streamId: screenShareViewingStreamId.value });
closeAllScreenSharePeers();
screenShareViewing.value = false;
screenShareViewingStreamId.value = "";
screenShareRemoteStream.value = null;
}