/** * Unified Casting Mini Player * Works with both Chromecast and AirPlay */ import { Ionicons } from "@expo/vector-icons"; import { Image } from "expo-image"; import { router } from "expo-router"; import { useAtomValue } from "jotai"; import React from "react"; import { Pressable, View } from "react-native"; import Animated, { SlideInDown, SlideOutDown } from "react-native-reanimated"; import { Text } from "@/components/common/Text"; import { useCasting } from "@/hooks/useCasting"; import { apiAtom } from "@/providers/JellyfinProvider"; import { formatTime, getPosterUrl, getProtocolIcon, getProtocolName, } from "@/utils/casting/helpers"; import { CASTING_CONSTANTS, PROTOCOL_COLORS } from "@/utils/casting/types"; export const CastingMiniPlayer: React.FC = () => { const api = useAtomValue(apiAtom); const { isConnected, protocol, currentItem, currentDevice, progress, duration, isPlaying, togglePlayPause, } = useCasting(null); if (!isConnected || !currentItem || !protocol) { return null; } const posterUrl = getPosterUrl( api?.basePath, currentItem.Id, currentItem.ImageTags?.Primary, 80, 120, ); const progressPercent = duration > 0 ? (progress / duration) * 100 : 0; const protocolColor = PROTOCOL_COLORS[protocol]; const handlePress = () => { router.push("/casting-player"); }; return ( {/* Progress bar */} {/* Content */} {/* Poster */} {posterUrl && ( )} {/* Info */} {currentItem.Name} {currentItem.SeriesName && ( {currentItem.SeriesName} )} {currentDevice?.name || getProtocolName(protocol)} {formatTime(progress)} / {formatTime(duration)} {/* Play/Pause button */} { e.stopPropagation(); togglePlayPause(); }} style={{ padding: 8, }} > ); };