mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-17 09:53:02 +01:00
fix(casting): trickplay bubble positioning and mini-player preview
Position the trickplay/scrub bubble above the progress bar and let the slider own horizontal placement (bubbleMaxWidth/bubbleWidth = tile width) so the preview tracks the cursor and is clamped at the track edges. Wire the mini-player trickplay to the fetched full item and size its tile/thumb.
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { Image } from "expo-image";
|
import { Image } from "expo-image";
|
||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
import { useAtomValue } from "jotai";
|
import { useAtomValue } from "jotai";
|
||||||
@@ -25,22 +24,22 @@ import Animated, {
|
|||||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||||
import { CastTrickplayBubble } from "@/components/casting/player/CastTrickplayBubble";
|
import { CastTrickplayBubble } from "@/components/casting/player/CastTrickplayBubble";
|
||||||
import { Text } from "@/components/common/Text";
|
import { Text } from "@/components/common/Text";
|
||||||
|
import { useCastPlayerItem } from "@/hooks/useCastPlayerItem";
|
||||||
import { useTrickplay } from "@/hooks/useTrickplay";
|
import { useTrickplay } from "@/hooks/useTrickplay";
|
||||||
import { apiAtom } from "@/providers/JellyfinProvider";
|
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
|
||||||
import { formatTime, getPosterUrl } from "@/utils/casting/helpers";
|
import { formatTime, getPosterUrl } from "@/utils/casting/helpers";
|
||||||
import { CASTING_CONSTANTS } from "@/utils/casting/types";
|
import { CASTING_CONSTANTS } from "@/utils/casting/types";
|
||||||
import { msToTicks, ticksToSeconds } from "@/utils/time";
|
import { msToTicks, ticksToSeconds } from "@/utils/time";
|
||||||
|
|
||||||
export const CastingMiniPlayer: React.FC = () => {
|
export const CastingMiniPlayer: React.FC = () => {
|
||||||
const api = useAtomValue(apiAtom);
|
const api = useAtomValue(apiAtom);
|
||||||
|
const user = useAtomValue(userAtom);
|
||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
const castDevice = useCastDevice();
|
const castDevice = useCastDevice();
|
||||||
const mediaStatus = useMediaStatus();
|
const mediaStatus = useMediaStatus();
|
||||||
const remoteMediaClient = useRemoteMediaClient();
|
const remoteMediaClient = useRemoteMediaClient();
|
||||||
|
|
||||||
const currentItem = useMemo(() => {
|
const { currentItem } = useCastPlayerItem({ api, user, mediaStatus });
|
||||||
return mediaStatus?.mediaInfo?.customData as BaseItemDto | undefined;
|
|
||||||
}, [mediaStatus?.mediaInfo?.customData]);
|
|
||||||
|
|
||||||
// Trickplay support - pass currentItem as BaseItemDto or null
|
// Trickplay support - pass currentItem as BaseItemDto or null
|
||||||
const { trickPlayUrl, calculateTrickplayUrl, trickplayInfo } = useTrickplay(
|
const { trickPlayUrl, calculateTrickplayUrl, trickplayInfo } = useTrickplay(
|
||||||
@@ -237,12 +236,14 @@ export const CastingMiniPlayer: React.FC = () => {
|
|||||||
trickPlayUrl={trickPlayUrl}
|
trickPlayUrl={trickPlayUrl}
|
||||||
trickplayInfo={trickplayInfo}
|
trickplayInfo={trickplayInfo}
|
||||||
trickplayTime={trickplayTime}
|
trickplayTime={trickplayTime}
|
||||||
tileWidth={140}
|
tileWidth={190}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
bubbleWidth={trickPlayUrl && trickplayInfo ? 140 : 60}
|
bubbleMaxWidth={190}
|
||||||
|
bubbleWidth={190}
|
||||||
|
bubbleTranslateY={-20}
|
||||||
sliderHeight={3}
|
sliderHeight={3}
|
||||||
thumbWidth={10}
|
thumbWidth={14}
|
||||||
panHitSlop={{ top: 20, bottom: 20, left: 5, right: 5 }}
|
panHitSlop={{ top: 20, bottom: 20, left: 5, right: 5 }}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -119,7 +119,9 @@ export function CastPlayerProgressBar({
|
|||||||
tileWidth={220}
|
tileWidth={220}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
bubbleWidth={trickPlayUrl && trickplayInfo ? 220 : 64}
|
bubbleMaxWidth={220}
|
||||||
|
bubbleWidth={220}
|
||||||
|
bubbleTranslateY={-20}
|
||||||
sliderHeight={6}
|
sliderHeight={6}
|
||||||
thumbWidth={16}
|
thumbWidth={16}
|
||||||
panHitSlop={{ top: 12, bottom: 12, left: 10, right: 10 }}
|
panHitSlop={{ top: 12, bottom: 12, left: 10, right: 10 }}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* Shared scrub-preview bubble for the casting progress bars.
|
* Shared scrub-preview bubble for the casting progress bars.
|
||||||
*
|
*
|
||||||
* Renders the trickplay tile (when trickplay data is available) with the scrub
|
* The slider (`react-native-awesome-slider`) sizes, centres and clamps this
|
||||||
* time as plain text above it, or just the scrub time as plain text. It does NO
|
* bubble on the thumb via its `bubbleMaxWidth` / `bubbleWidth` props. This
|
||||||
* positioning of its own — the slider places it via its `bubbleWidth` prop.
|
* component therefore does NO horizontal positioning — it only anchors itself
|
||||||
|
* vertically (`bottom: 0`, growing upward) so it sits above the progress bar.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Image } from "expo-image";
|
import { Image } from "expo-image";
|
||||||
@@ -47,16 +48,39 @@ export function CastTrickplayBubble({
|
|||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|
||||||
// No trickplay: just the plain time text.
|
// Anchored to the bottom of the slider-positioned container, growing upward,
|
||||||
|
// and filling the container width (left/right: 0) so it stays centred on the
|
||||||
|
// thumb. No horizontal maths here — the slider owns horizontal placement.
|
||||||
if (!trickPlayUrl || !trickplayInfo) {
|
if (!trickPlayUrl || !trickplayInfo) {
|
||||||
return timeText;
|
return (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{timeText}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { x, y, url } = trickPlayUrl;
|
const { x, y, url } = trickPlayUrl;
|
||||||
const tileHeight = tileWidth / (trickplayInfo.aspectRatio ?? 1.78);
|
const tileHeight = tileWidth / (trickplayInfo.aspectRatio ?? 1.78);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ width: tileWidth, alignItems: "center", gap: 4 }}>
|
<View
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 4,
|
||||||
|
}}
|
||||||
|
>
|
||||||
{timeText}
|
{timeText}
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
Reference in New Issue
Block a user