From 02c7fe5fa13bc833423e5f13a35fe646678488fd Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Tue, 13 May 2025 15:46:44 -0600 Subject: [PATCH] add widescreen button hold feat hold the fullscreen button to switch to the widescreen button. --- src/assets/locales/en.json | 2 +- src/pages/parts/player/PlayerPart.tsx | 34 ++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index 68494fc4..35cad4a1 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -604,7 +604,7 @@ "tips": { "1": "Tap the gear icon to switch sources!", "2": "Tap the title to copy the link!", - "3": "Hold SHIFT for widescreen instead of fullscreen!", + "3": "Tap and hold or hold SHIFT to show widescreen button instead of fullscreen!", "4": "Some sources work better than others!", "5": "Get the extension for more sources!", "6": "Hold bookmarks to edit or delete them!", diff --git a/src/pages/parts/player/PlayerPart.tsx b/src/pages/parts/player/PlayerPart.tsx index 5e254332..9a423e68 100644 --- a/src/pages/parts/player/PlayerPart.tsx +++ b/src/pages/parts/player/PlayerPart.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useState } from "react"; +import { ReactNode, useEffect, useRef, useState } from "react"; import IosPwaLimitations from "@/components/buttons/IosPwaLimitations"; import { BrandPill } from "@/components/layout/BrandPill"; @@ -31,8 +31,9 @@ export function PlayerPart(props: PlayerPartProps) { const isIOSPWA = isIOS && window.matchMedia("(display-mode: standalone)").matches; - // Detect if Shift key is being held const [isShifting, setIsShifting] = useState(false); + const [isHoldingFullscreen, setIsHoldingFullscreen] = useState(false); + const holdTimeoutRef = useRef(null); document.addEventListener("keydown", (event) => { if (event.key === "Shift") { @@ -46,6 +47,24 @@ export function PlayerPart(props: PlayerPartProps) { } }); + const handleTouchStart = () => { + if (holdTimeoutRef.current) { + clearTimeout(holdTimeoutRef.current); + } + holdTimeoutRef.current = setTimeout(() => { + setIsHoldingFullscreen(true); + }, 100); + }; + + const handleTouchEnd = () => { + if (holdTimeoutRef.current) { + clearTimeout(holdTimeoutRef.current); + } + holdTimeoutRef.current = setTimeout(() => { + setIsHoldingFullscreen(false); + }, 1000); + }; + const skiptime = useSkipTime(); return ( @@ -176,7 +195,16 @@ export function PlayerPart(props: PlayerPartProps) {
{/* iOS PWA */} - {!isIOSPWA && } + {!isIOSPWA && ( +
+ {isHoldingFullscreen ? : } +
+ )} {isIOSPWA && status === playerStatus.PLAYING && }