34 files changed
+2910
-300
No files matched your search
@@ -76,7 +76,7 @@ const Slider = ({
|
||||
},
|
||||
}));
|
||||
|
||||
const slide = (direction: Direction) => {
|
||||
const slideLeft = useCallback(() => {
|
||||
const clientWidth =
|
||||
containerRef.current?.getBoundingClientRect().width ?? 0;
|
||||
const cardWidth =
|
||||
@@ -86,58 +86,67 @@ const Slider = ({
|
||||
const visibleItems = Math.floor(clientWidth / cardWidth);
|
||||
const scrollOffset = scrollPosition % cardWidth;
|
||||
|
||||
if (direction === Direction.LEFT) {
|
||||
const newX = Math.max(
|
||||
scrollPosition - scrollOffset - visibleItems * cardWidth,
|
||||
0,
|
||||
);
|
||||
setX.start({
|
||||
from: { x: scrollPosition },
|
||||
to: { x: newX },
|
||||
onChange: (results) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current.scrollLeft = results.value.x;
|
||||
}
|
||||
},
|
||||
reset: true,
|
||||
config: { friction: 60, tension: 1000, velocity: 2 },
|
||||
});
|
||||
const newX = Math.max(
|
||||
scrollPosition - scrollOffset - visibleItems * cardWidth,
|
||||
0,
|
||||
);
|
||||
setX.start({
|
||||
from: { x: scrollPosition },
|
||||
to: { x: newX },
|
||||
onChange: (results) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current.scrollLeft = results.value.x;
|
||||
}
|
||||
},
|
||||
reset: true,
|
||||
config: { friction: 60, tension: 1000, velocity: 2 },
|
||||
});
|
||||
|
||||
if (newX === 0) {
|
||||
setScrollPos({ isStart: true, isEnd: false });
|
||||
} else {
|
||||
setScrollPos({ isStart: false, isEnd: false });
|
||||
}
|
||||
} else if (direction === Direction.RIGHT) {
|
||||
const newX = Math.min(
|
||||
scrollPosition - scrollOffset + visibleItems * cardWidth,
|
||||
containerRef.current?.scrollWidth ?? 0 - clientWidth,
|
||||
);
|
||||
setX.start({
|
||||
from: { x: scrollPosition },
|
||||
to: { x: newX },
|
||||
onChange: (results) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current.scrollLeft = results.value.x;
|
||||
}
|
||||
},
|
||||
reset: true,
|
||||
config: { friction: 60, tension: 500, velocity: 2 },
|
||||
});
|
||||
|
||||
if (newX >= (containerRef.current?.scrollWidth ?? 0) - clientWidth) {
|
||||
setScrollPos({ isStart: false, isEnd: true });
|
||||
} else {
|
||||
setScrollPos({ isStart: false, isEnd: false });
|
||||
}
|
||||
if (newX === 0) {
|
||||
setScrollPos({ isStart: true, isEnd: false });
|
||||
} else {
|
||||
setScrollPos({ isStart: false, isEnd: false });
|
||||
}
|
||||
};
|
||||
}, [setX]);
|
||||
|
||||
const slideRight = useCallback(() => {
|
||||
const clientWidth =
|
||||
containerRef.current?.getBoundingClientRect().width ?? 0;
|
||||
const cardWidth =
|
||||
containerRef.current?.firstElementChild?.getBoundingClientRect().width ??
|
||||
0;
|
||||
const scrollPosition = containerRef.current?.scrollLeft ?? 0;
|
||||
const visibleItems = Math.floor(clientWidth / cardWidth);
|
||||
const scrollOffset = scrollPosition % cardWidth;
|
||||
|
||||
const newX = Math.min(
|
||||
scrollPosition - scrollOffset + visibleItems * cardWidth,
|
||||
containerRef.current?.scrollWidth ?? 0 - clientWidth,
|
||||
);
|
||||
setX.start({
|
||||
from: { x: scrollPosition },
|
||||
to: { x: newX },
|
||||
onChange: (results) => {
|
||||
if (containerRef.current) {
|
||||
containerRef.current.scrollLeft = results.value.x;
|
||||
}
|
||||
},
|
||||
reset: true,
|
||||
config: { friction: 60, tension: 500, velocity: 2 },
|
||||
});
|
||||
|
||||
if (newX >= (containerRef.current?.scrollWidth ?? 0) - clientWidth) {
|
||||
setScrollPos({ isStart: false, isEnd: true });
|
||||
} else {
|
||||
setScrollPos({ isStart: false, isEnd: false });
|
||||
}
|
||||
}, [setX]);
|
||||
|
||||
return (
|
||||
<div className="slider">
|
||||
<IconButton
|
||||
className="slider-button left"
|
||||
onClick={() => slide(Direction.LEFT)}
|
||||
onClick={slideLeft}
|
||||
disabled={scrollPos.isStart}
|
||||
variant="contained"
|
||||
>
|
||||
@@ -159,7 +168,7 @@ const Slider = ({
|
||||
</div>
|
||||
<IconButton
|
||||
className="slider-button right"
|
||||
onClick={() => slide(Direction.RIGHT)}
|
||||
onClick={slideRight}
|
||||
disabled={scrollPos.isEnd}
|
||||
variant="contained"
|
||||
>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { type ReactNode } from "react";
|
||||
import React, { useCallback, useMemo, type ReactNode } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import MuiAppBar from "@mui/material/AppBar";
|
||||
@@ -21,6 +21,7 @@ import "./appBar.scss";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
@@ -34,7 +35,6 @@ import {
|
||||
ListItemText,
|
||||
} from "@mui/material";
|
||||
import BackButton from "../buttons/backButton";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
interface ListItemLinkProps {
|
||||
icon?: ReactNode;
|
||||
@@ -70,6 +70,8 @@ function ListItemLink(props: ListItemLinkProps) {
|
||||
);
|
||||
}
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
|
||||
export const AppBar = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const navigate = useNavigate();
|
||||
@@ -98,13 +100,12 @@ export const AppBar = () => {
|
||||
|
||||
const [anchorEl, setAnchorEl] = useState(null);
|
||||
const openMenu = Boolean(anchorEl);
|
||||
const handleMenuOpen = (event) => {
|
||||
const handleMenuOpen = useCallback((event) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
};
|
||||
const handleMenuClose = () => {
|
||||
}, []);
|
||||
const handleMenuClose = useCallback(() => {
|
||||
setAnchorEl(null);
|
||||
};
|
||||
|
||||
}, []);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const handleLogout = async () => {
|
||||
@@ -134,6 +135,43 @@ export const AppBar = () => {
|
||||
|
||||
const [showDrawer, setShowDrawer] = useState(false);
|
||||
|
||||
const appBarStyling = useMemo(() => {
|
||||
return {
|
||||
backgroundColor: "transparent",
|
||||
paddingRight: "0 !important",
|
||||
};
|
||||
}, []);
|
||||
const menuStyle = useMemo(() => {
|
||||
return { mt: 2 };
|
||||
}, []);
|
||||
|
||||
const drawerPaperProps = useMemo(() => {
|
||||
return {
|
||||
className: "glass library-drawer",
|
||||
elevation: 6,
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleNavigateToSearch = useCallback(
|
||||
() => navigate({ to: "/search", search: { query: "" } }),
|
||||
[navigate],
|
||||
);
|
||||
|
||||
const handleDrawerClose = useCallback(() => {
|
||||
setShowDrawer(false);
|
||||
}, []);
|
||||
|
||||
const handleDrawerOpen = useCallback(() => {
|
||||
setShowDrawer(true);
|
||||
}, []);
|
||||
|
||||
const handleNavigateToHome = useCallback(() => navigate({ to: "/home" }), []);
|
||||
const handleNavigateToFavorite = useCallback(() => {
|
||||
navigate({ to: "/favorite" });
|
||||
}, []);
|
||||
|
||||
const menuButtonSx = useMemo(() => ({ p: 0 }), []);
|
||||
|
||||
if (!display) {
|
||||
return <></>;
|
||||
}
|
||||
@@ -141,10 +179,7 @@ export const AppBar = () => {
|
||||
return (
|
||||
<>
|
||||
<MuiAppBar
|
||||
style={{
|
||||
backgroundColor: "transparent",
|
||||
paddingRight: "0 !important",
|
||||
}}
|
||||
style={appBarStyling}
|
||||
className={
|
||||
trigger
|
||||
? "appBar flex flex-row flex-justify-spaced-between elevated"
|
||||
@@ -154,11 +189,11 @@ export const AppBar = () => {
|
||||
color="transparent"
|
||||
>
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton onClick={() => setShowDrawer(true)}>
|
||||
<IconButton onClick={handleDrawerOpen}>
|
||||
<div className="material-symbols-rounded">menu</div>
|
||||
</IconButton>
|
||||
<BackButton />
|
||||
<IconButton onClick={() => navigate({ to: "/home" })}>
|
||||
<MemoizeBackButton />
|
||||
<IconButton onClick={handleNavigateToHome}>
|
||||
<div
|
||||
className={
|
||||
location.pathname === "/home"
|
||||
@@ -172,15 +207,13 @@ export const AppBar = () => {
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton
|
||||
onClick={() => navigate({ to: "/search", params: { query: "" } })}
|
||||
>
|
||||
<IconButton onClick={handleNavigateToSearch}>
|
||||
<div className="material-symbols-rounded">search</div>
|
||||
</IconButton>
|
||||
<IconButton onClick={() => navigate({ to: "/favorite" })}>
|
||||
<IconButton onClick={handleNavigateToFavorite}>
|
||||
<div className="material-symbols-rounded">favorite</div>
|
||||
</IconButton>
|
||||
<IconButton sx={{ p: 0 }} onClick={handleMenuOpen}>
|
||||
<IconButton sx={menuButtonSx} onClick={handleMenuOpen}>
|
||||
{!!user?.Id &&
|
||||
(user?.PrimaryImageTag === undefined ? (
|
||||
<Avatar className="appBar-avatar" alt={user?.Name ?? "image"}>
|
||||
@@ -204,7 +237,7 @@ export const AppBar = () => {
|
||||
anchorEl={anchorEl}
|
||||
open={openMenu}
|
||||
onClose={handleMenuClose}
|
||||
sx={{ mt: 2 }}
|
||||
sx={menuStyle}
|
||||
disableScrollLock
|
||||
>
|
||||
<MenuItem
|
||||
@@ -248,17 +281,14 @@ export const AppBar = () => {
|
||||
</MuiAppBar>
|
||||
<Drawer
|
||||
open={showDrawer}
|
||||
PaperProps={{
|
||||
className: "glass library-drawer",
|
||||
elevation: 6,
|
||||
}}
|
||||
PaperProps={drawerPaperProps}
|
||||
className="library-drawer"
|
||||
onClose={() => setShowDrawer(false)}
|
||||
onClose={handleDrawerClose}
|
||||
>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
onClick={() => setShowDrawer(false)}
|
||||
onClick={handleDrawerClose}
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import PropTypes from "prop-types";
|
||||
import React from "react";
|
||||
import React, { memo } from "react"; // Import memo
|
||||
|
||||
import Button, {
|
||||
type ButtonProps,
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
type BaseItemDtoQueryResult,
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
ItemFilter,
|
||||
LocationType,
|
||||
MediaProtocol,
|
||||
type PlaybackInfoResponse,
|
||||
SortOrder,
|
||||
@@ -37,8 +39,12 @@ import { getRuntimeCompact } from "@/utils/date/time";
|
||||
import getSubtitle from "@/utils/methods/getSubtitles";
|
||||
import playbackProfile from "@/utils/playback-profiles";
|
||||
import { axiosClient, useApiInContext } from "@/utils/store/api";
|
||||
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
||||
import type IntroMediaInfo from "@/utils/types/introMediaInfo";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
import type { SxProps } from "@mui/material";
|
||||
import type { AxiosResponse } from "axios";
|
||||
|
||||
@@ -62,6 +68,27 @@ type PlayButtonProps = {
|
||||
trackIndex: number;
|
||||
};
|
||||
|
||||
// Memoized LinearProgress component
|
||||
const MemoizedLinearProgress = memo(({ value }: { value: number }) => (
|
||||
<LinearProgress
|
||||
variant="determinate"
|
||||
value={value}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
height: "100%",
|
||||
background: "transparent",
|
||||
opacity: 0.2,
|
||||
zIndex: 0,
|
||||
mixBlendMode: "difference",
|
||||
}}
|
||||
color="white"
|
||||
/>
|
||||
));
|
||||
|
||||
const PlayButton = ({
|
||||
item,
|
||||
itemId,
|
||||
@@ -87,6 +114,7 @@ const PlayButton = ({
|
||||
const setPlaybackDataLoading = usePlaybackDataLoadStore(
|
||||
(state) => state.setisPending,
|
||||
);
|
||||
const playPhotos = usePhotosPlayback((s) => s.playPhotos);
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
@@ -96,7 +124,7 @@ const PlayButton = ({
|
||||
setPlaybackDataLoading(true);
|
||||
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
||||
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
||||
let introInfo: undefined | AxiosResponse<IntroMediaInfo, any>;
|
||||
let introInfo: undefined | IntroMediaInfo;
|
||||
const indexNumber = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
||||
if (playlistItem) {
|
||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
||||
@@ -106,48 +134,50 @@ const PlayButton = ({
|
||||
} else {
|
||||
switch (itemType) {
|
||||
case BaseItemKind.Episode:
|
||||
result = await getTvShowsApi(api).getEpisodes({
|
||||
seriesId: item.SeriesId,
|
||||
fields: [
|
||||
ItemFields.MediaSources,
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.Overview,
|
||||
ItemFields.Chapters,
|
||||
ItemFields.Trickplay,
|
||||
],
|
||||
enableUserData: true,
|
||||
userId: userId,
|
||||
seasonId: item.SeasonId,
|
||||
// startItemId: item.Id,
|
||||
});
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: currentAudioTrack,
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items?.[indexNumber].Id,
|
||||
startTimeTicks:
|
||||
result.data.Items?.[indexNumber].UserData
|
||||
?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[indexNumber].MediaSources?.[0].Id,
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
try {
|
||||
introInfo = (
|
||||
await axiosClient.get(
|
||||
`${api.basePath}/Episode/${result.data.Items?.[0]?.Id}/IntroSkipperSegments`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `MediaBrowser Token=${api.accessToken}`,
|
||||
if (item.SeriesId && item.SeasonId) {
|
||||
result = await getTvShowsApi(api).getEpisodes({
|
||||
seriesId: item.SeriesId,
|
||||
fields: [
|
||||
ItemFields.MediaSources,
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.Overview,
|
||||
ItemFields.Chapters,
|
||||
ItemFields.Trickplay,
|
||||
],
|
||||
enableUserData: true,
|
||||
userId: userId,
|
||||
seasonId: item.SeasonId,
|
||||
// startItemId: item.Id,
|
||||
});
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: currentAudioTrack,
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items?.[indexNumber].Id,
|
||||
startTimeTicks:
|
||||
result.data.Items?.[indexNumber].UserData
|
||||
?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[indexNumber].MediaSources?.[0].Id,
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
try {
|
||||
introInfo = (
|
||||
await axiosClient.get(
|
||||
`${api.basePath}/Episode/${result.data.Items?.[0]?.Id}/IntroSkipperSegments`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `MediaBrowser Token=${api.accessToken}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
)?.data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
)
|
||||
)?.data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BaseItemKind.Series:
|
||||
@@ -163,19 +193,23 @@ const PlayButton = ({
|
||||
enableUserData: true,
|
||||
userId: userId,
|
||||
});
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: currentAudioTrack,
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items?.[0].Id,
|
||||
startTimeTicks:
|
||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId: result.data.Items?.[0].MediaSources?.[0].Id,
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
if (
|
||||
result.data.Items?.[0].Id &&
|
||||
result.data.Items?.[0].MediaSources?.[0].Id
|
||||
)
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: currentAudioTrack,
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items?.[0].Id,
|
||||
startTimeTicks:
|
||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId: result.data.Items?.[0].MediaSources?.[0].Id,
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
try {
|
||||
introInfo = (
|
||||
await axiosClient.get(
|
||||
@@ -231,6 +265,24 @@ const PlayButton = ({
|
||||
sortBy: ["IndexNumber"],
|
||||
});
|
||||
break;
|
||||
case BaseItemKind.Photo:
|
||||
if (item.Id) {
|
||||
const photo = (
|
||||
await getUserLibraryApi(api).getItem({
|
||||
itemId: item.Id,
|
||||
})
|
||||
).data;
|
||||
result = await getItemsApi(api).getItems({
|
||||
parentId: photo.ParentId,
|
||||
filters: [ItemFilter.IsNotFolder],
|
||||
recursive: false,
|
||||
sortBy: ["SortName"],
|
||||
mediaTypes: ["Photo"],
|
||||
excludeLocationTypes: [LocationType.Virtual],
|
||||
collapseBoxSetItems: false,
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = await getItemsApi(api).getItems({
|
||||
ids: [itemId],
|
||||
@@ -268,16 +320,22 @@ const PlayButton = ({
|
||||
enqueueSnackbar("Playlist playback is WIP", { variant: "info" });
|
||||
} else if (audio) {
|
||||
// Album/Individual audio track playback
|
||||
const urlOptions = {
|
||||
const urlOptions: Record<string, string> = {
|
||||
deviceId: api?.deviceInfo.id,
|
||||
userId,
|
||||
//@ts-ignore
|
||||
userId: userId,
|
||||
api_key: api?.accessToken,
|
||||
};
|
||||
const urlParams = new URLSearchParams(urlOptions).toString();
|
||||
|
||||
const playbackUrl = `${api.basePath}/Audio/${result?.item.Items[0].Id}/universal?${urlParams}`;
|
||||
playAudio(playbackUrl, result?.item.Items[0], undefined);
|
||||
const playbackUrl = `${api.basePath}/Audio/${result?.item.Items?.[0].Id}/universal?${urlParams}`;
|
||||
playAudio(playbackUrl, result?.item.Items?.[0], undefined);
|
||||
setQueue(result?.item.Items ?? [], 0);
|
||||
} else if (item.Type === "Photo") {
|
||||
const index = result?.item?.Items?.map((i) => i.Id).indexOf(item.Id);
|
||||
if (result?.item?.Items && index) {
|
||||
playPhotos(result?.item?.Items, index);
|
||||
navigate({ to: "/player/photos" });
|
||||
}
|
||||
} else {
|
||||
const episodeIndex = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
||||
// Creates a queue containing all Episodes for a particular season(series) or collection of movies
|
||||
@@ -314,7 +372,7 @@ const PlayButton = ({
|
||||
let playItemValue = item;
|
||||
if (itemType === BaseItemKind.Movie) {
|
||||
playItemValue = result?.item.Items?.[0];
|
||||
}
|
||||
}
|
||||
|
||||
playItem(
|
||||
itemName,
|
||||
@@ -413,26 +471,13 @@ const PlayButton = ({
|
||||
audio
|
||||
? "Play Now"
|
||||
: "Watch Now"}
|
||||
<LinearProgress
|
||||
variant="determinate"
|
||||
<MemoizedLinearProgress
|
||||
value={
|
||||
100 > itemUserData?.PlayedPercentage > 0
|
||||
100 > itemUserData?.PlayedPercentage &&
|
||||
itemUserData?.PlayedPercentage > 0
|
||||
? itemUserData?.PlayedPercentage
|
||||
: 0
|
||||
}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
height: "100%",
|
||||
background: "transparent",
|
||||
opacity: 0.2,
|
||||
zIndex: 0,
|
||||
mixBlendMode: "difference",
|
||||
}}
|
||||
color="white"
|
||||
/>
|
||||
</Button>
|
||||
{itemUserData?.PlaybackPositionTicks > 0 && (
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/** @format */
|
||||
|
||||
import React, { memo } from "react";
|
||||
import { Component, useState } from "react";
|
||||
|
||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import {
|
||||
@@ -21,20 +19,6 @@ import { getTypeIcon } from "../utils/iconsCollection";
|
||||
import "./card.scss";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
|
||||
const cardImageAspectRatios = {
|
||||
thumb: 1.777,
|
||||
portrait: 0.666,
|
||||
square: 1,
|
||||
};
|
||||
|
||||
const availableSpecialRoutes = [
|
||||
BaseItemKind.Series,
|
||||
BaseItemKind.BoxSet,
|
||||
BaseItemKind.MusicAlbum,
|
||||
BaseItemKind.Episode,
|
||||
BaseItemKind.Playlist,
|
||||
];
|
||||
|
||||
const CardComponent = ({
|
||||
item,
|
||||
cardTitle,
|
||||
@@ -123,7 +107,9 @@ const CardComponent = ({
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
<div className="card-image-icon-container">
|
||||
{overrideIcon ? getTypeIcon(overrideIcon) : getTypeIcon(item.Type)}
|
||||
{overrideIcon
|
||||
? getTypeIcon(overrideIcon)
|
||||
: getTypeIcon(item.Type ?? "universal")}
|
||||
</div>
|
||||
<img
|
||||
alt={item.Name ?? "blink"}
|
||||
@@ -131,7 +117,7 @@ const CardComponent = ({
|
||||
overrideIcon === "User"
|
||||
? `${api.basePath}/Users/${item.Id}/Images/Primary`
|
||||
: api.getItemImageUrl(
|
||||
seriesId ? item.SeriesId : (item.AlbumId ?? item.Id),
|
||||
(seriesId ? item.SeriesId : (item.AlbumId ?? item.Id)) ?? "",
|
||||
imageType,
|
||||
{
|
||||
quality: 90,
|
||||
@@ -193,7 +179,7 @@ const CardComponent = ({
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{item.UserData?.PlaybackPositionTicks > 0 && (
|
||||
{(item.UserData?.PlaybackPositionTicks ?? -1) > 0 && (
|
||||
<div className="card-progress-container">
|
||||
<div
|
||||
className="card-progress"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
||||
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
|
||||
@@ -18,6 +18,12 @@ const swipePower = (offset, velocity) => {
|
||||
return Math.abs(offset) * velocity;
|
||||
};
|
||||
|
||||
// Memoize CarouselSlide to prevent unnecessary re-renders
|
||||
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
||||
|
||||
// Memoize Slider to prevent unnecessary re-renders
|
||||
const MemoizedSlider = React.memo(Slider);
|
||||
|
||||
const Carousel = ({
|
||||
content,
|
||||
onChange,
|
||||
@@ -31,6 +37,7 @@ const Carousel = ({
|
||||
state.setDirection,
|
||||
state.direction,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
onChange(currentSlide);
|
||||
}, [content[currentSlide]?.Id]);
|
||||
@@ -39,7 +46,6 @@ const Carousel = ({
|
||||
|
||||
const responsive = {
|
||||
superLargeDesktop: {
|
||||
// the naming can be any, depends on you.
|
||||
breakpoint: { max: 4000, min: 3000 },
|
||||
items: 6,
|
||||
},
|
||||
@@ -57,6 +63,70 @@ const Carousel = ({
|
||||
},
|
||||
};
|
||||
|
||||
// Memoize the content mapping
|
||||
const sliderContent = useMemo(() => {
|
||||
return content.map((item, index) => (
|
||||
<motion.div
|
||||
className={
|
||||
currentSlide === index
|
||||
? "carousel-indicator active"
|
||||
: "carousel-indicator"
|
||||
}
|
||||
layout
|
||||
initial={{
|
||||
height: "4.6em",
|
||||
}}
|
||||
whileHover={{
|
||||
height: "5.5em",
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.05,
|
||||
}}
|
||||
key={item.Id}
|
||||
onClick={() => {
|
||||
if (currentSlide > index) {
|
||||
setDirection("left");
|
||||
} else if (currentSlide <= index) {
|
||||
setDirection("right");
|
||||
}
|
||||
setCurrentSlide(index);
|
||||
}}
|
||||
>
|
||||
{item.ImageTags?.Thumb ? (
|
||||
<img
|
||||
src={api.getItemImageUrl(item.Id, "Thumb", {
|
||||
tag: item.ImageTags.Primary,
|
||||
fillWidth: 300,
|
||||
})}
|
||||
alt={item.Name ?? "item-image"}
|
||||
className="carousel-indicator-image"
|
||||
/>
|
||||
) : (
|
||||
<div className="carousel-indicator-icon">
|
||||
{getTypeIcon(item.Type)}
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
));
|
||||
}, [content, currentSlide, api, setDirection]);
|
||||
|
||||
const handleDragEnd = useCallback(
|
||||
(e, { offset, velocity }) => {
|
||||
const swipe = swipePower(offset.x, velocity.x);
|
||||
if (
|
||||
currentSlide !== content.length - 1 &&
|
||||
swipe < -swipeConfidenceThreshold
|
||||
) {
|
||||
setDirection("right");
|
||||
setCurrentSlide((init) => init + 1);
|
||||
} else if (currentSlide !== 0 && swipe > swipeConfidenceThreshold) {
|
||||
setDirection("left");
|
||||
setCurrentSlide((init) => init - 1);
|
||||
}
|
||||
},
|
||||
[currentSlide, content.length, setDirection],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="carousel">
|
||||
<AnimatePresence mode="sync">
|
||||
@@ -72,79 +142,22 @@ const Carousel = ({
|
||||
drag={"x"}
|
||||
dragConstraints={{ left: 0, right: 0 }}
|
||||
dragElastic={1}
|
||||
onDragEnd={(e, { offset, velocity }) => {
|
||||
const swipe = swipePower(offset.x, velocity.x);
|
||||
if (
|
||||
currentSlide !== content.length - 1 &&
|
||||
swipe < -swipeConfidenceThreshold
|
||||
) {
|
||||
setDirection("right");
|
||||
setCurrentSlide((init) => init + 1);
|
||||
} else if (currentSlide !== 0 && swipe > swipeConfidenceThreshold) {
|
||||
setDirection("left");
|
||||
setCurrentSlide((init) => init - 1);
|
||||
}
|
||||
}}
|
||||
onDragEnd={handleDragEnd}
|
||||
style={{
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
position: "absolute",
|
||||
}}
|
||||
>
|
||||
<CarouselSlide
|
||||
<MemoizedCarouselSlide
|
||||
item={content[currentSlide]}
|
||||
key={content[currentSlide].Id}
|
||||
/>
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
<Slider
|
||||
currentSlide={currentSlide}
|
||||
content={content.map((item, index) => (
|
||||
<motion.div
|
||||
className={
|
||||
currentSlide === index
|
||||
? "carousel-indicator active"
|
||||
: "carousel-indicator"
|
||||
}
|
||||
layout
|
||||
initial={{
|
||||
height: "4.6em",
|
||||
}}
|
||||
whileHover={{
|
||||
height: "5.5em",
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.05,
|
||||
}}
|
||||
key={item.Id}
|
||||
onClick={() => {
|
||||
if (currentSlide > index) {
|
||||
setDirection("left");
|
||||
} else if (currentSlide <= index) {
|
||||
setDirection("right");
|
||||
}
|
||||
setCurrentSlide(index);
|
||||
}}
|
||||
>
|
||||
{item.ImageTags?.Thumb ? (
|
||||
<img
|
||||
src={api.getItemImageUrl(item.Id, "Thumb", {
|
||||
tag: item.ImageTags.Primary,
|
||||
fillWidth: 300,
|
||||
})}
|
||||
alt={item.Name ?? "item-image"}
|
||||
className="carousel-indicator-image"
|
||||
/>
|
||||
) : (
|
||||
<div className="carousel-indicator-icon">
|
||||
{getTypeIcon(item.Type)}
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
))}
|
||||
/>
|
||||
<MemoizedSlider currentSlide={currentSlide} content={sliderContent} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Carousel;
|
||||
export default React.memo(Carousel);
|
||||
@@ -5,13 +5,13 @@ import { CardScroller } from "../../cardScroller/cardScroller";
|
||||
import { CardsSkeleton } from "../../skeleton/cards";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
/**
|
||||
* @description Latest Media Section
|
||||
@@ -26,7 +26,7 @@ export const LatestMediaSection = ({
|
||||
userId: user?.Id,
|
||||
parentId: library.Id,
|
||||
limit: 16,
|
||||
fields: ["PrimaryImageAspectRatio"],
|
||||
fields: ["PrimaryImageAspectRatio", "ParentId"],
|
||||
});
|
||||
return media.data;
|
||||
};
|
||||
|
||||
@@ -19,11 +19,11 @@ import PlayNextButton from "@/components/buttons/playNextButton";
|
||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||
import QueueButton from "@/components/buttons/queueButton";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { playItemFromQueue } from "@/utils/store/playback";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { playItemFromQueue } from "@/utils/store/playback";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
|
||||
const AudioPlayer = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
@@ -62,13 +62,117 @@ const AudioPlayer = () => {
|
||||
Authorization: api.authorizationHeader,
|
||||
},
|
||||
});
|
||||
|
||||
const currentTrackItem = tracks[currentTrack];
|
||||
|
||||
fetch(audioUrlRequest)
|
||||
.then((res) => res)
|
||||
.then(async (result) => {
|
||||
const blob = await result.blob();
|
||||
const blobUrl = URL.createObjectURL(blob);
|
||||
audioRef.current.src = blobUrl;
|
||||
audioRef.current.play();
|
||||
await audioRef.current.play();
|
||||
if ("mediaSession" in navigator) {
|
||||
navigator.mediaSession.playbackState = "playing";
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: currentTrackItem.Name ?? "Unknown audio",
|
||||
artist: currentTrackItem.Artists?.join(", "),
|
||||
album: currentTrackItem.Album ?? "",
|
||||
artwork: [
|
||||
{
|
||||
src: api.getItemImageUrl(currentTrackItem.Id, "Primary", {
|
||||
tag: currentTrackItem.ImageTags?.Primary,
|
||||
width: 96,
|
||||
height: 96,
|
||||
}),
|
||||
sizes: "96x96",
|
||||
type: "image/jpeg",
|
||||
},
|
||||
{
|
||||
src: api.getItemImageUrl(currentTrackItem.Id, "Primary", {
|
||||
tag: currentTrackItem.ImageTags?.Primary,
|
||||
width: 128,
|
||||
height: 128,
|
||||
}),
|
||||
sizes: "128x128",
|
||||
type: "image/jpeg",
|
||||
},
|
||||
{
|
||||
src: api.getItemImageUrl(currentTrackItem.Id, "Primary", {
|
||||
tag: currentTrackItem.ImageTags?.Primary,
|
||||
width: 192,
|
||||
height: 192,
|
||||
}),
|
||||
sizes: "192x192",
|
||||
type: "image/jpeg",
|
||||
},
|
||||
{
|
||||
src: api.getItemImageUrl(currentTrackItem.Id, "Primary", {
|
||||
tag: currentTrackItem.ImageTags?.Primary,
|
||||
width: 256,
|
||||
height: 256,
|
||||
}),
|
||||
sizes: "256x256",
|
||||
type: "image/jpeg",
|
||||
},
|
||||
{
|
||||
src: api.getItemImageUrl(currentTrackItem.Id, "Primary", {
|
||||
tag: currentTrackItem.ImageTags?.Primary,
|
||||
width: 384,
|
||||
height: 384,
|
||||
}),
|
||||
sizes: "384x384",
|
||||
type: "image/jpeg",
|
||||
},
|
||||
{
|
||||
src: api.getItemImageUrl(currentTrackItem.Id, "Primary", {
|
||||
tag: currentTrackItem.ImageTags?.Primary,
|
||||
width: 512,
|
||||
height: 512,
|
||||
}),
|
||||
sizes: "512x512",
|
||||
type: "image/jpeg",
|
||||
},
|
||||
],
|
||||
});
|
||||
console.log("Using MediaSession Api");
|
||||
// navigator.mediaSession.setActionHandler("play", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("pause", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("stop", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("seekbackward", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("seekforward", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("seekto", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("previoustrack", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("nexttrack", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("skipad", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("togglecamera", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("togglemicrophone", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
// navigator.mediaSession.setActionHandler("hangup", () => {
|
||||
// /* Code excerpted. */
|
||||
// });
|
||||
}
|
||||
setLoading(false);
|
||||
});
|
||||
setAudioRef(audioRef);
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
withStyles,
|
||||
} from "@mui/material";
|
||||
import { AnimatePresence, motion, transform } from "framer-motion";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
||||
|
||||
import logo from "@/assets/logo.png";
|
||||
|
||||
@@ -191,17 +191,28 @@ const Settings = () => {
|
||||
},
|
||||
});
|
||||
|
||||
// Memoize PaperProps to prevent unnecessary re-renders
|
||||
const paperProps = useMemo(
|
||||
() => ({
|
||||
className: "settings glass",
|
||||
elevation: 10,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
// Memoize onClose function to prevent unnecessary re-renders
|
||||
const handleClose = useCallback(() => {
|
||||
setSettingsDialogOpen(false);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
fullWidth
|
||||
maxWidth="md"
|
||||
PaperProps={{
|
||||
className: "settings glass",
|
||||
elevation: 10,
|
||||
}}
|
||||
PaperProps={paperProps}
|
||||
hideBackdrop
|
||||
onClose={() => setSettingsDialogOpen(false)}
|
||||
onClose={handleClose}
|
||||
>
|
||||
<Tabs
|
||||
orientation="vertical"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React, { useCallback, useMemo } from "react";
|
||||
|
||||
import { Dialog, Slide } from "@mui/material";
|
||||
import { useKonamiEasterEgg } from "../../utils/misc/konami";
|
||||
@@ -6,15 +6,22 @@ import { useKonamiEasterEgg } from "../../utils/misc/konami";
|
||||
export const EasterEgg = () => {
|
||||
const [easterEgg, setEasterEgg] = useKonamiEasterEgg();
|
||||
|
||||
// Memoize the onClose function
|
||||
const handleClose = useCallback(() => {
|
||||
setEasterEgg(false);
|
||||
}, [setEasterEgg]);
|
||||
|
||||
// Memoize the sx object
|
||||
const dialogSx = useMemo(
|
||||
() => ({
|
||||
background: "black",
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog
|
||||
open={easterEgg}
|
||||
onClose={() => setEasterEgg(false)}
|
||||
sx={{
|
||||
background: "black",
|
||||
}}
|
||||
>
|
||||
<Dialog open={easterEgg} onClose={handleClose} sx={dialogSx}>
|
||||
<iframe
|
||||
width="560"
|
||||
height="315"
|
||||
|
||||
+27
-1
@@ -25,6 +25,7 @@ import { Route as SetupServerErrorImport } from './routes/setup/server.error'
|
||||
import { Route as SetupServerAddImport } from './routes/setup/server.add'
|
||||
import { Route as ApiSeriesIdImport } from './routes/_api/series/$id'
|
||||
import { Route as ApiPlaylistIdImport } from './routes/_api/playlist/$id'
|
||||
import { Route as ApiPlayerPhotosImport } from './routes/_api/player/photos'
|
||||
import { Route as ApiPlayerAudioImport } from './routes/_api/player/audio'
|
||||
import { Route as ApiPersonIdImport } from './routes/_api/person/$id'
|
||||
import { Route as ApiLoginManualImport } from './routes/_api/login/manual'
|
||||
@@ -109,6 +110,11 @@ const ApiPlaylistIdRoute = ApiPlaylistIdImport.update({
|
||||
getParentRoute: () => ApiRoute,
|
||||
} as any)
|
||||
|
||||
const ApiPlayerPhotosRoute = ApiPlayerPhotosImport.update({
|
||||
path: '/player/photos',
|
||||
getParentRoute: () => ApiRoute,
|
||||
} as any)
|
||||
|
||||
const ApiPlayerAudioRoute = ApiPlayerAudioImport.update({
|
||||
path: '/player/audio',
|
||||
getParentRoute: () => ApiRoute,
|
||||
@@ -273,6 +279,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof ApiPlayerAudioImport
|
||||
parentRoute: typeof ApiImport
|
||||
}
|
||||
'/_api/player/photos': {
|
||||
id: '/_api/player/photos'
|
||||
path: '/player/photos'
|
||||
fullPath: '/player/photos'
|
||||
preLoaderRoute: typeof ApiPlayerPhotosImport
|
||||
parentRoute: typeof ApiImport
|
||||
}
|
||||
'/_api/playlist/$id': {
|
||||
id: '/_api/playlist/$id'
|
||||
path: '/playlist/$id'
|
||||
@@ -387,6 +400,7 @@ interface ApiRouteChildren {
|
||||
ApiLibraryIdRoute: typeof ApiLibraryIdRoute
|
||||
ApiPersonIdRoute: typeof ApiPersonIdRoute
|
||||
ApiPlayerAudioRoute: typeof ApiPlayerAudioRoute
|
||||
ApiPlayerPhotosRoute: typeof ApiPlayerPhotosRoute
|
||||
ApiPlaylistIdRoute: typeof ApiPlaylistIdRoute
|
||||
ApiSeriesIdRoute: typeof ApiSeriesIdRoute
|
||||
ApiFavoriteIndexRoute: typeof ApiFavoriteIndexRoute
|
||||
@@ -405,6 +419,7 @@ const ApiRouteChildren: ApiRouteChildren = {
|
||||
ApiLibraryIdRoute: ApiLibraryIdRoute,
|
||||
ApiPersonIdRoute: ApiPersonIdRoute,
|
||||
ApiPlayerAudioRoute: ApiPlayerAudioRoute,
|
||||
ApiPlayerPhotosRoute: ApiPlayerPhotosRoute,
|
||||
ApiPlaylistIdRoute: ApiPlaylistIdRoute,
|
||||
ApiSeriesIdRoute: ApiSeriesIdRoute,
|
||||
ApiFavoriteIndexRoute: ApiFavoriteIndexRoute,
|
||||
@@ -430,6 +445,7 @@ export interface FileRoutesByFullPath {
|
||||
'/login/manual': typeof ApiLoginManualRoute
|
||||
'/person/$id': typeof ApiPersonIdRoute
|
||||
'/player/audio': typeof ApiPlayerAudioRoute
|
||||
'/player/photos': typeof ApiPlayerPhotosRoute
|
||||
'/playlist/$id': typeof ApiPlaylistIdRoute
|
||||
'/series/$id': typeof ApiSeriesIdRoute
|
||||
'/setup/server/add': typeof SetupServerAddRoute
|
||||
@@ -457,6 +473,7 @@ export interface FileRoutesByTo {
|
||||
'/login/manual': typeof ApiLoginManualRoute
|
||||
'/person/$id': typeof ApiPersonIdRoute
|
||||
'/player/audio': typeof ApiPlayerAudioRoute
|
||||
'/player/photos': typeof ApiPlayerPhotosRoute
|
||||
'/playlist/$id': typeof ApiPlaylistIdRoute
|
||||
'/series/$id': typeof ApiSeriesIdRoute
|
||||
'/setup/server/add': typeof SetupServerAddRoute
|
||||
@@ -486,6 +503,7 @@ export interface FileRoutesById {
|
||||
'/_api/login/manual': typeof ApiLoginManualRoute
|
||||
'/_api/person/$id': typeof ApiPersonIdRoute
|
||||
'/_api/player/audio': typeof ApiPlayerAudioRoute
|
||||
'/_api/player/photos': typeof ApiPlayerPhotosRoute
|
||||
'/_api/playlist/$id': typeof ApiPlaylistIdRoute
|
||||
'/_api/series/$id': typeof ApiSeriesIdRoute
|
||||
'/setup/server/add': typeof SetupServerAddRoute
|
||||
@@ -516,6 +534,7 @@ export interface FileRouteTypes {
|
||||
| '/login/manual'
|
||||
| '/person/$id'
|
||||
| '/player/audio'
|
||||
| '/player/photos'
|
||||
| '/playlist/$id'
|
||||
| '/series/$id'
|
||||
| '/setup/server/add'
|
||||
@@ -542,6 +561,7 @@ export interface FileRouteTypes {
|
||||
| '/login/manual'
|
||||
| '/person/$id'
|
||||
| '/player/audio'
|
||||
| '/player/photos'
|
||||
| '/playlist/$id'
|
||||
| '/series/$id'
|
||||
| '/setup/server/add'
|
||||
@@ -569,6 +589,7 @@ export interface FileRouteTypes {
|
||||
| '/_api/login/manual'
|
||||
| '/_api/person/$id'
|
||||
| '/_api/player/audio'
|
||||
| '/_api/player/photos'
|
||||
| '/_api/playlist/$id'
|
||||
| '/_api/series/$id'
|
||||
| '/setup/server/add'
|
||||
@@ -636,6 +657,7 @@ export const routeTree = rootRoute
|
||||
"/_api/library/$id",
|
||||
"/_api/person/$id",
|
||||
"/_api/player/audio",
|
||||
"/_api/player/photos",
|
||||
"/_api/playlist/$id",
|
||||
"/_api/series/$id",
|
||||
"/_api/favorite/",
|
||||
@@ -702,6 +724,10 @@ export const routeTree = rootRoute
|
||||
"filePath": "_api/player/audio.tsx",
|
||||
"parent": "/_api"
|
||||
},
|
||||
"/_api/player/photos": {
|
||||
"filePath": "_api/player/photos.tsx",
|
||||
"parent": "/_api"
|
||||
},
|
||||
"/_api/playlist/$id": {
|
||||
"filePath": "_api/playlist/$id.jsx",
|
||||
"parent": "/_api"
|
||||
@@ -732,7 +758,7 @@ export const routeTree = rootRoute
|
||||
"parent": "/_api"
|
||||
},
|
||||
"/_api/search/": {
|
||||
"filePath": "_api/search/index.jsx",
|
||||
"filePath": "_api/search/index.tsx",
|
||||
"parent": "/_api/search"
|
||||
},
|
||||
"/_api/login/$userId/$userName": {
|
||||
|
||||
@@ -265,7 +265,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
||||
<AppBar />
|
||||
<AudioPlayer />
|
||||
<Outlet />
|
||||
{/* <ReactQueryDevtools /> */}
|
||||
<ReactQueryDevtools />
|
||||
{/* <TanStackRouterDevtools /> */}
|
||||
</SnackbarProvider>
|
||||
</ThemeProvider>
|
||||
|
||||
@@ -15,16 +15,16 @@ import { CarouselSkeleton } from "@/components/skeleton/carousel";
|
||||
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import { setBackdrop } from "@/utils/store/backdrop";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
@@ -32,7 +32,6 @@ import {
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
export const Route = createFileRoute("/_api/home/")({
|
||||
component: Home,
|
||||
@@ -67,6 +66,11 @@ function Home() {
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.MediaSources,
|
||||
],
|
||||
includeItemTypes: [
|
||||
BaseItemKind.Movie,
|
||||
BaseItemKind.Series,
|
||||
BaseItemKind.MusicAlbum,
|
||||
],
|
||||
enableUserData: true,
|
||||
enableImages: true,
|
||||
});
|
||||
@@ -131,6 +135,8 @@ function Home() {
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||
|
||||
const [excludeTypes] = useState(
|
||||
() => new Set(["boxsets", "playlists", "livetv", "channels"]),
|
||||
);
|
||||
@@ -139,7 +145,7 @@ function Home() {
|
||||
if (libraries.isSuccess) {
|
||||
const latestMediaLibsTemp = libraries.data.Items?.reduce(
|
||||
(filteredItems: BaseItemDto[], currentItem) => {
|
||||
if (!excludeTypes.has(currentItem.Type)) {
|
||||
if (currentItem.Type && !excludeTypes.has(currentItem.Type)) {
|
||||
filteredItems.push(currentItem);
|
||||
}
|
||||
return filteredItems;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
.photos {
|
||||
background: black;
|
||||
overflow: hidden;
|
||||
height: 100vh;
|
||||
&-currentPhoto {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
object-fit: contain;
|
||||
}
|
||||
&-overlay{
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
}
|
||||
&-preview {
|
||||
// width: 10vw;
|
||||
height: 10vh;
|
||||
object-fit: cover;
|
||||
border: 2px;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 4px;
|
||||
transition: border $transition-time-default;
|
||||
&-container {
|
||||
width: 90vw;
|
||||
overflow-y: hidden;
|
||||
overflow-x: auto;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
margin: 0 auto;
|
||||
bottom: 0;
|
||||
left: 5vw;
|
||||
}
|
||||
&.active {
|
||||
border-color: $clr-accent-default;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import brokenImage from "../../../../public/assetsStatic/broken-image.png";
|
||||
|
||||
import "./photos.scss";
|
||||
import { Button } from "@mui/material";
|
||||
|
||||
export const Route = createFileRoute("/_api/player/photos")({
|
||||
component: PhotosPlayer,
|
||||
});
|
||||
|
||||
function PhotosPlayer() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const [photos, startIndex] = usePhotosPlayback((s) => [s.photos, s.index]);
|
||||
const [currentIndex, setCurrentIndex] = useState(startIndex);
|
||||
const currentPhoto = useMemo(
|
||||
() => photos?.[currentIndex],
|
||||
[photos, currentIndex],
|
||||
);
|
||||
const allPhotos = useMemo(
|
||||
() =>
|
||||
photos?.map((item, index) => (
|
||||
<div
|
||||
onClick={() => setCurrentIndex(index)}
|
||||
key={item?.Id ?? "noPhoto"}
|
||||
className={
|
||||
index === currentIndex ? "photos-preview active" : "photos-preview"
|
||||
}
|
||||
>
|
||||
<img
|
||||
src={
|
||||
item.Id
|
||||
? api.getItemImageUrl(item.Id, "Primary", {
|
||||
// width: 250,
|
||||
fillWidth: 250,
|
||||
quality: 70,
|
||||
})
|
||||
: brokenImage
|
||||
}
|
||||
style={{
|
||||
width: "auto",
|
||||
height: "100%",
|
||||
borderRadius: "2px",
|
||||
}}
|
||||
alt="Item"
|
||||
/>
|
||||
</div>
|
||||
)),
|
||||
[photos, currentIndex],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="photos">
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.img
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
key={currentPhoto?.Id ?? "noPhoto"}
|
||||
src={
|
||||
currentPhoto
|
||||
? `${api.basePath}/Items/${currentPhoto.Id}/Download?api_key=${api.accessToken}`
|
||||
: brokenImage
|
||||
}
|
||||
alt="Item"
|
||||
transition={{ duration: 0.1 }}
|
||||
className="photos-currentPhoto"
|
||||
/>
|
||||
</AnimatePresence>
|
||||
<motion.div
|
||||
className="photos-overlay"
|
||||
whileHover={{ opacity: 1, transform: "translateY(0)" }}
|
||||
style={{ opacity: 0.5, transform: "translateY(80%)" }}
|
||||
>
|
||||
<div className="photos-preview-container">{allPhotos}</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -21,12 +21,15 @@ import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
||||
import "./search.scss";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { Dialog, Fab } from "@mui/material";
|
||||
import { Outlet, createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
export const Route = createFileRoute("/_api/search/")({
|
||||
component: SearchPage,
|
||||
validateSearch: (search: Record<string, unknown>): { query: string } => {
|
||||
return { query: search.query as string };
|
||||
},
|
||||
});
|
||||
|
||||
function SearchPage() {
|
||||
@@ -37,8 +37,6 @@ export const playAudio = (
|
||||
url: string,
|
||||
item: BaseItemDto | undefined | null,
|
||||
playlistItemId: string | undefined,
|
||||
queue: BaseItemDto[] | undefined,
|
||||
queueItemIndex: number,
|
||||
): void => {
|
||||
useAudioPlayback.setState({
|
||||
display: true,
|
||||
@@ -46,7 +44,6 @@ export const playAudio = (
|
||||
item,
|
||||
playlistItemId,
|
||||
});
|
||||
setQueue(queue, queueItemIndex);
|
||||
};
|
||||
|
||||
export const generateAudioStreamUrl = (
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { create } from "zustand";
|
||||
import { devtools } from "zustand/middleware";
|
||||
import { immer } from "zustand/middleware/immer";
|
||||
import { shallow } from "zustand/shallow";
|
||||
import { createWithEqualityFn } from "zustand/traditional";
|
||||
import { usePlaybackStore } from "./playback";
|
||||
|
||||
type PhotosPlaybackStore = {
|
||||
photos: BaseItemDto[] | null;
|
||||
index: number;
|
||||
playPhotos: (photos: BaseItemDto[], index: number) => void;
|
||||
};
|
||||
|
||||
type PhotosPlaybackStoreActions = {
|
||||
playPhotos: (photos: BaseItemDto[]) => void;
|
||||
};
|
||||
|
||||
export const usePhotosPlayback = createWithEqualityFn<PhotosPlaybackStore>()(
|
||||
devtools(
|
||||
immer((set) => ({
|
||||
photos: null,
|
||||
playPhotos: (photos, index) =>
|
||||
set((state) => {
|
||||
state.photos = photos;
|
||||
state.index = index;
|
||||
}),
|
||||
index: 0,
|
||||
})),
|
||||
),
|
||||
shallow,
|
||||
);
|
||||
@@ -1,4 +1,3 @@
|
||||
import { create } from "zustand";
|
||||
import { shallow } from "zustand/shallow";
|
||||
import { createWithEqualityFn } from "zustand/traditional";
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import type {
|
||||
import type IntroMediaInfo from "./introMediaInfo";
|
||||
|
||||
interface PlayResult {
|
||||
item: BaseItemDtoQueryResult;
|
||||
mediaSource: PlaybackInfoResponse;
|
||||
item: BaseItemDtoQueryResult | undefined;
|
||||
mediaSource: PlaybackInfoResponse | undefined;
|
||||
introInfo: IntroMediaInfo | undefined;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user