mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-29 16:23:16 +00:00
fix speed boost for mobile
This commit is contained in:
parent
826254757a
commit
18c3588fba
1 changed files with 15 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import { useShouldShowVideoElement } from "@/components/player/internals/VideoCo
|
||||||
import { useOverlayStack } from "@/stores/interface/overlayStack";
|
import { useOverlayStack } from "@/stores/interface/overlayStack";
|
||||||
import { PlayerHoverState } from "@/stores/player/slices/interface";
|
import { PlayerHoverState } from "@/stores/player/slices/interface";
|
||||||
import { usePlayerStore } from "@/stores/player/store";
|
import { usePlayerStore } from "@/stores/player/store";
|
||||||
|
import { useWatchPartyStore } from "@/stores/watchParty";
|
||||||
|
|
||||||
export function VideoClickTarget(props: { showingControls: boolean }) {
|
export function VideoClickTarget(props: { showingControls: boolean }) {
|
||||||
const show = useShouldShowVideoElement();
|
const show = useShouldShowVideoElement();
|
||||||
|
|
@ -19,6 +20,7 @@ export function VideoClickTarget(props: { showingControls: boolean }) {
|
||||||
const setShowSpeedIndicator = usePlayerStore((s) => s.setShowSpeedIndicator);
|
const setShowSpeedIndicator = usePlayerStore((s) => s.setShowSpeedIndicator);
|
||||||
const hovering = usePlayerStore((s) => s.interface.hovering);
|
const hovering = usePlayerStore((s) => s.interface.hovering);
|
||||||
const setCurrentOverlay = useOverlayStack((s) => s.setCurrentOverlay);
|
const setCurrentOverlay = useOverlayStack((s) => s.setCurrentOverlay);
|
||||||
|
const isInWatchParty = useWatchPartyStore((s) => s.enabled);
|
||||||
|
|
||||||
const [_, cancel, reset] = useTimeoutFn(() => {
|
const [_, cancel, reset] = useTimeoutFn(() => {
|
||||||
updateInterfaceHovering(PlayerHoverState.NOT_HOVERING);
|
updateInterfaceHovering(PlayerHoverState.NOT_HOVERING);
|
||||||
|
|
@ -82,7 +84,13 @@ export function VideoClickTarget(props: { showingControls: boolean }) {
|
||||||
|
|
||||||
const handlePointerDown = useCallback(
|
const handlePointerDown = useCallback(
|
||||||
(e: PointerEvent<HTMLDivElement>) => {
|
(e: PointerEvent<HTMLDivElement>) => {
|
||||||
if (e.pointerType === "mouse" && e.button === 0 && !isPaused) {
|
if (
|
||||||
|
((e.pointerType === "mouse" && e.button === 0) ||
|
||||||
|
e.pointerType === "touch") &&
|
||||||
|
!isInWatchParty
|
||||||
|
) {
|
||||||
|
if (isPaused) return; // Don't boost if video is paused
|
||||||
|
|
||||||
// Store current rate before changing
|
// Store current rate before changing
|
||||||
previousRateRef.current = playbackRate;
|
previousRateRef.current = playbackRate;
|
||||||
|
|
||||||
|
|
@ -119,6 +127,7 @@ export function VideoClickTarget(props: { showingControls: boolean }) {
|
||||||
setSpeedBoosted,
|
setSpeedBoosted,
|
||||||
setShowSpeedIndicator,
|
setShowSpeedIndicator,
|
||||||
setCurrentOverlay,
|
setCurrentOverlay,
|
||||||
|
isInWatchParty,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -132,7 +141,11 @@ export function VideoClickTarget(props: { showingControls: boolean }) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHoldingRef.current && e.pointerType === "mouse" && e.button === 0) {
|
if (
|
||||||
|
isHoldingRef.current &&
|
||||||
|
((e.pointerType === "mouse" && e.button === 0) ||
|
||||||
|
e.pointerType === "touch")
|
||||||
|
) {
|
||||||
// Restore previous rate
|
// Restore previous rate
|
||||||
display?.setPlaybackRate(previousRateRef.current);
|
display?.setPlaybackRate(previousRateRef.current);
|
||||||
isHoldingRef.current = false;
|
isHoldingRef.current = false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue