feat: add playlist playback support
This commit is contained in:
6 files changed
+678
-256
No files matched your search
@@ -147,12 +147,18 @@ const PlayButton = ({
|
|||||||
// startItemId: item.Id,
|
// startItemId: item.Id,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) === -1) {
|
if (
|
||||||
|
result.data.Items?.map((i) => i.Id).indexOf(
|
||||||
|
currentEpisodeId,
|
||||||
|
) === -1
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Episode having id ${currentEpisodeId} not found, index return -1`,
|
`Episode having id ${currentEpisodeId} not found, index return -1`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
index = result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ?? 0;
|
index =
|
||||||
|
result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ??
|
||||||
|
0;
|
||||||
if (currentAudioTrack === "auto") {
|
if (currentAudioTrack === "auto") {
|
||||||
const defaultAudioStreamIndex =
|
const defaultAudioStreamIndex =
|
||||||
result.data.Items?.[index].MediaSources?.[0]
|
result.data.Items?.[index].MediaSources?.[0]
|
||||||
@@ -275,11 +281,6 @@ const PlayButton = ({
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Playlist:
|
case BaseItemKind.Playlist:
|
||||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
|
||||||
userId: userId,
|
|
||||||
playlistId: playlistItemId,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case BaseItemKind.MusicAlbum:
|
case BaseItemKind.MusicAlbum:
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
parentId: item.Id,
|
parentId: item.Id,
|
||||||
@@ -351,7 +352,6 @@ const PlayButton = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Photo:
|
case BaseItemKind.Photo:
|
||||||
@@ -451,10 +451,7 @@ const PlayButton = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trackIndex) {
|
if (audio) {
|
||||||
// Playlist Playback
|
|
||||||
enqueueSnackbar("Playlist playback is WIP", { variant: "info" });
|
|
||||||
} else if (audio) {
|
|
||||||
// Album/Individual audio track playback
|
// Album/Individual audio track playback
|
||||||
const playbackUrl = generateAudioStreamUrl(
|
const playbackUrl = generateAudioStreamUrl(
|
||||||
result?.item?.Items?.[0].Id,
|
result?.item?.Items?.[0].Id,
|
||||||
|
|||||||
@@ -715,7 +715,7 @@ export const routeTree = rootRoute
|
|||||||
"parent": "/_api"
|
"parent": "/_api"
|
||||||
},
|
},
|
||||||
"/_api/playlist/$id": {
|
"/_api/playlist/$id": {
|
||||||
"filePath": "_api/playlist/$id.jsx",
|
"filePath": "_api/playlist/$id.tsx",
|
||||||
"parent": "/_api"
|
"parent": "/_api"
|
||||||
},
|
},
|
||||||
"/_api/series/$id": {
|
"/_api/series/$id": {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ import { useApiInContext } from "@/utils/store/api";
|
|||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
|
||||||
type SortByObject = { title: string; value: ItemSortBy };
|
type SortByObject = { title: string; value: string };
|
||||||
type ViewObject = { title: string; value: BaseItemKind | "Artist" };
|
type ViewObject = { title: string; value: BaseItemKind | "Artist" };
|
||||||
// type allowedFilters = ["movies", "tvshows", "music", "books"];
|
// type allowedFilters = ["movies", "tvshows", "music", "books"];
|
||||||
|
|
||||||
@@ -215,6 +215,9 @@ function Library() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
case CollectionType.Playlists:
|
||||||
|
result = [{ title: "Playlist", value: BaseItemKind.Playlist }];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
result = [];
|
result = [];
|
||||||
}
|
}
|
||||||
@@ -243,7 +246,7 @@ function Library() {
|
|||||||
Dvd: undefined,
|
Dvd: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [sortBy, setSortBy] = useState<ItemSortBy>("Name");
|
const [sortBy, setSortBy] = useState<string>("Name");
|
||||||
const [sortAscending, setSortAscending] = useState(
|
const [sortAscending, setSortAscending] = useState(
|
||||||
() =>
|
() =>
|
||||||
JSON.parse(
|
JSON.parse(
|
||||||
@@ -344,6 +347,47 @@ function Library() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
case BaseItemKind.Playlist:
|
||||||
|
result = [
|
||||||
|
{
|
||||||
|
title: "Name",
|
||||||
|
value: ItemSortBy.SortName,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Community Rating",
|
||||||
|
value: ItemSortBy.CommunityRating,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Critics Rating",
|
||||||
|
value: ItemSortBy.CriticRating,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Date Added",
|
||||||
|
value: ItemSortBy.DateCreated,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Date Played",
|
||||||
|
value: ItemSortBy.DatePlayed,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Folder",
|
||||||
|
value: `${ItemSortBy.IsFolder},${ItemSortBy.SortName}`,
|
||||||
|
},
|
||||||
|
{ title: "Parenal Rating", value: ItemSortBy.OfficialRating },
|
||||||
|
{
|
||||||
|
title: "Play Count",
|
||||||
|
value: ItemSortBy.PlayCount,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Release Date",
|
||||||
|
value: `${ItemSortBy.ProductionYear},${ItemSortBy.PremiereDate},${ItemSortBy.SortName}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Random",
|
||||||
|
value: ItemSortBy.Random,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
result = [];
|
result = [];
|
||||||
break;
|
break;
|
||||||
@@ -587,7 +631,7 @@ function Library() {
|
|||||||
sortOrder: [
|
sortOrder: [
|
||||||
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||||
],
|
],
|
||||||
sortBy: [sortBy],
|
sortBy: sortBy.split(",") as ItemSortBy[],
|
||||||
filters: filtersArray,
|
filters: filtersArray,
|
||||||
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
||||||
hasTrailer: filters.hasTrailer ? true : undefined,
|
hasTrailer: filters.hasTrailer ? true : undefined,
|
||||||
@@ -623,7 +667,7 @@ function Library() {
|
|||||||
sortOrder: [
|
sortOrder: [
|
||||||
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||||
],
|
],
|
||||||
sortBy: [sortBy],
|
sortBy: sortBy.split(",") as ItemSortBy[],
|
||||||
filters: filtersArray,
|
filters: filtersArray,
|
||||||
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
||||||
hasTrailer: filters.hasTrailer ? true : undefined,
|
hasTrailer: filters.hasTrailer ? true : undefined,
|
||||||
@@ -844,7 +888,7 @@ function Library() {
|
|||||||
gap={1.2}
|
gap={1.2}
|
||||||
className="library-items-options"
|
className="library-items-options"
|
||||||
>
|
>
|
||||||
{!disableSort && (
|
{!disableSort && sortBy && (
|
||||||
<div className="flex flex-row flex-center">
|
<div className="flex flex-row flex-center">
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -874,7 +918,7 @@ function Library() {
|
|||||||
value={sortBy ?? "Name"}
|
value={sortBy ?? "Name"}
|
||||||
size="small"
|
size="small"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setSortBy(e.target.value as ItemSortBy);
|
setSortBy(e.target.value);
|
||||||
console.info(e);
|
console.info(e);
|
||||||
sessionStorage.setItem(
|
sessionStorage.setItem(
|
||||||
`library-${currentLib.data?.Id}-config_sort`,
|
`library-${currentLib.data?.Id}-config_sort`,
|
||||||
@@ -886,7 +930,7 @@ function Library() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{sortByOptions.map((item) => (
|
{sortByOptions.map((item) => (
|
||||||
<MenuItem key={item.value} value={item.value}>
|
<MenuItem key={item.title} value={item.value}>
|
||||||
{item.title}
|
{item.title}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,223 +0,0 @@
|
|||||||
import PropTypes from "prop-types";
|
|
||||||
import React, { useEffect } from "react";
|
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
|
||||||
|
|
||||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
|
||||||
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
|
||||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
|
||||||
|
|
||||||
import MusicTrack from "@/components/musicTrack";
|
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
|
||||||
import "./playlist.scss";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
|
||||||
function TabPanel(props) {
|
|
||||||
const { children, value, index, ...other } = props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
role="tabpanel"
|
|
||||||
hidden={value !== index}
|
|
||||||
id={`full-width-tabpanel-${index}`}
|
|
||||||
aria-labelledby={`full-width-tab-${index}`}
|
|
||||||
{...other}
|
|
||||||
style={{ marginTop: "1em" }}
|
|
||||||
>
|
|
||||||
{value === index && <Box>{children}</Box>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TabPanel.propTypes = {
|
|
||||||
children: PropTypes.node,
|
|
||||||
index: PropTypes.number.isRequired,
|
|
||||||
value: PropTypes.number.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
function a11yProps(index) {
|
|
||||||
return {
|
|
||||||
id: `full-width-tab-${index}`,
|
|
||||||
"aria-controls": `full-width-tabpanel-${index}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/playlist/$id")({
|
|
||||||
component: PlaylistTitlePage,
|
|
||||||
});
|
|
||||||
|
|
||||||
function PlaylistTitlePage() {
|
|
||||||
const { id } = Route.useParams();
|
|
||||||
const api = Route.useRouteContext().api;
|
|
||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
|
||||||
|
|
||||||
const item = useQuery({
|
|
||||||
queryKey: ["item", id],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
|
||||||
userId: user?.Id,
|
|
||||||
itemId: id,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: !!user?.Id,
|
|
||||||
networkMode: "always",
|
|
||||||
refetchOnWindowFocus: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const similarItems = useQuery({
|
|
||||||
queryKey: ["item", id, "similarItem"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getLibraryApi(api).getSimilarAlbums({
|
|
||||||
userId: user?.Id,
|
|
||||||
itemId: item.data.Id,
|
|
||||||
limit: 16,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: item.isSuccess,
|
|
||||||
networkMode: "always",
|
|
||||||
refetchOnWindowFocus: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const musicTracks = useQuery({
|
|
||||||
queryKey: ["item", id, "musicTracks"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getPlaylistsApi(api).getPlaylistItems({
|
|
||||||
userId: user?.Id,
|
|
||||||
playlistId: item.data.Id,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: item.isSuccess,
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (item.isSuccess) {
|
|
||||||
setAppBackdrop(
|
|
||||||
item.data.Type === BaseItemKind.MusicAlbum ||
|
|
||||||
item.data.Type === BaseItemKind.Episode
|
|
||||||
? `${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`
|
|
||||||
: `${api.basePath}/Items/${item.data.Id}/Images/Backdrop`,
|
|
||||||
item.data.Id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (item.isPending || similarItems.isPending) {
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
width: "100%",
|
|
||||||
height: "100vh",
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CircularProgress />
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (item.isSuccess && similarItems.isSuccess) {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="scrollY padded-top item"
|
|
||||||
style={{
|
|
||||||
padding: "5em 2em 2em 1em",
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
gap: "0.5em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{musicTracks.isPending ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
musicTracks.data.TotalRecordCount > 0 &&
|
|
||||||
musicTracks.data.Items.map((track, index) => {
|
|
||||||
return (
|
|
||||||
<MusicTrack
|
|
||||||
item={track}
|
|
||||||
key={track.Id}
|
|
||||||
queryKey={["item", id, "musicTracks"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
playlistItem
|
|
||||||
playlistItemId={item.data.Id}
|
|
||||||
trackIndex={index}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
|
|
||||||
{similarItems.data.TotalRecordCount > 0 && (
|
|
||||||
<CardScroller
|
|
||||||
title="You might also like"
|
|
||||||
displayCards={8}
|
|
||||||
disableDecoration
|
|
||||||
>
|
|
||||||
{similarItems.data.Items.map((similar, index) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={similar.Id}
|
|
||||||
item={similar}
|
|
||||||
seriesId={similar.SeriesId}
|
|
||||||
cardTitle={
|
|
||||||
similar.Type === BaseItemKind.Episode
|
|
||||||
? similar.SeriesName
|
|
||||||
: similar.Name
|
|
||||||
}
|
|
||||||
imageType={"Primary"}
|
|
||||||
cardCaption={
|
|
||||||
similar.Type === BaseItemKind.Episode
|
|
||||||
? `S${similar.ParentIndexNumber}:E${similar.IndexNumber} - ${similar.Name}`
|
|
||||||
: similar.Type === BaseItemKind.Series
|
|
||||||
? `${similar.ProductionYear} - ${
|
|
||||||
similar.EndDate
|
|
||||||
? new Date(similar.EndDate).toLocaleString([], {
|
|
||||||
year: "numeric",
|
|
||||||
})
|
|
||||||
: "Present"
|
|
||||||
}`
|
|
||||||
: similar.ProductionYear
|
|
||||||
}
|
|
||||||
cardType={
|
|
||||||
similar.Type === BaseItemKind.MusicAlbum ||
|
|
||||||
similar.Type === BaseItemKind.Audio
|
|
||||||
? "square"
|
|
||||||
: "portrait"
|
|
||||||
}
|
|
||||||
queryKey={["item", id, "similarItem"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
imageBlurhash={
|
|
||||||
!!similar.ImageBlurHashes?.Primary &&
|
|
||||||
similar.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(similar.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (item.isError || similarItems.isError) {
|
|
||||||
return <ErrorNotice />;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default PlaylistTitlePage;
|
|
||||||
@@ -0,0 +1,250 @@
|
|||||||
|
import React, { useEffect } from "react";
|
||||||
|
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
|
|
||||||
|
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
|
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
||||||
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import { Card } from "@/components/card/card";
|
||||||
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
import "./playlist.scss";
|
||||||
|
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||||
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
|
import PlayButton from "@/components/buttons/playButton";
|
||||||
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
|
import TagChip from "@/components/tagChip";
|
||||||
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
|
import { getRuntimeCompact } from "@/utils/date/time";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { Typography } from "@mui/material";
|
||||||
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/_api/playlist/$id")({
|
||||||
|
component: PlaylistTitlePage,
|
||||||
|
});
|
||||||
|
|
||||||
|
function PlaylistTitlePage() {
|
||||||
|
const { id } = Route.useParams();
|
||||||
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
|
const item = useQuery({
|
||||||
|
queryKey: ["item", id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
|
userId: user?.Id,
|
||||||
|
itemId: id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
enabled: !!user?.Id,
|
||||||
|
networkMode: "always",
|
||||||
|
refetchOnWindowFocus: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const similarItems = useQuery({
|
||||||
|
queryKey: ["item", id, "similarItem"],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
if (!item.data?.Id) return null;
|
||||||
|
const result = await getLibraryApi(api).getSimilarAlbums({
|
||||||
|
userId: user?.Id,
|
||||||
|
itemId: item.data.Id,
|
||||||
|
limit: 16,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
enabled: item.isSuccess,
|
||||||
|
networkMode: "always",
|
||||||
|
refetchOnWindowFocus: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const musicTracks = useQuery({
|
||||||
|
queryKey: ["item", "musicTracks"],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
if (!item.data?.Id) return null;
|
||||||
|
const result = await getPlaylistsApi(api).getPlaylistItems({
|
||||||
|
userId: user?.Id,
|
||||||
|
playlistId: item.data.Id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
enabled: item.isSuccess,
|
||||||
|
networkMode: "always",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (item.isSuccess) {
|
||||||
|
setAppBackdrop("", "");
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (item.isPending || similarItems.isPending) {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: "100%",
|
||||||
|
height: "100vh",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CircularProgress />
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (item.isSuccess && item.data && similarItems.isSuccess) {
|
||||||
|
return (
|
||||||
|
<div key={id} className="scrollY padded-top item item-playlist">
|
||||||
|
<div className="item-info">
|
||||||
|
<Typography className="item-info-name" variant="h3">
|
||||||
|
{item.data?.Name}
|
||||||
|
</Typography>
|
||||||
|
<div className="flex flex-align-center item-info-playlist-info">
|
||||||
|
<Typography className="opacity-07">
|
||||||
|
{(musicTracks.data?.TotalRecordCount ?? 0) > 1
|
||||||
|
? `${musicTracks.data?.TotalRecordCount} songs`
|
||||||
|
: "Single"}
|
||||||
|
</Typography>
|
||||||
|
<Typography className="opacity-07">
|
||||||
|
{getRuntimeCompact(item.data.CumulativeRunTimeTicks ?? 0)}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<div className="item-info-buttons">
|
||||||
|
<PlayButton
|
||||||
|
item={item.data}
|
||||||
|
audio
|
||||||
|
itemType={item.data.Type ?? "Playlist"}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
<LikeButton
|
||||||
|
itemId={item.data.Id}
|
||||||
|
isFavorite={item.data.UserData?.IsFavorite}
|
||||||
|
queryKey={["item"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={item.data.Name}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="item-info-track-container ">
|
||||||
|
<div>
|
||||||
|
<div className="item-info-track header">
|
||||||
|
<span className="material-symbols-rounded index">tag</span>
|
||||||
|
<Typography variant="subtitle1">Title</Typography>
|
||||||
|
<Typography variant="subtitle1">Duration</Typography>
|
||||||
|
</div>
|
||||||
|
{musicTracks.data?.Items?.map((track, index) => (
|
||||||
|
<AlbumMusicTrack
|
||||||
|
key={track.Id}
|
||||||
|
track={track}
|
||||||
|
trackIndex={index}
|
||||||
|
musicTracks={musicTracks.data}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{createPortal(
|
||||||
|
<div className="item-info-sidebar">
|
||||||
|
<div className="item-info-sidebar-image-container">
|
||||||
|
{item.data.ImageTags?.Primary ? (
|
||||||
|
<img
|
||||||
|
className="item-info-sidebar-image"
|
||||||
|
alt={item.data.Name ?? "Playlist"}
|
||||||
|
src={
|
||||||
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
item.data.Id ?? "",
|
||||||
|
"Primary",
|
||||||
|
{
|
||||||
|
tag: item.data.ImageTags.Primary,
|
||||||
|
quality: 90,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="item-info-sidebar-icon">
|
||||||
|
{getTypeIcon("Playlist")}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="flex flex-align-center"
|
||||||
|
style={{ gap: "1em", flexWrap: "wrap" }}
|
||||||
|
>
|
||||||
|
{item.data.GenreItems?.map((genre) => (
|
||||||
|
<TagChip label={genre.Name ?? "genre"} key={genre.Id} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="item-info-sidebar-overview">
|
||||||
|
<ShowMoreText
|
||||||
|
content={item.data.Overview ?? ""}
|
||||||
|
collapsedLines={4}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>,
|
||||||
|
document.body,
|
||||||
|
)}
|
||||||
|
{(similarItems.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="You might also like"
|
||||||
|
displayCards={5}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{similarItems.data?.Items?.map((similar) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={similar.Id}
|
||||||
|
item={similar}
|
||||||
|
seriesId={similar.SeriesId}
|
||||||
|
cardTitle={
|
||||||
|
similar.Type === BaseItemKind.Episode
|
||||||
|
? similar.SeriesName
|
||||||
|
: similar.Name
|
||||||
|
}
|
||||||
|
imageType={"Primary"}
|
||||||
|
cardCaption={
|
||||||
|
similar.Type === BaseItemKind.Episode
|
||||||
|
? `S${similar.ParentIndexNumber}:E${similar.IndexNumber} - ${similar.Name}`
|
||||||
|
: similar.Type === BaseItemKind.Series
|
||||||
|
? `${similar.ProductionYear} - ${
|
||||||
|
similar.EndDate
|
||||||
|
? new Date(similar.EndDate).toLocaleString([], {
|
||||||
|
year: "numeric",
|
||||||
|
})
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: similar.ProductionYear
|
||||||
|
}
|
||||||
|
cardType={"square"}
|
||||||
|
queryKey={["item", id, "similarItem"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (item.isError || similarItems.isError) {
|
||||||
|
return <ErrorNotice />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PlaylistTitlePage;
|
||||||
@@ -1,5 +1,99 @@
|
|||||||
|
$border-radius: 20px;
|
||||||
.item-detail-playlist {
|
.item-playlist {
|
||||||
|
width: 70vw;
|
||||||
|
padding-right: 2.2em;
|
||||||
|
.item-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.2em;
|
||||||
|
&-container {
|
||||||
|
grid-template-columns: 1fr 25%;
|
||||||
|
display: grid;
|
||||||
|
gap: 3em;
|
||||||
|
}
|
||||||
|
&-playlist-info {
|
||||||
|
gap: 1.2em;
|
||||||
|
}
|
||||||
|
&-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 1em;
|
||||||
|
}
|
||||||
|
&-disc-header {
|
||||||
|
padding: 1em 2em;
|
||||||
|
background: hsla(0, 0, 100%, 10%);
|
||||||
|
border-radius: 100px;
|
||||||
|
gap: 1em;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.item-info-sidebar {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1em;
|
||||||
|
position: fixed;
|
||||||
|
// max-height: 100vh;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 30vw;
|
||||||
|
padding: 4.4em;
|
||||||
|
padding-left: 2.2em;
|
||||||
|
&-image {
|
||||||
|
width: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: $border-radius-default;
|
||||||
|
}
|
||||||
|
&-artist {
|
||||||
|
display: flex;
|
||||||
|
gap: 1em;
|
||||||
|
align-items: center;
|
||||||
|
padding: 1em 0;
|
||||||
|
color: rgb(255 255 255 / 0.7);
|
||||||
|
transition: $transition-time-default;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
|
&:hover {
|
||||||
|
color: rgb(255 255 255)
|
||||||
|
}
|
||||||
|
&-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
z-index: 1;
|
||||||
|
position: relative;
|
||||||
|
&-container {
|
||||||
|
width: 3em;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
border-radius: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
.material-symbols-rounded {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-container {
|
||||||
|
// max-height: 20em;/
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-overview {
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: 28vh;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.item-detail- {
|
||||||
&-track {
|
&-track {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 4% 1fr 80% 1fr;
|
grid-template-columns: 4% 1fr 80% 1fr;
|
||||||
@@ -8,26 +102,286 @@
|
|||||||
gap: 0.5em;
|
gap: 0.5em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.25em 0;
|
padding: 0.25em 0;
|
||||||
background: rgb(255 255 255 / 0);
|
background: rgb(0 0 0 / 0.4);
|
||||||
transition: background $transition-time-default;
|
transition: background $transition-time-default;
|
||||||
|
backdrop-filter: blur(5px);
|
||||||
&:first-child,
|
&:first-child {
|
||||||
|
border-radius: $border-radius $border-radius 8px 8px;
|
||||||
|
cursor: default !important;
|
||||||
|
}
|
||||||
&:last-child {
|
&:last-child {
|
||||||
border-bottom: none;
|
border-radius: 8px 8px $border-radius $border-radius;
|
||||||
}
|
}
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.05);
|
border-radius: 8px;
|
||||||
&s {
|
&s {
|
||||||
border-radius: 10px !important;
|
background: transparent !important;
|
||||||
overflow: hidden !important;
|
box-shadow: none !important;
|
||||||
background: $clr-background-dark-opacity-0_8 !important;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: rgb(255 255 255 / 0.05);
|
background: rgb(0 0 0 / 0.5);
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.playing {
|
&.playing {
|
||||||
color: $clr-accent-default;
|
color: $clr-accent-default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$cardWidth: 22%;
|
||||||
|
.item-playlist.item {
|
||||||
|
.item-hero {
|
||||||
|
height: 50vh;
|
||||||
|
gap: 2em;
|
||||||
|
position: relative;
|
||||||
|
align-items: center;
|
||||||
|
&-image {
|
||||||
|
opacity: 0;
|
||||||
|
width: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
|
&-container {
|
||||||
|
height: fit-content;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: $border-radius-default;
|
||||||
|
box-shadow: $shadow-card;
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-shrink: 0;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
&-blurhash {
|
||||||
|
position: absolute !important;
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-logo {
|
||||||
|
max-width: 42rem;
|
||||||
|
max-height: 10rem;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
|
object-position: bottom;
|
||||||
|
}
|
||||||
|
&-detail {
|
||||||
|
width: 100%;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1em;
|
||||||
|
justify-content: end;
|
||||||
|
}
|
||||||
|
&-buttons {
|
||||||
|
&-container {
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-backdrop {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
object-fit: cover;
|
||||||
|
object-position: top;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
|
&-container {
|
||||||
|
filter: brightness(0.8);
|
||||||
|
position: absolute;
|
||||||
|
top: -4.4em;
|
||||||
|
left: -$page-margin;
|
||||||
|
width: 100vw;
|
||||||
|
height: calc(50vh + 4.4em);
|
||||||
|
z-index: -1;
|
||||||
|
mask-image: linear-gradient(to top, transparent, black);
|
||||||
|
-webkit-mask-image: linear-gradient(to top,
|
||||||
|
transparent,
|
||||||
|
black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.item-hero {
|
||||||
|
height: 60vh;
|
||||||
|
gap: 2em;
|
||||||
|
row-gap: 1.2em;
|
||||||
|
position: relative;
|
||||||
|
align-items: flex-end;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: $cardWidth 1fr;
|
||||||
|
grid-template-rows: 1fr auto;
|
||||||
|
&-image {
|
||||||
|
opacity: 0;
|
||||||
|
width: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
|
&-container {
|
||||||
|
height: fit-content;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: $border-radius-default;
|
||||||
|
box-shadow: $shadow-card;
|
||||||
|
flex-grow: 1;
|
||||||
|
flex-shrink: 0;
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
&-blurhash {
|
||||||
|
position: absolute !important;
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
&-icon {
|
||||||
|
background: linear-gradient(45deg, rgb(255 255 255 / 0.05), rgb(255 255 255 / 0.15));
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 4em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-logo {
|
||||||
|
max-width: 34rem;
|
||||||
|
max-height: 10rem;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
|
object-position: bottom;
|
||||||
|
margin-bottom: 2em;
|
||||||
|
}
|
||||||
|
&-detail {
|
||||||
|
width: 100%;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.2em;
|
||||||
|
justify-content: end;
|
||||||
|
}
|
||||||
|
&-buttons {
|
||||||
|
&-container {
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
grid-column: 1/3;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: inherit;
|
||||||
|
gap: 2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-backdrop {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
object-fit: cover;
|
||||||
|
object-position: top;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
|
&-container {
|
||||||
|
filter: brightness(0.8);
|
||||||
|
position: absolute;
|
||||||
|
top: -4.4em;
|
||||||
|
left: -$page-margin;
|
||||||
|
width: 100vw;
|
||||||
|
height: calc(54vh + 4.4em);
|
||||||
|
z-index: -1;
|
||||||
|
mask-image: linear-gradient(to top, transparent, black);
|
||||||
|
-webkit-mask-image: linear-gradient(to top,
|
||||||
|
transparent,
|
||||||
|
black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
& .play-button {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.item-detail {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 35%;
|
||||||
|
justify-items: center;
|
||||||
|
align-items: start;
|
||||||
|
gap: 3em;
|
||||||
|
&-cast {
|
||||||
|
max-height: 50vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
mask-image: linear-gradient(to top, transparent, black 1.2em);
|
||||||
|
-webkit-mask-image: linear-gradient(to top, transparent, black 1.2em);
|
||||||
|
&-title {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
background: black;
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.2);
|
||||||
|
padding: 0.35em;
|
||||||
|
border-radius: 10px;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
&-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1em;
|
||||||
|
}
|
||||||
|
&-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 1em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
&-card {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 6em 1fr;
|
||||||
|
gap: 0.5em;
|
||||||
|
align-items: center;
|
||||||
|
color: white !important;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 0.5em;
|
||||||
|
background: rgb(255 255 255 / 0);
|
||||||
|
transition: background $transition-time-default;
|
||||||
|
border-radius: $border-radius-default;
|
||||||
|
&:hover {
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
}
|
||||||
|
&-image,
|
||||||
|
&-icon {
|
||||||
|
width: 6em;
|
||||||
|
height: 6em;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 100%;
|
||||||
|
box-shadow: $shadow-card-image;
|
||||||
|
}
|
||||||
|
&-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 1em;
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 3em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-link {
|
||||||
|
color: white;
|
||||||
|
text-decoration-color: rgb(255 255 255 / 0.5);
|
||||||
|
&:hover {
|
||||||
|
text-decoration-color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-episodes-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
gap: 0.25em;
|
||||||
|
margin-top: 0.5em;
|
||||||
|
align-items: start;
|
||||||
|
justify-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (max-width: 1320px) {
|
||||||
|
.item-playlist .item-detail {
|
||||||
|
&-cast {
|
||||||
|
&-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user