From c2391ba11398b95648cf0031a8ec44e3575485c4 Mon Sep 17 00:00:00 2001 From: tom-heidenreich Date: Tue, 21 Jan 2025 09:55:59 +0100 Subject: [PATCH] feat: display metadata for specific media type --- app/(auth)/player/google-cast-player.tsx | 78 ++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/app/(auth)/player/google-cast-player.tsx b/app/(auth)/player/google-cast-player.tsx index 1db2d642..0048588a 100644 --- a/app/(auth)/player/google-cast-player.tsx +++ b/app/(auth)/player/google-cast-player.tsx @@ -272,12 +272,20 @@ function ChromecastControls({ mediaStatus, client }: { mediaStatus: MediaStatus, const mediaMetadata = mediaStatus.mediaInfo?.metadata; - const title = mediaMetadata?.title || 'Title not found!' const type = mediaMetadata?.type || 'generic' const images = mediaMetadata?.images || [] const blurhash = '|rF?hV%2WCj[ayj[a|j[az_NaeWBj@ayfRayfQfQM{M|azj[azf6fQfQfQIpWXofj[ayj[j[fQayWCoeoeaya}j[ayfQa{oLj?j[WVj[ayayj[fQoff7azayj[ayj[j[ayofayayayj[fQj[ayayj[ayfjj[j[ayjuayj['; + const ItemInfo = useMemo(() => { + switch(type) { + case 'generic': return + case 'movie': return + case 'tvShow': return + default: return {type} not implemented yet! + } + }, [type]) + return ( @@ -286,11 +294,12 @@ function ChromecastControls({ mediaStatus, client }: { mediaStatus: MediaStatus, tint='dark' experimentalBlurMethod='dimezisBlurView' > - - {title} - {mediaStatus.playerState} + + + {ItemInfo} + ) +} + +type MetadataInfoProps = { mediaMetadata: MediaInfo['metadata'] } + +function GenericInfo({ mediaMetadata }: MetadataInfoProps) { + + const title = mediaMetadata?.title || 'Title not found!' + + return ( + <> + {title} + { + // @ts-expect-error The metadata type doesn't have subtitle, but the object has + mediaMetadata?.subtitle && {mediaMetadata?.subtitle} + } + + ) +} + +function MovieInfo({ mediaMetadata }: MetadataInfoProps) { + + const title = mediaMetadata?.title || 'Title not found!' + + return ( + <> + {title} + { + // @ts-expect-error The metadata type doesn't have subtitle, but the object has + mediaMetadata?.subtitle && {mediaMetadata?.subtitle} + } + + ) +} + +function TvShowInfo({ mediaMetadata }: MetadataInfoProps) { + + const itemTitle: string = mediaMetadata?.title || 'Title not found!' + // @ts-expect-error + const seriesTitle: string = mediaMetadata?.seriesTitle || 'Title not found!' + + // @ts-expect-error + const episodeNumber: number = mediaMetadata?.episodeNumber || 0 + // @ts-expect-error + const seasonNumber: number = mediaMetadata?.seasonNumber || 0 + + return ( + <> + + {seriesTitle} + {itemTitle} + + + Season {seasonNumber.toLocaleString()} {' '} + Episode {episodeNumber.toLocaleString()} + + + ) } \ No newline at end of file