wide-shoe-67933
08/13/2025, 11:32 AMtall-airline-16756
08/13/2025, 11:32 AMtall-airline-16756
08/13/2025, 11:33 AMisMobileBrowser()
function to see if the user’s on a mobile browser:
const isMobile = isMobileBrowser();
• For Flutter, you can use lkPlatformIs
to spot specific platforms like iOS or Android:
if (lkPlatformIs(PlatformType.iOS)) {
// iOS-specific handling
} else if (lkPlatformIs(PlatformType.Android)) {
// Android-specific handling
}
Adjusting Video Aspect Ratio and Fit:
• In Flutter, the VideoViewFit
enum is your friend for controlling how the video shows up:
VideoTrackRenderer(
track: videoTrack,
fit: isMobile ? VideoViewFit.cover : VideoViewFit.contain,
);
• And if you’re in JavaScript/TypeScript, just tweak the CSS object-fit
property to get the right video look:
if (isMobileBrowser()) {
videoElement.style.objectFit = 'cover';
} else {
videoElement.style.objectFit = 'contain';
}
If you want me to walk you through any of this or need a hand with the implementation, just give me a shout!
Sources: packages/styles/scss/prefabs/prejoin.scss | lib/src/utils.dartwide-shoe-67933
08/13/2025, 11:37 AMtall-airline-16756
08/13/2025, 11:37 AMwide-shoe-67933
08/13/2025, 11:39 AMtall-airline-16756
08/13/2025, 11:39 AMisMobileBrowser()
that helps you figure out if someone’s on a mobile browser:
import { isMobileBrowser } from "@livekit/components-core";
const isMobile = isMobileBrowser();
Feel free to use this right inside your React components to easily check the platform.
2. Using a Custom Hook:
If you like a more React-centric way, you can create your own custom hook to detect mobile devices like this:
import { getSelectorsByUserAgent } from "react-device-detect";
export const useMobile = () => {
if (typeof navigator === "undefined") return false;
const { isMobile } = getSelectorsByUserAgent(navigator.userAgent);
return isMobile;
};
Then, just use this hook in your component like so:
import { useMobile } from "@/util/useMobile";
function MyComponent() {
const isMobile = useMobile();
return (
<div>
{isMobile ? (
<p>Mobile user</p>
) : (
<p>Web user</p>
)}
</div>
);
}
If you’d like me to walk you through any part of this or help with the implementation, just let me know—I’m here to help!wide-shoe-67933
08/13/2025, 11:43 AMtall-airline-16756
08/13/2025, 11:44 AMClientInfo
structure tied to each participant. It gives you handy details about their platform and SDK.
Here’s how you can do it:
1. Grab the participant's ClientInfo
object.
2. Look at the sdk
field to see which LiveKit SDK they’re on:
• `JS`: That means a web client
• iOS
or `Android`: That’s a mobile client
1. If you want, peek at the os
and browser
fields for even more info:
• `os`: Shows the operating system (like iOS or Android).
• `browser`: Tells you the browser type for web clients (think Chrome, Safari).
Here’s a quick example:
// Example in JavaScript/TypeScript
const clientInfo = participant.clientInfo;
if (clientInfo.sdk === 'JS') {
console.log('Participant is using a web client');
} else if (clientInfo.sdk === 'iOS' || clientInfo.sdk === 'Android') {
console.log('Participant is using a mobile client');
}
If you want a hand setting this up or have any questions, just let me know—I’m here to help!
Sources: Sources/LiveKit/Protos/livekit_models.pb.swift | livekit-protocol/livekit/protocol/models.pyi | livekit-protocol/src/livekit.rs | Web and mobile frontends | LiveKit Docswide-shoe-67933
08/13/2025, 11:47 AMtall-airline-16756
08/13/2025, 11:47 AM