From 45ba24bb5dd961a052f25d4a9fec5400f18afbf5 Mon Sep 17 00:00:00 2001 From: xdzqyyds <139134069+xdzqyyds@users.noreply.github.com> Date: Sun, 24 Nov 2024 00:24:38 +0800 Subject: [PATCH] feat(webapp): hide share screen button at mobile device (#23) * Hide share screen button at mobile device * fix video screen label * improve(webapp): hide share screen button at mobile device --------- Co-authored-by: a-wing <1@233.email> --- webapp/components/device.tsx | 37 ++++++++++++++++------------- webapp/components/player/player.tsx | 8 +++---- webapp/store/atom.ts | 12 ++++++++-- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/webapp/components/device.tsx b/webapp/components/device.tsx index fad64e9..610bb8d 100644 --- a/webapp/components/device.tsx +++ b/webapp/components/device.tsx @@ -6,7 +6,7 @@ import { deviceNone, deviceScreen, } from '../lib/device' -import { deviceSpeakerAtom, SpeakerStatusAtom } from './../store/atom' +import { deviceSpeakerAtom, speakerStatusAtom, settingsEnabledScreenAtom } from './../store/atom' import Loading from './svg/loading' import SvgSpeaker from './svg/speaker' @@ -33,7 +33,9 @@ export default function DeviceBar(props: { streamId: string }) { const [loadingScreen, setLoadingScreen] = useState(false) const [currentDeviceSpeaker, setCurrentDeviceSpeaker] = useAtom(deviceSpeakerAtom) - const [SpeakerStatus, setSpeakerStatus] = useAtom(SpeakerStatusAtom) + const [speakerStatus, setSpeakerStatus] = useAtom(speakerStatusAtom) + + const [settingsEnabledScreen] = useAtom(settingsEnabledScreenAtom) const { userStatus, @@ -111,7 +113,7 @@ export default function DeviceBar(props: { streamId: string }) { setDeviceSpeaker([...speakers]) setDeviceAudio([...audios]) - setDeviceVideo([...videos, deviceScreen]) + setDeviceVideo(settingsEnabledScreen ? [...videos] : [...videos, deviceScreen]) } const init = async () => { @@ -182,7 +184,7 @@ export default function DeviceBar(props: { streamId: string }) {
- {SpeakerStatus + {speakerStatus ?
:
-
-
- -
- -
+ {!settingsEnabledScreen && ( +
+
+ +
+
+ )}
) } diff --git a/webapp/components/player/player.tsx b/webapp/components/player/player.tsx index d60ab89..c20c151 100644 --- a/webapp/components/player/player.tsx +++ b/webapp/components/player/player.tsx @@ -4,7 +4,7 @@ import WaveSurfer from 'wavesurfer.js' import RecordPlugin from 'wavesurfer.js/dist/plugins/record' import { isWechat } from '../../lib/util' import SvgProgress from '../svg/progress' -import { deviceSpeakerAtom, SpeakerStatusAtom } from '../../store/atom' +import { deviceSpeakerAtom, speakerStatusAtom } from '../../store/atom' function AudioWave(props: { stream: MediaStream }) { const refWave = useRef(null) @@ -37,7 +37,7 @@ export default function Player(props: { stream: MediaStream, muted: boolean, aud const audioTrack = props.stream.getAudioTracks()[0] const videoTrack = props.stream.getVideoTracks()[0] const [currentDeviceSpeaker] = useAtom(deviceSpeakerAtom) - const [SpeakerStatus] = useAtom(SpeakerStatusAtom) + const [speakerStatus] = useAtom(speakerStatusAtom) useEffect(() => { if (audioTrack && !videoTrack) { @@ -53,7 +53,7 @@ export default function Player(props: { stream: MediaStream, muted: boolean, aud el.setSinkId(currentDeviceSpeaker) } - el.muted = !SpeakerStatus + el.muted = !speakerStatus el.play() return () => { @@ -62,7 +62,7 @@ export default function Player(props: { stream: MediaStream, muted: boolean, aud el.remove() } } - }, [audioTrack, videoTrack, currentDeviceSpeaker, SpeakerStatus]) + }, [audioTrack, videoTrack, currentDeviceSpeaker, speakerStatus]) useEffect(() => { if (refVideo.current && videoTrack) { diff --git a/webapp/store/atom.ts b/webapp/store/atom.ts index 2a23057..9e5ab5d 100644 --- a/webapp/store/atom.ts +++ b/webapp/store/atom.ts @@ -36,7 +36,13 @@ const enabledPresentationAtom = atom(get => get(presentationStreamAtom).stream.g enabledPresentationAtom.debugLabel = 'enabledPresentation' const deviceSpeakerAtom = atom('') -const SpeakerStatusAtom = atom(true) +deviceSpeakerAtom.debugLabel = 'deviceSpeaker' +const speakerStatusAtom = atom(true) +speakerStatusAtom.debugLabel = 'speakerStatus' + +// Mobile device don't support share screen, For Mobile device default disabled +const settingsEnabledScreenAtom = atom(/Mobi|Android|iPhone|iPad|HarmonyOS|HMSCore/i.test(navigator.userAgent)) +settingsEnabledScreenAtom.debugLabel = 'settingsEnabledScreen' export { locationAtom, @@ -46,7 +52,9 @@ export { meetingJoinedAtom, enabledPresentationAtom, deviceSpeakerAtom, - SpeakerStatusAtom, + speakerStatusAtom, + + settingsEnabledScreenAtom, } export type {