diff --git a/src/components/player/base/Container.tsx b/src/components/player/base/Container.tsx
index 13f1371f..8e2aa67f 100644
--- a/src/components/player/base/Container.tsx
+++ b/src/components/player/base/Container.tsx
@@ -64,9 +64,7 @@ function BaseContainer(props: { children?: ReactNode }) {
return (
-
- {props.children}
-
+ {props.children}
);
@@ -80,11 +78,13 @@ export function Container(props: PlayerProps) {
return (
-
-
-
- {props.children}
+
+
+
+
+ {props.children}
+
);
diff --git a/src/components/player/hooks/useShouldShowControls.tsx b/src/components/player/hooks/useShouldShowControls.tsx
index ed74b742..3d76cb4e 100644
--- a/src/components/player/hooks/useShouldShowControls.tsx
+++ b/src/components/player/hooks/useShouldShowControls.tsx
@@ -1,7 +1,7 @@
import { PlayerHoverState } from "@/stores/player/slices/interface";
import { usePlayerStore } from "@/stores/player/store";
-export function useShouldShowControls(opts?: { touchOnly: boolean }) {
+export function useShouldShowControls() {
const hovering = usePlayerStore((s) => s.interface.hovering);
const lastHoveringState = usePlayerStore(
(s) => s.interface.lastHoveringState
@@ -9,12 +9,18 @@ export function useShouldShowControls(opts?: { touchOnly: boolean }) {
const isPaused = usePlayerStore((s) => s.mediaPlaying.isPaused);
const hasOpenOverlay = usePlayerStore((s) => s.interface.hasOpenOverlay);
- const showTouchControls =
- lastHoveringState === PlayerHoverState.MOBILE_TAPPED;
- const notNotHovering = hovering !== PlayerHoverState.NOT_HOVERING;
+ const isUsingTouch = lastHoveringState === PlayerHoverState.MOBILE_TAPPED;
+ const isHovering = hovering !== PlayerHoverState.NOT_HOVERING;
- if (opts?.touchOnly)
- return (showTouchControls && notNotHovering) || isPaused || hasOpenOverlay;
+ // when using touch, pause screens can be dismissed by tapping
+ const showTargetsWithoutPause = isHovering || hasOpenOverlay;
+ const showTargetsIncludingPause = showTargetsWithoutPause || isPaused;
+ const showTargets = isUsingTouch
+ ? showTargetsWithoutPause
+ : showTargetsIncludingPause;
- return notNotHovering || isPaused || hasOpenOverlay;
+ return {
+ showTouchTargets: isUsingTouch && showTargets,
+ showTargets,
+ };
}
diff --git a/src/components/player/internals/VideoClickTarget.tsx b/src/components/player/internals/VideoClickTarget.tsx
index d8dcd4aa..f57cd704 100644
--- a/src/components/player/internals/VideoClickTarget.tsx
+++ b/src/components/player/internals/VideoClickTarget.tsx
@@ -19,18 +19,20 @@ export function VideoClickTarget() {
const togglePause = useCallback(
(e: PointerEvent) => {
- // pause on mouse click
- if (e.pointerType === "mouse") {
- if (e.button !== 0) return;
- if (isPaused) display?.play();
- else display?.pause();
- return;
- }
+ setTimeout(() => {
+ // pause on mouse click
+ if (e.pointerType === "mouse") {
+ if (e.button !== 0) return;
+ if (isPaused) display?.play();
+ else display?.pause();
+ return;
+ }
- // toggle on other types of clicks
- if (hovering !== PlayerHoverState.MOBILE_TAPPED)
- updateInterfaceHovering(PlayerHoverState.MOBILE_TAPPED);
- else updateInterfaceHovering(PlayerHoverState.NOT_HOVERING);
+ // toggle on other types of clicks
+ if (hovering !== PlayerHoverState.MOBILE_TAPPED)
+ updateInterfaceHovering(PlayerHoverState.MOBILE_TAPPED);
+ else updateInterfaceHovering(PlayerHoverState.NOT_HOVERING);
+ }, 10); // TODO this is dirty workaround, without this, tapping on something where a button will be will trigger it immediately
},
[display, isPaused, hovering, updateInterfaceHovering]
);
diff --git a/src/pages/PlayerView.tsx b/src/pages/PlayerView.tsx
index eb7bdaa6..2f9f0eac 100644
--- a/src/pages/PlayerView.tsx
+++ b/src/pages/PlayerView.tsx
@@ -7,20 +7,15 @@ import { AutoPlayStart } from "@/components/player/atoms";
import { usePlayer } from "@/components/player/hooks/usePlayer";
import { useShouldShowControls } from "@/components/player/hooks/useShouldShowControls";
import { ScrapingPart } from "@/pages/parts/player/ScrapingPart";
-import { PlayerHoverState } from "@/stores/player/slices/interface";
import {
PlayerMeta,
metaToScrapeMedia,
playerStatus,
} from "@/stores/player/slices/source";
-import { usePlayerStore } from "@/stores/player/store";
export function PlayerView() {
const { status, setScrapeStatus, playMedia, setMeta } = usePlayer();
- const { lastHoveringState } = usePlayerStore((s) => s.interface);
-
- const desktopControlsVisible = useShouldShowControls();
- const touchControlsVisible = useShouldShowControls({ touchOnly: true });
+ const { showTargets, showTouchTargets } = useShouldShowControls();
const meta = useMemo(
() => ({
@@ -70,7 +65,7 @@ export function PlayerView() {
/>
) : null}
-
+
@@ -79,14 +74,14 @@ export function PlayerView() {
-
+
@@ -103,7 +98,7 @@ export function PlayerView() {
-
+