Skip to content

Commit 9583a28

Browse files
rickstaayondonfu
authored andcommitted
feat(ui): enhance preview video layout for mobile devices
This commit improves the layout and responsiveness of the preview video on mobile devices, ensuring a better user experience by addressing compatibility and display issues.
1 parent 87020a3 commit 9583a28

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

ui/src/components/room.tsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function Stage({ connected, onStreamReady }: StageProps) {
8686
}
8787

8888
return (
89-
<div className="relative">
89+
<div className="relative w-full h-full">
9090
<MediaStreamPlayer stream={remoteStream} />
9191
<div className="absolute top-2 right-2 bg-black/50 text-white px-2 py-1 rounded text-sm">
9292
<TooltipProvider>
@@ -178,15 +178,24 @@ export function Room() {
178178
onDisconnected={handleDisconnected}
179179
localStream={localStream}
180180
>
181-
<div className="min-h-[100dvh] flex flex-col items-center justify-start pt-[10vh]">
182-
<div className="w-full max-h-[100dvh] flex flex-col lg:flex-row landscape:flex-row justify-center items-center lg:space-x-4">
183-
<div className="landscape:w-full lg:w-1/2 h-[50dvh] lg:h-auto landscape:h-full max-w-[512px] max-h-[512px] aspect-square bg-[black] flex justify-center items-center border-2 rounded-md">
181+
<div className="min-h-[100dvh] flex flex-col items-center justify-start">
182+
<div className="w-full max-h-[100dvh] flex flex-col lg:flex-row landscape:flex-row justify-center items-center lg:space-x-4 sm:pt-[10vh]">
183+
{/* Output Stream */}
184+
<div className="relative w-full max-w-[100vw] h-auto aspect-square sm:max-w-[512px] sm:max-h-[512px] md:max-w-[512px] md:max-h-[512px] flex justify-center items-center bg-slate-900 sm:border-[2px] md:border-0 lg:border-2 rounded-md">
184185
<Stage
185186
connected={isConnected}
186187
onStreamReady={onRemoteStreamReady}
187188
/>
189+
<div className="absolute bottom-[8px] right-[8px] w-[90px] h-[90px] bg-slate-800 block md:hidden">
190+
<Webcam
191+
onStreamReady={onStreamReady}
192+
deviceId={config.selectedDeviceId}
193+
frameRate={config.frameRate}
194+
/>
195+
</div>
188196
</div>
189-
<div className="landscape:w-full lg:w-1/2 h-[50dvh] lg:h-auto landscape:h-full max-w-[512px] max-h-[512px] aspect-square flex justify-center items-center lg:border-2 lg:rounded-md">
197+
{/* Input Stream */}
198+
<div className="hidden md:flex w-full sm:w-full md:w-full h-[50dvh] sm:h-auto md:h-auto max-w-[512px] max-h-[512px] aspect-square justify-center items-center lg:border-2 lg:rounded-md bg-slate-800">
190199
<Webcam
191200
onStreamReady={onStreamReady}
192201
deviceId={config.selectedDeviceId}

ui/src/components/webcam.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ function StreamCanvas({
100100
width={512}
101101
height={512}
102102
className="w-full h-full"
103-
style={{
104-
backgroundColor: "black",
105-
}}
106103
/>
107104
<div className="absolute top-2 right-2 bg-black/50 text-white px-2 py-1 rounded text-sm">
108105
<TooltipProvider>
@@ -171,7 +168,7 @@ export function Webcam({ onStreamReady, deviceId, frameRate }: WebcamProps) {
171168
if (frameRate == 0) return;
172169

173170
startWebcam().then((newStream) => {
174-
replaceStream(newStream);
171+
replaceStream(newStream);
175172
});
176173

177174
return () => {

0 commit comments

Comments
 (0)