/** * Mini Chromecast player bar shown at the bottom of the screen * Similar to music player mini bar */ import { Ionicons } from "@expo/vector-icons"; import { useRouter } from "expo-router"; import React from "react"; import { Pressable, View } from "react-native"; import Animated, { FadeIn, FadeOut, SlideInDown, SlideOutDown, } from "react-native-reanimated"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { Text } from "@/components/common/Text"; import { formatEpisodeInfo, truncateTitle } from "@/utils/chromecast/helpers"; import { CHROMECAST_CONSTANTS } from "@/utils/chromecast/options"; import { useChromecastPlayer } from "./hooks/useChromecastPlayer"; export const ChromecastMiniPlayer: React.FC = () => { const router = useRouter(); const insets = useSafeAreaInsets(); const { playerState, currentItem, togglePlay, showNextEpisodeCountdown } = useChromecastPlayer(); // Don't show if not connected or no media if (!playerState.isConnected || !playerState.currentItemId) { return null; } const handlePress = () => { router.push("/chromecast-player"); }; const progress = playerState.duration > 0 ? (playerState.progress / playerState.duration) * 100 : 0; return ( {/* Progress bar */} {/* Cast icon */} {/* Media info */} {currentItem && ( <> {truncateTitle(currentItem.Name || "Unknown", 40)} {formatEpisodeInfo( currentItem.ParentIndexNumber, currentItem.IndexNumber, )} {showNextEpisodeCountdown && ( Next episode starting... )} )} {!currentItem && ( <> Casting to {playerState.deviceName || "Chromecast"} {playerState.isPlaying ? "Playing" : "Paused"} )} {/* Play/Pause button */} { e.stopPropagation(); togglePlay(); }} style={{ width: 48, height: 48, justifyContent: "center", alignItems: "center", }} > {playerState.isBuffering ? ( ) : ( )} ); };