Allow tap to toggle controls so zooming still works

This commit is contained in:
Nicolas Mowen 2024-03-15 11:12:25 -06:00
parent 4122462f50
commit 56c4b97321
3 changed files with 33 additions and 15 deletions

View File

@ -21,6 +21,7 @@ type LivePlayerProps = {
windowVisible?: boolean; windowVisible?: boolean;
playAudio?: boolean; playAudio?: boolean;
micEnabled?: boolean; // only webrtc supports mic micEnabled?: boolean; // only webrtc supports mic
iOSCompatFullScreen?: boolean;
onClick?: () => void; onClick?: () => void;
}; };
@ -32,6 +33,7 @@ export default function LivePlayer({
windowVisible = true, windowVisible = true,
playAudio = false, playAudio = false,
micEnabled = false, micEnabled = false,
iOSCompatFullScreen = false,
onClick, onClick,
}: LivePlayerProps) { }: LivePlayerProps) {
// camera activity // camera activity
@ -100,6 +102,7 @@ export default function LivePlayer({
playbackEnabled={cameraActive} playbackEnabled={cameraActive}
audioEnabled={playAudio} audioEnabled={playAudio}
microphoneEnabled={micEnabled} microphoneEnabled={micEnabled}
iOSCompatFullScreen={iOSCompatFullScreen}
onPlaying={() => setLiveReady(true)} onPlaying={() => setLiveReady(true)}
/> />
); );

View File

@ -1,5 +1,5 @@
import { baseUrl } from "@/api/baseUrl"; import { baseUrl } from "@/api/baseUrl";
import { useCallback, useEffect, useMemo, useRef } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react";
type WebRtcPlayerProps = { type WebRtcPlayerProps = {
className?: string; className?: string;
@ -7,6 +7,7 @@ type WebRtcPlayerProps = {
playbackEnabled?: boolean; playbackEnabled?: boolean;
audioEnabled?: boolean; audioEnabled?: boolean;
microphoneEnabled?: boolean; microphoneEnabled?: boolean;
iOSCompatFullScreen?: boolean; // ios doesn't support fullscreen divs so we must support the video element
onPlaying?: () => void; onPlaying?: () => void;
}; };
@ -16,6 +17,7 @@ export default function WebRtcPlayer({
playbackEnabled = true, playbackEnabled = true,
audioEnabled = false, audioEnabled = false,
microphoneEnabled = false, microphoneEnabled = false,
iOSCompatFullScreen = false,
onPlaying, onPlaying,
}: WebRtcPlayerProps) { }: WebRtcPlayerProps) {
// metadata // metadata
@ -170,14 +172,23 @@ export default function WebRtcPlayer({
microphoneEnabled, microphoneEnabled,
]); ]);
// ios compat
const [iOSCompatControls, setiOSCompatControls] = useState(false);
return ( return (
<video <video
ref={videoRef} ref={videoRef}
className={className} className={className}
controls={iOSCompatControls}
autoPlay autoPlay
playsInline playsInline
muted={!audioEnabled} muted={!audioEnabled}
onLoadedData={onPlaying} onLoadedData={onPlaying}
onClick={
iOSCompatFullScreen
? () => setiOSCompatControls(!iOSCompatControls)
: undefined
}
/> />
); );
} }

View File

@ -28,6 +28,7 @@ import React, {
} from "react"; } from "react";
import { import {
isDesktop, isDesktop,
isIOS,
isMobile, isMobile,
isSafari, isSafari,
useMobileOrientation, useMobileOrientation,
@ -189,6 +190,7 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {
<div <div
className={`flex flex-row items-center gap-2 mr-1 *:rounded-lg ${isMobile ? "landscape:flex-col" : ""}`} className={`flex flex-row items-center gap-2 mr-1 *:rounded-lg ${isMobile ? "landscape:flex-col" : ""}`}
> >
{!isIOS && (
<CameraFeatureToggle <CameraFeatureToggle
className="p-2 md:p-0" className="p-2 md:p-0"
variant={fullscreen ? "overlay" : "primary"} variant={fullscreen ? "overlay" : "primary"}
@ -203,6 +205,7 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {
} }
}} }}
/> />
)}
{window.isSecureContext && ( {window.isSecureContext && (
<CameraFeatureToggle <CameraFeatureToggle
className="p-2 md:p-0" className="p-2 md:p-0"
@ -286,6 +289,7 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {
cameraConfig={camera} cameraConfig={camera}
playAudio={audio} playAudio={audio}
micEnabled={mic} micEnabled={mic}
iOSCompatFullScreen={isIOS}
preferredLiveMode={preferredLiveMode} preferredLiveMode={preferredLiveMode}
/> />
</div> </div>