Skip to content

Commit 4d8d3cd

Browse files
authored
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
1 parent a886b6a commit 4d8d3cd

File tree

4 files changed

+215
-54
lines changed

4 files changed

+215
-54
lines changed

web/src/components/player/LivePlayer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type LivePlayerProps = {
2222
playAudio?: boolean;
2323
micEnabled?: boolean; // only webrtc supports mic
2424
iOSCompatFullScreen?: boolean;
25+
pip?: boolean;
2526
onClick?: () => void;
2627
};
2728

@@ -35,6 +36,7 @@ export default function LivePlayer({
3536
playAudio = false,
3637
micEnabled = false,
3738
iOSCompatFullScreen = false,
39+
pip,
3840
onClick,
3941
}: LivePlayerProps) {
4042
// camera activity
@@ -105,6 +107,7 @@ export default function LivePlayer({
105107
microphoneEnabled={micEnabled}
106108
iOSCompatFullScreen={iOSCompatFullScreen}
107109
onPlaying={() => setLiveReady(true)}
110+
pip={pip}
108111
/>
109112
);
110113
} else if (liveMode == "mse") {
@@ -116,6 +119,7 @@ export default function LivePlayer({
116119
playbackEnabled={cameraActive}
117120
audioEnabled={playAudio}
118121
onPlaying={() => setLiveReady(true)}
122+
pip={pip}
119123
/>
120124
);
121125
} else {

web/src/components/player/MsePlayer.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type MSEPlayerProps = {
66
className?: string;
77
playbackEnabled?: boolean;
88
audioEnabled?: boolean;
9+
pip?: boolean;
910
onPlaying?: () => void;
1011
};
1112

@@ -14,6 +15,7 @@ function MSEPlayer({
1415
className,
1516
playbackEnabled = true,
1617
audioEnabled = false,
18+
pip = false,
1719
onPlaying,
1820
}: MSEPlayerProps) {
1921
let connectTS: number = 0;
@@ -268,6 +270,16 @@ function MSEPlayer({
268270
// eslint-disable-next-line react-hooks/exhaustive-deps
269271
}, [playbackEnabled, onDisconnect, onConnect]);
270272

273+
// control pip
274+
275+
useEffect(() => {
276+
if (!videoRef.current || !pip) {
277+
return;
278+
}
279+
280+
videoRef.current.requestPictureInPicture();
281+
}, [pip, videoRef]);
282+
271283
return (
272284
<video
273285
ref={videoRef}

web/src/components/player/WebRTCPlayer.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type WebRtcPlayerProps = {
88
audioEnabled?: boolean;
99
microphoneEnabled?: boolean;
1010
iOSCompatFullScreen?: boolean; // ios doesn't support fullscreen divs so we must support the video element
11+
pip?: boolean;
1112
onPlaying?: () => void;
1213
};
1314

@@ -18,6 +19,7 @@ export default function WebRtcPlayer({
1819
audioEnabled = false,
1920
microphoneEnabled = false,
2021
iOSCompatFullScreen = false,
22+
pip = false,
2123
onPlaying,
2224
}: WebRtcPlayerProps) {
2325
// metadata
@@ -173,8 +175,19 @@ export default function WebRtcPlayer({
173175
]);
174176

175177
// ios compat
178+
176179
const [iOSCompatControls, setiOSCompatControls] = useState(false);
177180

181+
// control pip
182+
183+
useEffect(() => {
184+
if (!videoRef.current || !pip) {
185+
return;
186+
}
187+
188+
videoRef.current.requestPictureInPicture();
189+
}, [pip, videoRef]);
190+
178191
return (
179192
<video
180193
ref={videoRef}

0 commit comments

Comments
 (0)