From 58f6447009bfbc70b5b5da20407172decf5d5e26 Mon Sep 17 00:00:00 2001 From: a-wing <1@233.email> Date: Tue, 26 Dec 2023 13:56:00 +0800 Subject: [PATCH] feat(webapp): add whip & whep loading --- webapp/components/player/whep-player.tsx | 9 ++++++++- webapp/components/player/whip-player.tsx | 10 +++++++++- webapp/components/svg/progress.tsx | 7 +++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 webapp/components/svg/progress.tsx diff --git a/webapp/components/player/whep-player.tsx b/webapp/components/player/whep-player.tsx index ec15b7f..2fe7e32 100644 --- a/webapp/components/player/whep-player.tsx +++ b/webapp/components/player/whep-player.tsx @@ -7,10 +7,12 @@ import { } from '../../store/atom' import { WHEPClient } from '@binbat/whip-whep/whep' import { useAtom } from 'jotai' +import SvgProgress from '../svg/progress' export default function WhepPlayer(props: { streamId: string, status: UserStatus, width: string }) { const refEnabled = useRef(false) const refPC = useRef(null) + const [loading, setLoading] = useState(true) const [connectionState, setConnectionState] = useState("unknown") const [userStream, setUserStream] = useState({ stream: new MediaStream, @@ -34,6 +36,7 @@ export default function WhepPlayer(props: { streamId: string, status: UserStatus } const start = async (resource: string) => { + setLoading(false) if (refPC.current) { const whep = new WHEPClient(); const url = location.origin + "/whep/" + resource; @@ -44,6 +47,7 @@ export default function WhepPlayer(props: { streamId: string, status: UserStatus } const restart = async (resource: string) => { + setLoading(true) if (refPC.current) { refPC.current.close() } @@ -79,7 +83,10 @@ export default function WhepPlayer(props: { streamId: string, status: UserStatus return (
- + { loading + ? + : + }
diff --git a/webapp/components/player/whip-player.tsx b/webapp/components/player/whip-player.tsx index f0704a8..a91985a 100644 --- a/webapp/components/player/whip-player.tsx +++ b/webapp/components/player/whip-player.tsx @@ -11,6 +11,7 @@ import { import Player from './player' import { WHIPClient } from '@binbat/whip-whep/whip' import { deviceScreen } from '../../lib/device' +import SvgProgress from '../svg/progress' export default function WhipPlayer(props: { streamId: string, width: string }) { const refEnabled = useRef(false) @@ -19,6 +20,8 @@ export default function WhipPlayer(props: { streamId: string, width: string }) { const [localStream] = useAtom(localStreamAtom) const [localUserStatus, setLocalUserStatus] = useAtom(localUserStatusAtom) + const [loading, setLoading] = useState(true) + const [currentDeviceAudio] = useAtom(currentDeviceAudioAtom) const [currentDeviceVideo] = useAtom(currentDeviceVideoAtom) @@ -71,9 +74,11 @@ export default function WhipPlayer(props: { streamId: string, width: string }) { refClient.current = whip } } + setLoading(false) } const restart = async (resource: string) => { + setLoading(true) if (refPC.current) { refPC.current.close() } @@ -136,7 +141,10 @@ export default function WhipPlayer(props: { streamId: string, width: string }) { return (
- + { loading + ? + : + }
diff --git a/webapp/components/svg/progress.tsx b/webapp/components/svg/progress.tsx new file mode 100644 index 0000000..019ddbe --- /dev/null +++ b/webapp/components/svg/progress.tsx @@ -0,0 +1,7 @@ +export default function SvgProgress() { + return ( + + + + ) +}