From 5672957f10099a9e9576492bacaad3b774e5298d Mon Sep 17 00:00:00 2001 From: huanghuang358 <178640467+huanghuang358@users.noreply.github.com> Date: Thu, 31 Jul 2025 17:42:22 +0800 Subject: [PATCH] feat(webapp): display tip of disabled media --- webapp/components/layout.tsx | 2 +- webapp/components/player/player.tsx | 38 +++++++++++++----------- webapp/components/player/whep-player.tsx | 2 +- webapp/components/player/whip-player.tsx | 2 +- webapp/components/prepare.tsx | 4 +-- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/webapp/components/layout.tsx b/webapp/components/layout.tsx index 3fe0ead..38d2581 100644 --- a/webapp/components/layout.tsx +++ b/webapp/components/layout.tsx @@ -99,7 +99,7 @@ export default function Layout(props: { meetingId: string }) {
{enabledPresentation - ? + ? : null } diff --git a/webapp/components/player/player.tsx b/webapp/components/player/player.tsx index ea0e62b..c25ca2d 100644 --- a/webapp/components/player/player.tsx +++ b/webapp/components/player/player.tsx @@ -76,9 +76,8 @@ function Mic(props: { stream: MediaStream }) { ) } -export default function Player(props: { stream: MediaStream, muted: boolean, audio?: boolean, video?: boolean, width: string }) { +export default function Player(props: { stream: MediaStream, muted: boolean, audio?: boolean, video?: boolean, width: string, self: boolean }) { const refVideo = useRef(null) - const [showAudio, setShowAudio] = useState(false) const audioTrack = props.stream.getAudioTracks()[0] const videoTrack = props.stream.getVideoTracks()[0] const [currentDeviceSpeaker] = useAtom(deviceSpeakerAtom) @@ -90,6 +89,10 @@ export default function Player(props: { stream: MediaStream, muted: boolean, aud const [isMuted, setIsMuted] = useState(false) const [isFullscreened, setIsFullscreened] = useState(false) const [isPictureInPictured, setIsPictureInPictured] = useState(false) + const hasTracks = props.stream.getTracks().length > 0 + const mediaEnabled = props.audio || props.video + const showAudio = props.audio && !props.video + const mediaDisabledTip = `All ${props.self ? 'your' : 'their'} media are disabled` const handleMouseMove = () => { setShowControls(true) @@ -164,13 +167,7 @@ export default function Player(props: { stream: MediaStream, muted: boolean, aud }, []) useEffect(() => { - if (audioTrack && !videoTrack) { - setShowAudio(true) - } else { - setShowAudio(false) - } - if (!props.audio) setIsMuted(true) - if (audioTrack && props.audio) { + if (audioTrack && props.audio && !props.muted) { const el = document.createElement('audio') el.srcObject = new MediaStream([audioTrack]) @@ -209,21 +206,26 @@ export default function Player(props: { stream: MediaStream, muted: boolean, aud // NOTE: iOS can't display video // https://webkit.org/blog/6784/new-video-policies-for-ios/ return ( -
- {!props.stream.getTracks().length ?
: null} +
+ {!mediaEnabled ?

{mediaDisabledTip}

: null} + {mediaEnabled && !hasTracks ? : null}
-
+ ) } diff --git a/webapp/components/player/whep-player.tsx b/webapp/components/player/whep-player.tsx index f92154e..d94ee2f 100644 --- a/webapp/components/player/whep-player.tsx +++ b/webapp/components/player/whep-player.tsx @@ -53,7 +53,7 @@ export default function WhepPlayer(props: { streamId: string, userStatus: Stream return (
- +
) diff --git a/webapp/components/player/whip-player.tsx b/webapp/components/player/whip-player.tsx index 678387a..c9e1aa4 100644 --- a/webapp/components/player/whip-player.tsx +++ b/webapp/components/player/whip-player.tsx @@ -30,7 +30,7 @@ export default function WhipPlayer(props: { streamId: string, width: string }) { return (
- +
) diff --git a/webapp/components/prepare.tsx b/webapp/components/prepare.tsx index 0299b17..b2ea459 100644 --- a/webapp/components/prepare.tsx +++ b/webapp/components/prepare.tsx @@ -18,7 +18,7 @@ export default function Prepare(_props: { meetingId: string }) { const localStreamId = getStorageStream() const [_, setMeetingJoined] = useAtom(meetingJoinedAtom) - const { id, stream, setUserName, setSyncUserStatus, restart } = useWhipClient(localStreamId) + const { id, stream, setUserName, setSyncUserStatus, restart, userStatus } = useWhipClient(localStreamId) const join = async () => { setLoading(true) @@ -39,7 +39,7 @@ export default function Prepare(_props: { meetingId: string }) { return (
- +