Live view improvements (#10781)

* Show frigate features in bottom sheet on mobile

* Use flex wrap on mobile so the ptz icons are not cutoff

* Support opening pip from live view

* Remove unused
This commit is contained in:
Nicolas Mowen
2024-04-02 06:45:16 -06:00
committed by GitHub
parent a886b6a3e5
commit 4d8d3cd22e
4 changed files with 215 additions and 54 deletions

View File

@@ -22,6 +22,7 @@ type LivePlayerProps = {
playAudio?: boolean;
micEnabled?: boolean; // only webrtc supports mic
iOSCompatFullScreen?: boolean;
pip?: boolean;
onClick?: () => void;
};
@@ -35,6 +36,7 @@ export default function LivePlayer({
playAudio = false,
micEnabled = false,
iOSCompatFullScreen = false,
pip,
onClick,
}: LivePlayerProps) {
// camera activity
@@ -105,6 +107,7 @@ export default function LivePlayer({
microphoneEnabled={micEnabled}
iOSCompatFullScreen={iOSCompatFullScreen}
onPlaying={() => setLiveReady(true)}
pip={pip}
/>
);
} else if (liveMode == "mse") {
@@ -116,6 +119,7 @@ export default function LivePlayer({
playbackEnabled={cameraActive}
audioEnabled={playAudio}
onPlaying={() => setLiveReady(true)}
pip={pip}
/>
);
} else {

View File

@@ -6,6 +6,7 @@ type MSEPlayerProps = {
className?: string;
playbackEnabled?: boolean;
audioEnabled?: boolean;
pip?: boolean;
onPlaying?: () => void;
};
@@ -14,6 +15,7 @@ function MSEPlayer({
className,
playbackEnabled = true,
audioEnabled = false,
pip = false,
onPlaying,
}: MSEPlayerProps) {
let connectTS: number = 0;
@@ -268,6 +270,16 @@ function MSEPlayer({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [playbackEnabled, onDisconnect, onConnect]);
// control pip
useEffect(() => {
if (!videoRef.current || !pip) {
return;
}
videoRef.current.requestPictureInPicture();
}, [pip, videoRef]);
return (
<video
ref={videoRef}

View File

@@ -8,6 +8,7 @@ type WebRtcPlayerProps = {
audioEnabled?: boolean;
microphoneEnabled?: boolean;
iOSCompatFullScreen?: boolean; // ios doesn't support fullscreen divs so we must support the video element
pip?: boolean;
onPlaying?: () => void;
};
@@ -18,6 +19,7 @@ export default function WebRtcPlayer({
audioEnabled = false,
microphoneEnabled = false,
iOSCompatFullScreen = false,
pip = false,
onPlaying,
}: WebRtcPlayerProps) {
// metadata
@@ -173,8 +175,19 @@ export default function WebRtcPlayer({
]);
// ios compat
const [iOSCompatControls, setiOSCompatControls] = useState(false);
// control pip
useEffect(() => {
if (!videoRef.current || !pip) {
return;
}
videoRef.current.requestPictureInPicture();
}, [pip, videoRef]);
return (
<video
ref={videoRef}