fix: player throws error whenever settings panel is openned

This commit is contained in:
--remove-section committed 2026-10-20 18:08:50 +05:30
1 parent 0c50acddd9
commit 2d5f49c32e
11 files changed
+113 -115

No files matched your search

+40 -45
View File
@@ -1,4 +1,4 @@
import { Link, Typography } from "@mui/material";
import { Link, Tooltip } from "@mui/material";
import React, { memo } from "react";
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 tvMazeIcon from "../../assets/icons/tvmaze.png";
const knownIcons = [
"imdb",
"themoviedb",
"trakt",
"musicbrainz",
"thetvdb",
"anidb",
"anilist",
"tvmaze",
"theaudiodb",
"kitsu",
/**
* Provider icons keyed by the start of the normalized link name, so variants like
* "TMDB"/"TheMovieDb", "TVDB"/"TheTVDB" or "MusicBrainz Artist" all match.
*/
const providerIcons: [prefixes: string[], icon: string][] = [
[["imdb"], imdbIcon],
[["tmdb", "themoviedb"], tmdbIcon],
[["tvdb", "thetvdb"], tvDbIcon],
[["trakt"], traktIcon],
[["musicbrainz"], musicBrainzIcon],
[["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 icon = getProviderIcon(name);
return (
<Link target="_blank" href={url} className="item-detail-link">
{name.toLocaleLowerCase() === "imdb" && <img src={imdbIcon} alt="IMDb" />}
{name.toLocaleLowerCase() === "themoviedb" && (
<img src={tmdbIcon} alt="TheMovieDb" />
)}
{name.toLocaleLowerCase() === "trakt" && (
<img src={traktIcon} alt="Trakt" />
)}
{name.toLocaleLowerCase() === "musicbrainz" && (
<img src={musicBrainzIcon} alt="MusicBrainz" />
)}
{name.toLocaleLowerCase() === "thetvdb" && (
<img src={tvDbIcon} alt="TheTVDB" />
)}
{name.toLocaleLowerCase() === "anidb" && (
<img src={anidbIcon} alt="AniDB" />
)}
{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>
<Tooltip title={name}>
<Link
target="_blank"
href={url}
className="item-detail-link"
aria-label={name}
>
{icon ? (
<img src={icon} alt={name} />
) : (
<span className="material-symbols-rounded item-detail-link-generic">
link
</span>
)}
</Link>
</Tooltip>
);
});
+10
View File
@@ -208,6 +208,16 @@
filter: brightness(0.5);
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 {
@@ -31,15 +31,16 @@ export const ErrorNotice = ({ error }: { error?: Error }) => {
</div>
<Typography
variant="h3"
color="white"
sx={{
color: "white",
fontWeight: 300,
}}
>
Something went wrong.
</Typography>
<Typography
variant="h5"
variant="body2"
component="pre"
style={{
padding: "0.5em",
background: "rgb(0 0 0 / 1)",
@@ -49,15 +50,16 @@ export const ErrorNotice = ({ error }: { error?: Error }) => {
maxHeight: "20em",
overflow: "auto",
marginTop: "1em",
// opacity: 0.6,
whiteSpace: "pre-wrap",
}}
color="gray"
sx={{
color: "grey.400",
fontFamily: "JetBrains Mono Variable",
fontWeight: 100,
}}
>
{JSON.stringify(error?.stack)}
{error
? error.stack || `${error.name}: ${error.message}`
: "Unknown error"}
</Typography>
</Box>
);
@@ -190,7 +190,7 @@ const BubbleSlider = () => {
const backgroundOffsetY = -(imageOffsetY * trickplayResolution?.Height);
const imgUrlParamsObject: Record<string, string> = {
api_key: String(api?.accessToken),
ApiKey: String(api?.accessToken),
MediaSourceId: mediaSource.id ?? "",
};
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
@@ -1,5 +1,6 @@
import {
MenuItem,
MenuList,
Popover,
Switch,
TextField,
@@ -144,16 +145,18 @@ const VideoPlayerSettingsMenu = ({
</MenuItem>
))}
</TextField>
<MenuItem onClick={toggleShowStatsForNerds}>
<Typography
sx={{
flexGrow: 1,
}}
>
Stats for Nerds
</Typography>
<Switch checked={showStatsForNerds} />
</MenuItem>
<MenuList disablePadding>
<MenuItem onClick={toggleShowStatsForNerds}>
<Typography
sx={{
flexGrow: 1,
}}
>
Stats for Nerds
</Typography>
<Switch checked={showStatsForNerds} />
</MenuItem>
</MenuList>
</Popover>
);
};