From 7ea111322b5a9d9bae0041a0db732bf06fc50ba2 Mon Sep 17 00:00:00 2001 From: Deluan Date: Thu, 16 Mar 2023 17:25:07 -0400 Subject: [PATCH] Don't pump the volume up to 100% if it is not in a mobile device. Fix #2255 This detection method is not bullet-proof, but should work for now. Ref: https://stackoverflow.com/a/3540295 --- ui/src/audioplayer/Player.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/src/audioplayer/Player.js b/ui/src/audioplayer/Player.js index 73f17f26..6b472017 100644 --- a/ui/src/audioplayer/Player.js +++ b/ui/src/audioplayer/Player.js @@ -46,9 +46,11 @@ const Player = () => { const [preloaded, setPreload] = useState(false) const [audioInstance, setAudioInstance] = useState(null) const isDesktop = useMediaQuery('(min-width:810px)') - const isMobilePlayer = useMediaQuery( - '(max-width: 768px) and (orientation : portrait)' - ) + const isMobilePlayer = + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( + navigator.userAgent + ) + const { authenticated } = useAuthState() const visible = authenticated && playerState.queue.length > 0 const isRadio = playerState.current?.isRadio || false