fix: player throws error whenever settings panel is openned
This commit is contained in:
11 files changed
+113
-115
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import { Link, Typography } from "@mui/material";
|
import { Link, Tooltip } from "@mui/material";
|
||||||
import React, { memo } from "react";
|
import React, { memo } from "react";
|
||||||
|
|
||||||
import anidbIcon from "../../assets/icons/anidb.png";
|
import anidbIcon from "../../assets/icons/anidb.png";
|
||||||
@@ -12,54 +12,49 @@ import tmdbIcon from "../../assets/icons/themoviedatabase.svg";
|
|||||||
import traktIcon from "../../assets/icons/trakt.svg";
|
import traktIcon from "../../assets/icons/trakt.svg";
|
||||||
import tvMazeIcon from "../../assets/icons/tvmaze.png";
|
import tvMazeIcon from "../../assets/icons/tvmaze.png";
|
||||||
|
|
||||||
const knownIcons = [
|
/**
|
||||||
"imdb",
|
* Provider icons keyed by the start of the normalized link name, so variants like
|
||||||
"themoviedb",
|
* "TMDB"/"TheMovieDb", "TVDB"/"TheTVDB" or "MusicBrainz Artist" all match.
|
||||||
"trakt",
|
*/
|
||||||
"musicbrainz",
|
const providerIcons: [prefixes: string[], icon: string][] = [
|
||||||
"thetvdb",
|
[["imdb"], imdbIcon],
|
||||||
"anidb",
|
[["tmdb", "themoviedb"], tmdbIcon],
|
||||||
"anilist",
|
[["tvdb", "thetvdb"], tvDbIcon],
|
||||||
"tvmaze",
|
[["trakt"], traktIcon],
|
||||||
"theaudiodb",
|
[["musicbrainz"], musicBrainzIcon],
|
||||||
"kitsu",
|
[["anidb"], anidbIcon],
|
||||||
|
[["anilist"], anilistIcon],
|
||||||
|
[["tvmaze"], tvMazeIcon],
|
||||||
|
[["theaudiodb", "audiodb"], audioDBIcon],
|
||||||
|
[["kitsu"], kitsuIcon],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const getProviderIcon = (name: string) => {
|
||||||
|
const normalized = name.toLocaleLowerCase().replace(/[^a-z0-9]/g, "");
|
||||||
|
return providerIcons.find(([prefixes]) =>
|
||||||
|
prefixes.some((prefix) => normalized.startsWith(prefix)),
|
||||||
|
)?.[1];
|
||||||
|
};
|
||||||
|
|
||||||
const IconLink = memo(({ name, url }: { name: string; url: string }) => {
|
const IconLink = memo(({ name, url }: { name: string; url: string }) => {
|
||||||
|
const icon = getProviderIcon(name);
|
||||||
return (
|
return (
|
||||||
<Link target="_blank" href={url} className="item-detail-link">
|
<Tooltip title={name}>
|
||||||
{name.toLocaleLowerCase() === "imdb" && <img src={imdbIcon} alt="IMDb" />}
|
<Link
|
||||||
{name.toLocaleLowerCase() === "themoviedb" && (
|
target="_blank"
|
||||||
<img src={tmdbIcon} alt="TheMovieDb" />
|
href={url}
|
||||||
)}
|
className="item-detail-link"
|
||||||
{name.toLocaleLowerCase() === "trakt" && (
|
aria-label={name}
|
||||||
<img src={traktIcon} alt="Trakt" />
|
>
|
||||||
)}
|
{icon ? (
|
||||||
{name.toLocaleLowerCase() === "musicbrainz" && (
|
<img src={icon} alt={name} />
|
||||||
<img src={musicBrainzIcon} alt="MusicBrainz" />
|
) : (
|
||||||
)}
|
<span className="material-symbols-rounded item-detail-link-generic">
|
||||||
{name.toLocaleLowerCase() === "thetvdb" && (
|
link
|
||||||
<img src={tvDbIcon} alt="TheTVDB" />
|
</span>
|
||||||
)}
|
)}
|
||||||
{name.toLocaleLowerCase() === "anidb" && (
|
</Link>
|
||||||
<img src={anidbIcon} alt="AniDB" />
|
</Tooltip>
|
||||||
)}
|
|
||||||
{name.toLocaleLowerCase() === "anilist" && (
|
|
||||||
<img src={anilistIcon} alt="AniList" />
|
|
||||||
)}
|
|
||||||
{name.toLocaleLowerCase() === "tvmaze" && (
|
|
||||||
<img src={tvMazeIcon} alt="TVMaze" />
|
|
||||||
)}
|
|
||||||
{name.toLocaleLowerCase() === "theaudiodb" && (
|
|
||||||
<img src={audioDBIcon} alt="TheAudioDB" />
|
|
||||||
)}
|
|
||||||
{name.toLocaleLowerCase() === "kitsu" && (
|
|
||||||
<img src={kitsuIcon} alt="Kitsu" />
|
|
||||||
)}
|
|
||||||
{!knownIcons.includes(name.toLocaleLowerCase()) && (
|
|
||||||
<Typography>{name}</Typography>
|
|
||||||
)}
|
|
||||||
</Link>
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,16 @@
|
|||||||
filter: brightness(0.5);
|
filter: brightness(0.5);
|
||||||
transition: filter $transition-time-default;
|
transition: filter $transition-time-default;
|
||||||
}
|
}
|
||||||
|
&-generic {
|
||||||
|
display: block;
|
||||||
|
font-size: 2em !important;
|
||||||
|
color: white;
|
||||||
|
opacity: 0.5;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
|
}
|
||||||
|
&:hover > &-generic {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
|
|||||||
@@ -31,15 +31,16 @@ export const ErrorNotice = ({ error }: { error?: Error }) => {
|
|||||||
</div>
|
</div>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h3"
|
variant="h3"
|
||||||
color="white"
|
|
||||||
sx={{
|
sx={{
|
||||||
|
color: "white",
|
||||||
fontWeight: 300,
|
fontWeight: 300,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Something went wrong.
|
Something went wrong.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h5"
|
variant="body2"
|
||||||
|
component="pre"
|
||||||
style={{
|
style={{
|
||||||
padding: "0.5em",
|
padding: "0.5em",
|
||||||
background: "rgb(0 0 0 / 1)",
|
background: "rgb(0 0 0 / 1)",
|
||||||
@@ -49,15 +50,16 @@ export const ErrorNotice = ({ error }: { error?: Error }) => {
|
|||||||
maxHeight: "20em",
|
maxHeight: "20em",
|
||||||
overflow: "auto",
|
overflow: "auto",
|
||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
// opacity: 0.6,
|
whiteSpace: "pre-wrap",
|
||||||
}}
|
}}
|
||||||
color="gray"
|
|
||||||
sx={{
|
sx={{
|
||||||
|
color: "grey.400",
|
||||||
fontFamily: "JetBrains Mono Variable",
|
fontFamily: "JetBrains Mono Variable",
|
||||||
fontWeight: 100,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{JSON.stringify(error?.stack)}
|
{error
|
||||||
|
? error.stack || `${error.name}: ${error.message}`
|
||||||
|
: "Unknown error"}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ const BubbleSlider = () => {
|
|||||||
const backgroundOffsetY = -(imageOffsetY * trickplayResolution?.Height);
|
const backgroundOffsetY = -(imageOffsetY * trickplayResolution?.Height);
|
||||||
|
|
||||||
const imgUrlParamsObject: Record<string, string> = {
|
const imgUrlParamsObject: Record<string, string> = {
|
||||||
api_key: String(api?.accessToken),
|
ApiKey: String(api?.accessToken),
|
||||||
MediaSourceId: mediaSource.id ?? "",
|
MediaSourceId: mediaSource.id ?? "",
|
||||||
};
|
};
|
||||||
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
|
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
MenuItem,
|
MenuItem,
|
||||||
|
MenuList,
|
||||||
Popover,
|
Popover,
|
||||||
Switch,
|
Switch,
|
||||||
TextField,
|
TextField,
|
||||||
@@ -144,16 +145,18 @@ const VideoPlayerSettingsMenu = ({
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</TextField>
|
</TextField>
|
||||||
<MenuItem onClick={toggleShowStatsForNerds}>
|
<MenuList disablePadding>
|
||||||
<Typography
|
<MenuItem onClick={toggleShowStatsForNerds}>
|
||||||
sx={{
|
<Typography
|
||||||
flexGrow: 1,
|
sx={{
|
||||||
}}
|
flexGrow: 1,
|
||||||
>
|
}}
|
||||||
Stats for Nerds
|
>
|
||||||
</Typography>
|
Stats for Nerds
|
||||||
<Switch checked={showStatsForNerds} />
|
</Typography>
|
||||||
</MenuItem>
|
<Switch checked={showStatsForNerds} />
|
||||||
|
</MenuItem>
|
||||||
|
</MenuList>
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useQueries, useSuspenseQuery } from "@tanstack/react-query";
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import React, { useCallback, useMemo } from "react";
|
import React, { useCallback, useMemo } from "react";
|
||||||
|
|
||||||
import "./home.scss";
|
import "./home.scss";
|
||||||
@@ -24,25 +24,11 @@ import Carousel from "@/components/carousel";
|
|||||||
import CircularPageLoadingAnimation from "@/components/circularPageLoadingAnimation";
|
import CircularPageLoadingAnimation from "@/components/circularPageLoadingAnimation";
|
||||||
import { LatestMediaSection } from "@/components/layouts/homeSection/latestMediaSection";
|
import { LatestMediaSection } from "@/components/layouts/homeSection/latestMediaSection";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import {
|
import { getLatestItemsQueryOptions } from "@/utils/queries/items";
|
||||||
getLatestItemsQueryOptions,
|
|
||||||
getLibraryLatestQueryOptions,
|
|
||||||
} from "@/utils/queries/items";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
const heroItemTypes = new Set<string>([
|
|
||||||
BaseItemKind.Movie,
|
|
||||||
BaseItemKind.Series,
|
|
||||||
BaseItemKind.Episode,
|
|
||||||
BaseItemKind.MusicAlbum,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const combineLibraryLatest = (
|
|
||||||
results: { data?: BaseItemDto[] | null }[],
|
|
||||||
): BaseItemDto[][] => results.map((result) => result.data ?? []);
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/home/")({
|
export const Route = createFileRoute("/_api/home/")({
|
||||||
component: Home,
|
component: Home,
|
||||||
pendingComponent: () => <CircularPageLoadingAnimation />,
|
pendingComponent: () => <CircularPageLoadingAnimation />,
|
||||||
@@ -141,28 +127,14 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
|||||||
}
|
}
|
||||||
}, [libraries.data?.Items?.length]);
|
}, [libraries.data?.Items?.length]);
|
||||||
|
|
||||||
// The per-library "latest" rows; shares cache entries with LatestMediaSection.
|
const heroItems = useMemo(
|
||||||
const libraryLatest = useQueries({
|
() =>
|
||||||
queries: (latestMediaLibs ?? []).map((lib) =>
|
latestMedia.data?.filter(
|
||||||
getLibraryLatestQueryOptions(api, user.Id, lib.Id),
|
(item) =>
|
||||||
),
|
item.Type === BaseItemKind.Movie || item.Type === BaseItemKind.Series,
|
||||||
combine: combineLibraryLatest,
|
) ?? [],
|
||||||
});
|
[latestMedia.data],
|
||||||
|
);
|
||||||
// Some servers return nothing for the global /Items/Latest query, so fall back to
|
|
||||||
// interleaving the per-library results (each already newest-first).
|
|
||||||
const heroItems = useMemo(() => {
|
|
||||||
if (latestMedia.data?.length) return latestMedia.data;
|
|
||||||
const items: BaseItemDto[] = [];
|
|
||||||
const longest = Math.max(0, ...libraryLatest.map((list) => list.length));
|
|
||||||
for (let index = 0; index < longest; index++) {
|
|
||||||
for (const list of libraryLatest) {
|
|
||||||
const item = list[index];
|
|
||||||
if (item?.Type && heroItemTypes.has(item.Type)) items.push(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return items.slice(0, 16);
|
|
||||||
}, [latestMedia.data, libraryLatest]);
|
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function addSubtitleTrackToReactPlayer(
|
|||||||
|
|
||||||
const track = document.createElement("track");
|
const track = document.createElement("track");
|
||||||
const separator = subtitleTracks.url.includes("?") ? "&" : "?";
|
const separator = subtitleTracks.url.includes("?") ? "&" : "?";
|
||||||
const urlParams = apiKey ? `${separator}api_key=${apiKey}` : "";
|
const urlParams = apiKey ? `${separator}ApiKey=${apiKey}` : "";
|
||||||
track.src = `${baseUrl}${subtitleTracks.url}${urlParams}`;
|
track.src = `${baseUrl}${subtitleTracks.url}${urlParams}`;
|
||||||
track.kind = "subtitles";
|
track.kind = "subtitles";
|
||||||
track.srclang = reqSubTrack.Language ?? "en";
|
track.srclang = reqSubTrack.Language ?? "en";
|
||||||
@@ -458,7 +458,7 @@ export function VideoPlayer() {
|
|||||||
let pgsRenderer: PgsRenderer | undefined;
|
let pgsRenderer: PgsRenderer | undefined;
|
||||||
const apiKey = api?.accessToken;
|
const apiKey = api?.accessToken;
|
||||||
const separator = mediaSource.subtitle.url?.includes("?") ? "&" : "?";
|
const separator = mediaSource.subtitle.url?.includes("?") ? "&" : "?";
|
||||||
const urlParams = apiKey ? `${separator}api_key=${apiKey}` : "";
|
const urlParams = apiKey ? `${separator}ApiKey=${apiKey}` : "";
|
||||||
|
|
||||||
if (
|
if (
|
||||||
mediaSource.subtitle.format === "ass" ||
|
mediaSource.subtitle.format === "ass" ||
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ function PhotosPlayer() {
|
|||||||
|
|
||||||
if (pathToSave) {
|
if (pathToSave) {
|
||||||
download(
|
download(
|
||||||
`${api?.basePath}/Items/${currentPhoto?.Id}/Download?api_key=${api?.accessToken}`,
|
`${api?.basePath}/Items/${currentPhoto?.Id}/Download?ApiKey=${api?.accessToken}`,
|
||||||
pathToSave,
|
pathToSave,
|
||||||
);
|
);
|
||||||
enqueueSnackbar("Image download queued.", { variant: "info" });
|
enqueueSnackbar("Image download queued.", { variant: "info" });
|
||||||
@@ -122,7 +122,7 @@ function PhotosPlayer() {
|
|||||||
key={currentPhoto?.Id ?? "noPhoto"}
|
key={currentPhoto?.Id ?? "noPhoto"}
|
||||||
src={
|
src={
|
||||||
currentPhoto
|
currentPhoto
|
||||||
? `${api?.basePath}/Items/${currentPhoto.Id}/Download?api_key=${api?.accessToken}`
|
? `${api?.basePath}/Items/${currentPhoto.Id}/Download?ApiKey=${api?.accessToken}`
|
||||||
: brokenImage
|
: brokenImage
|
||||||
}
|
}
|
||||||
alt="Item"
|
alt="Item"
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import type { Api } from "@jellyfin/sdk";
|
import type { Api } from "@jellyfin/sdk";
|
||||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
import {
|
||||||
|
BaseItemKind,
|
||||||
|
ItemFields,
|
||||||
|
ItemSortBy,
|
||||||
|
LocationType,
|
||||||
|
SortOrder,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import { queryOptions } from "@tanstack/react-query";
|
import { queryOptions } from "@tanstack/react-query";
|
||||||
|
|
||||||
@@ -51,7 +57,7 @@ export const getLatestItemsQueryOptions = (
|
|||||||
if (!userId) {
|
if (!userId) {
|
||||||
throw Error("User ID is not defined");
|
throw Error("User ID is not defined");
|
||||||
}
|
}
|
||||||
const media = await getLibraryApi(api).getLatestMedia({
|
const request = {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
fields: [
|
fields: [
|
||||||
ItemFields.Overview,
|
ItemFields.Overview,
|
||||||
@@ -61,15 +67,25 @@ export const getLatestItemsQueryOptions = (
|
|||||||
ItemFields.MediaStreams,
|
ItemFields.MediaStreams,
|
||||||
ItemFields.MediaSources,
|
ItemFields.MediaSources,
|
||||||
],
|
],
|
||||||
includeItemTypes: [
|
includeItemTypes: [BaseItemKind.Movie, BaseItemKind.Series],
|
||||||
BaseItemKind.Movie,
|
|
||||||
BaseItemKind.Series,
|
|
||||||
BaseItemKind.MusicAlbum,
|
|
||||||
],
|
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
enableImages: true,
|
enableImages: true,
|
||||||
|
};
|
||||||
|
const media = await getLibraryApi(api).getLatestMedia(request);
|
||||||
|
if (media.data.length > 0) {
|
||||||
|
return media.data;
|
||||||
|
}
|
||||||
|
// Jellyfin 12 returns nothing for /Items/Latest without a parentId, so fall back
|
||||||
|
// to the most recently added movies and series.
|
||||||
|
const recent = await getLibraryApi(api).getItems({
|
||||||
|
...request,
|
||||||
|
recursive: true,
|
||||||
|
sortBy: [ItemSortBy.DateCreated],
|
||||||
|
sortOrder: [SortOrder.Descending],
|
||||||
|
excludeLocationTypes: [LocationType.Virtual],
|
||||||
|
limit: 16,
|
||||||
});
|
});
|
||||||
return media.data;
|
return recent.data.Items ?? [];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export const generateAudioStreamUrl = (
|
|||||||
const urlOptions = {
|
const urlOptions = {
|
||||||
userId,
|
userId,
|
||||||
deviceId,
|
deviceId,
|
||||||
api_key,
|
ApiKey: api_key,
|
||||||
container: directPlayContainers,
|
container: directPlayContainers,
|
||||||
maxAudioChannels: transcodingProfile?.MaxAudioChannels,
|
maxAudioChannels: transcodingProfile?.MaxAudioChannels,
|
||||||
transcodingContainer: transcodingProfile?.Container,
|
transcodingContainer: transcodingProfile?.Container,
|
||||||
|
|||||||
@@ -788,7 +788,7 @@ export const initializePlayback = async (args: {
|
|||||||
tag: source.ETag,
|
tag: source.ETag,
|
||||||
mediaSourceId: source.Id,
|
mediaSourceId: source.Id,
|
||||||
deviceId: api.deviceInfo.id,
|
deviceId: api.deviceInfo.id,
|
||||||
api_key: api.accessToken,
|
ApiKey: api.accessToken,
|
||||||
};
|
};
|
||||||
|
|
||||||
let playMethod: PlayMethod = PlayMethod.Transcode;
|
let playMethod: PlayMethod = PlayMethod.Transcode;
|
||||||
@@ -1045,7 +1045,7 @@ export const changeAudioTrack = async (trackIndex: number, api: Api) => {
|
|||||||
tag: mediaSource.MediaSources?.[0].ETag,
|
tag: mediaSource.MediaSources?.[0].ETag,
|
||||||
mediaSourceId: mediaSource.MediaSources?.[0].Id,
|
mediaSourceId: mediaSource.MediaSources?.[0].Id,
|
||||||
deviceId: api?.deviceInfo.id,
|
deviceId: api?.deviceInfo.id,
|
||||||
api_key: api?.accessToken,
|
ApiKey: api?.accessToken,
|
||||||
};
|
};
|
||||||
const urlParams = new URLSearchParams(urlOptions).toString();
|
const urlParams = new URLSearchParams(urlOptions).toString();
|
||||||
let playbackUrl = `${api?.basePath}/Videos/${mediaSource.MediaSources?.[0].Id}/stream.${mediaSource.MediaSources?.[0].Container}?${urlParams}`;
|
let playbackUrl = `${api?.basePath}/Videos/${mediaSource.MediaSources?.[0].Id}/stream.${mediaSource.MediaSources?.[0].Container}?${urlParams}`;
|
||||||
|
|||||||
Reference in new issue
Block a user