diff --git a/components/player/AutoplayCountdown.tsx b/components/player/AutoplayCountdown.tsx new file mode 100644 index 000000000..9374d9d40 --- /dev/null +++ b/components/player/AutoplayCountdown.tsx @@ -0,0 +1,103 @@ +/** + * Player-agnostic "next episode" countdown card. The parent owns the timer and + * positioning — this component only renders the next episode's poster, title, + * the remaining seconds, and the Play-now / Cancel actions. + */ + +import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; +import { Image } from "expo-image"; +import { useTranslation } from "react-i18next"; +import { Pressable, View } from "react-native"; +import { Text } from "@/components/common/Text"; + +interface AutoplayCountdownProps { + /** The episode that will play next. */ + nextEpisode: BaseItemDto; + /** Poster image URL for the next episode, or null. */ + posterUrl: string | null; + /** Seconds left before the next episode plays. */ + secondsRemaining: number; + /** Play the next episode immediately. */ + onPlayNow: () => void; + /** Cancel autoplay — the next episode will not play. */ + onCancel: () => void; +} + +export function AutoplayCountdown({ + nextEpisode, + posterUrl, + secondsRemaining, + onPlayNow, + onCancel, +}: AutoplayCountdownProps) { + const { t } = useTranslation(); + + return ( + + {posterUrl && ( + + )} + + + + {t("player.up_next")} + + + {nextEpisode.Name} + + + {t("player.next_episode_in", { seconds: secondsRemaining })} + + + + + + {t("player.play_now")} + + + + + {t("player.cancel")} + + + + + + ); +} diff --git a/translations/en.json b/translations/en.json index 3b57e5d00..b3789acdd 100644 --- a/translations/en.json +++ b/translations/en.json @@ -47,7 +47,11 @@ "downloaded_file_message": "Do you want to play the downloaded file?", "downloaded_file_yes": "Yes", "downloaded_file_no": "No", - "downloaded_file_cancel": "Cancel" + "downloaded_file_cancel": "Cancel", + "up_next": "Up next", + "next_episode_in": "Next episode in {{seconds}}s", + "play_now": "Play now", + "cancel": "Cancel" }, "casting_player": { "buffering": "Buffering...",