Addd ArtistTitlePage #160

This commit is contained in:
Prayag Prajapati committed 2023-09-19 15:18:39 +05:30
1 parent 2c85f67467
commit f549d6430f
17 files changed
+1050 -234

No files matched your search

+17
View File
@@ -36,6 +36,7 @@ const PlayButton = ({
buttonProps,
iconOnly,
audio = false,
size = "large",
}) => {
const navigate = useNavigate();
const [
@@ -94,6 +95,19 @@ const PlayButton = ({
sortOrder: SortOrder.Ascending,
sortBy: "IndexNumber",
});
} else if (itemType == BaseItemKind.MusicArtist) {
result = await getItemsApi(window.api).getItems({
artistIds: [itemId],
recursive: true,
includeItemTypes: [BaseItemKind.Audio],
userId: userId,
fields: [
ItemFields.MediaSources,
ItemFields.MediaStreams,
],
sortOrder: SortOrder.Ascending,
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
});
} else {
result = await getItemsApi(window.api).getItems({
ids: [itemId],
@@ -109,6 +123,7 @@ const PlayButton = ({
return result.data;
},
onSuccess: (item) => {
console.log(item);
if (audio) {
setAudioTracks(item.Items);
setAudioUrl(
@@ -156,6 +171,7 @@ const PlayButton = ({
className={className}
onClick={handleClick}
sx={sx}
size={size}
{...buttonProps}
>
<MdiPlayOutline {...iconProps} />
@@ -173,6 +189,7 @@ const PlayButton = ({
position: "relative",
overflow: "hidden",
}}
size={size}
>
<LinearProgress
variant="determinate"
+22 -4
View File
@@ -1,11 +1,29 @@
/** @format */
.album {
&-image-icon {
fill: url(#clr-gradient-default) !important;
&-image {
aspect-ratio: 1;
border-radius: 10px;
overflow: hidden;
width: 12em;
box-shadow: 0 0 10px rgb(0 0 0 /0.2);
position: relative;
height: 12em;
&-icon {
fill: url(#clr-gradient-default) !important;
&-container {
background: $clr-gradient-dark;
&-container {
background: $clr-gradient-dark;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
}
}
}
}
+169 -130
View File
@@ -29,6 +29,9 @@ import { MdiHeartOutline } from "../../icons/mdiHeartOutline";
import { MdiAlbum } from "../../icons/mdiAlbum";
import "./albumArtist.scss";
import { useAudioPlayback } from "../../../utils/store/audioPlayback";
import LikeButton from "../../buttons/likeButton";
import { SortOrder } from "@jellyfin/sdk/lib/generated-client";
export const ArtistAlbum = ({ user, album, boxProps }) => {
const albumTracks = useQuery({
@@ -37,9 +40,12 @@ export const ArtistAlbum = ({ user, album, boxProps }) => {
const result = await getItemsApi(window.api).getItems({
userId: user.Id,
parentId: album.Id,
sortOrder: SortOrder.Ascending,
sortBy: "IndexNumber",
});
return result.data;
},
networkMode: "always",
});
@@ -61,22 +67,43 @@ export const ArtistAlbum = ({ user, album, boxProps }) => {
const [imgLoaded, setImgLoaded] = useState(false);
const [
currentTrackItem,
setCurrentAudioTrack,
setAudioUrl,
setAudioDisplay,
setAudioItem,
setAudioTracks,
] = useAudioPlayback((state) => [
state.item,
state.setCurrentTrack,
state.setUrl,
state.setDisplay,
state.setItem,
state.setTracks,
]);
const playTrack = (index) => {
setAudioTracks(albumTracks.data.Items);
setCurrentAudioTrack(index);
setAudioUrl(
`${window.api.basePath}/Audio/${albumTracks.data.Items[index].Id}/universal?deviceId=${window.api.deviceInfo.id}&userId=${user.Id}&api_key=${window.api.accessToken}`,
);
setAudioItem(albumTracks.data.Items[index]);
setAudioDisplay(true);
};
return (
<Box sx={{ mb: 6 }} {...boxProps}>
<Stack direction="row" gap={3} mb={3}>
<div style={{ marginBottom: "3em" }} {...boxProps}>
<div
style={{
display: "flex",
flexDirection: "row",
gap: "1em",
marginBottom: "1em",
}}
>
{!!album.ImageTags?.Primary && (
<Box
className="album-image"
sx={{
aspectRatio: 1,
borderRadius: "10px",
overflow: "hidden",
width: "12em",
boxShadow: "0 0 10px rgb(0 0 0 /0.2)",
position: "relative",
height: "12em",
}}
>
<div className="album-image">
<img
src={`${window.api.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
style={{
@@ -90,37 +117,24 @@ export const ArtistAlbum = ({ user, album, boxProps }) => {
}}
onLoad={() => setImgLoaded(true)}
/>
<Box
className="album-image-icon-container"
sx={{
position: "absolute",
width: "100%",
height: "100%",
top: 0,
left: 0,
display: "flex",
alignItems: "center",
justifyContent: "center",
zIndex: 1,
}}
>
<div className="album-image-icon-container">
<MdiAlbum
className="album-image-icon"
sx={{ fontSize: "6em" }}
/>
</Box>
</Box>
</div>
</div>
)}
<Stack>
<Typography
variant="h5"
sx={{ opacity: `0.7`, mb: 1 }}
style={{ opacity: `0.6`, mb: 1 }}
>
{album.ProductionYear}
</Typography>
<MuiLink
component={Link}
to={`/item/${album.Id}`}
to={`/musicalbum/${album.Id}`}
variant="h3"
color="inherit"
underline="hover"
@@ -128,110 +142,135 @@ export const ArtistAlbum = ({ user, album, boxProps }) => {
{album.Name}
</MuiLink>
</Stack>
</Stack>
</div>
<TableContainer
component={Paper}
sx={{ mb: 2, borderRadius: "15px" }}
>
<Table>
<TableHead
sx={{
mb: 1,
{albumTracks.isSuccess && (
<Paper
className="item-detail-album-tracks"
style={{
marginBottom: "1.2em",
}}
>
<div
key={0}
className="item-detail-album-track"
style={{
padding: "0.75em 0 ",
background: "rgb(255 255 255 / 0.1)",
boxShadow: "0 0 10px rgb(0 0 0 / 0.5)",
}}
>
<TableRow>
<TableCell
sx={{
maxWidth: 120,
width: 20,
}}
<Typography
variant="h6"
fontWeight={400}
style={{
justifySelf: "end",
}}
>
#
</Typography>
<div></div>
<Typography
variant="h6"
style={{
justifySelf: "start",
}}
fontWeight={400}
onClick={() => {
console.log("Hvnrjn");
}}
>
Name
</Typography>
<MdiClockOutline />
</div>
{albumTracks.data.Items.map((track, index) => {
return (
<div
key={track.Id}
className={
currentTrackItem.Id == track.Id &&
currentTrackItem.ParentId ==
track.ParentId
? "item-detail-album-track playing"
: "item-detail-album-track"
}
onClick={() => playTrack(index)}
>
<Typography variant="h6">#</Typography>
</TableCell>
<TableCell sx={{ width: 20 }}></TableCell>
<TableCell>
<Typography variant="h6">
Name
<Typography
variant="subtitle1"
style={{
justifySelf: "end",
}}
>
{!!track.IndexNumber
? track.IndexNumber
: "-"}
</Typography>
</TableCell>
<TableCell>
<Typography variant="h6" align="right">
<MdiClockOutline />
</Typography>
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{albumTracks.isSuccess &&
albumTracks.data.Items.map(
(mitem, mindex) => {
return (
<TableRow
key={mindex}
sx={{
"&:last-child td, &:last-child th":
{
border: 0,
},
"&:hover": {
background:
"rgb(255 255 255 / 0.05)",
},
<LikeButton
itemId={track.Id}
isFavorite={
track.UserData?.IsFavorite
}
queryKey={[
"artist",
"album",
album.Id,
]}
userId={user.Id}
itemName={track.Name}
color={
currentTrackItem.Id ==
track.Id &&
currentTrackItem.ParentId ==
track.ParentId
? "hsl(337, 96%, 56%)"
: "white"
}
/>
<div
style={{
display: "flex",
flexDirection: "column",
width: "100%",
}}
>
<Typography
variant="subtitle1"
style={{
justifySelf: "start",
}}
fontWeight={500}
>
{track.Name}
</Typography>
{track.AlbumArtist ==
"Various Artists" && (
<Typography
variant="subtitle2"
style={{
opacity: 0.5,
}}
>
<TableCell
sx={{
maxWidth: 120,
width: 20,
}}
>
<Typography variant="body1">
{
mitem.IndexNumber
}
</Typography>
</TableCell>
<TableCell
sx={{
width: 20,
}}
align="center"
>
<IconButton
onClick={() =>
handleLikingTrack(
mitem,
)
}
>
{mitem.UserData
.IsFavorite ? (
<MdiHeart />
) : (
<MdiHeartOutline />
)}
</IconButton>
</TableCell>
<TableCell>
<Typography variant="body1">
{mitem.Name}
</Typography>
</TableCell>
<TableCell align="right">
<Typography variant="body1">
{getRuntimeMusic(
mitem.RunTimeTicks,
)}
</Typography>
</TableCell>
</TableRow>
);
},
)}
</TableBody>
</Table>
</TableContainer>
</Box>
{track.ArtistItems.map(
(artist) =>
artist.Name,
).join(", ")}
</Typography>
)}
</div>
<Typography variant="subtitle1">
{getRuntimeMusic(
track.RunTimeTicks,
)}
</Typography>
</div>
);
})}
</Paper>
)}
</div>
);
};
@@ -84,6 +84,7 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
]}
userId={user.data.Id}
imageBlurhash={
!!item.ImageBlurHashes?.Primary &&
item.ImageBlurHashes?.Primary[
Object.keys(
item.ImageBlurHashes.Primary,
+54 -30
View File
@@ -205,15 +205,19 @@ const Hero = ({
)}
</Typography>
{!!albumBy && (
<Typography
<TextLink
text={`By ${albumBy.Name}`}
variant="h6"
fontWeight={400}
style={{
opacity: 0.8,
location={`/artist/${albumBy.Id}`}
otherProps={{
fontWeight: 400,
style: {
opacity: 0.8,
},
}}
>
By {albumBy}
</Typography>
</TextLink>
)}
</div>
{!disableInfoStrip && (
@@ -550,22 +554,21 @@ const Hero = ({
{writers.map((writer, index) => (
<>
<TextLink
text={
index ==
writers.length
? writer.Name
: `${writer.Name}`
}
text={writer.Name}
variant={"subtitle1"}
location={`/person/${writer.Id}`}
/>
<span
style={{
whiteSpace: "pre",
}}
>
,{" "}
</span>
{index !=
writers.length - 1 && (
<span
style={{
whiteSpace:
"pre",
}}
>
,{" "}
</span>
)}
</>
))}
</div>
@@ -595,13 +598,17 @@ const Hero = ({
variant={"subtitle1"}
location={`/person/${director.Id}`}
/>
<span
style={{
whiteSpace: "pre",
}}
>
,{" "}
</span>
{index !=
directors.length - 1 && (
<span
style={{
whiteSpace:
"pre",
}}
>
,{" "}
</span>
)}
</>
))}
</div>
@@ -623,11 +630,28 @@ const Hero = ({
>
Artists
</Typography>
<Typography variant="subtitle1">
{artists
.map((artist) => artist.Name)
.join(", ")}
</Typography>
<div className="hero-text-container">
{artists.map((artist, index) => (
<>
<TextLink
text={artist.Name}
variant={"subtitle1"}
location={`/artist/${artist.Id}`}
/>
{index !=
artists.length - 1 && (
<span
style={{
whiteSpace:
"pre",
}}
>
,{" "}
</span>
)}
</>
))}
</div>
</div>
)}
{studios.length > 0 && (
+124
View File
@@ -0,0 +1,124 @@
/** @format */
import Typography from "@mui/material/Typography";
import "./musicTrack.module.scss";
import { getRuntimeMusic } from "../../utils/date/time";
import LikeButton from "../buttons/likeButton";
import TextLink from "../textLink";
import PlayButton from "../buttons/playButton";
import { useAudioPlayback } from "../../utils/store/audioPlayback";
/**
* @typedef {Object} Props
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
* @property {Array} queryKey
* @property {string} userId
*/
/**
* @description Music Track element displayed in ArtistTitlePage and Songs library
* @param {Props}
* @returns {React.Component}
*/
const MusicTrack = ({ item, queryKey, userId }) => {
const [currentTrackItem] = useAudioPlayback((state) => [state.item]);
return (
<div className="music-track">
<div className="music-track-image">
<img
src={window.api.getItemImageUrl(
Object.keys(item.ImageTags).length == 0
? item.AlbumId
: item.Id,
"Primary",
{
quality: 85,
fillHeight: 462,
fillWidth: 462,
},
)}
style={{
width: "100%",
height: "100%",
objectFit: "cover",
opacity: 0,
}}
onLoad={(e) => (e.target.style.opacity = 1)}
/>
<div className="music-track-image-overlay">
<PlayButton
itemId={item.Id}
userId={userId}
itemType={item.Type}
size="small"
iconOnly
audio
/>
</div>
</div>
<div className="music-track-info">
<Typography
variant="subtitle1"
style={{
color:
item.Id == currentTrackItem.Id
? "hsl(337, 96%, 56%)"
: "white",
}}
>
{item.Name}
</Typography>
<div
style={{
display: "flex",
opacity: 0.8,
}}
>
{item.ArtistItems.map((artist, index) => (
<>
<TextLink
text={artist.Name}
variant={"subtitle2"}
location={`/artist/${artist.Id}`}
otherProps={{
fontWeight: 400,
}}
/>
{index != item.ArtistItems.length - 1 && (
<span
style={{
whiteSpace: "pre",
}}
>
,{" "}
</span>
)}
</>
))}
</div>
{/* <Typography
variant="subtitle2"
style={{
opacity: 0.5,
}}
>
{item.Name}
</Typography> */}
</div>
<Typography variant="subtitl1">
{getRuntimeMusic(item.RunTimeTicks)}
</Typography>
<LikeButton
itemId={item.Id}
isFavorite={item.UserData?.IsFavorite}
queryKey={queryKey}
userId={userId}
itemName={item.Name}
/>
</div>
);
};
export default MusicTrack;
@@ -0,0 +1,40 @@
/** @format */
.music-track {
display: grid;
grid-template-columns: 4.5em 80% 1fr 1fr;
gap: 0.5em;
align-items: center;
justify-items: center;
&-image {
margin: 0.4em;
border-radius: $border-radius-default;
overflow: hidden;
aspect-ratio: 1;
position: relative;
&-overlay {
position: absolute;
top: 0;
left: 0;
backdrop-filter: blur(10px);
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity $transition-time-fast;
}
box-shadow: 0 0 10px rgb(0 0 0 / 0.2);
transition: opacity $transition-time-fast;
}
&-info {
justify-self: start;
}
&:hover {
.music-track-image-overlay {
opacity: 1;
}
}
}
@@ -3,7 +3,6 @@
.audio-player {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: $clr-background-dark-opacity-0_8;
z-index: 10;
+67 -9
View File
@@ -6,6 +6,7 @@ import { motion } from "framer-motion";
import Fab from "@mui/material/Fab";
import IconButton from "@mui/material/IconButton";
import Typography from "@mui/material/Typography";
import CircularProgress from "@mui/material/CircularProgress";
import WaveSurfer from "wavesurfer.js";
@@ -21,10 +22,11 @@ import { MdiSkipNext } from "../../icons/mdiSkipNext";
import { MdiSkipPrevious } from "../../icons/mdiSkipPrevious";
import { useQuery } from "@tanstack/react-query";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { Icon } from "@mui/material";
import { MdiClose } from "../../icons/mdiClose";
import { MdiMusic } from "../../icons/mdiMusic";
import { theme } from "../../../theme";
const AudioPlayer = () => {
const user = useQuery({
queryKey: ["user"],
@@ -37,7 +39,10 @@ const AudioPlayer = () => {
const waveSurferRef = useRef(null);
const waveSurferContainerRef = useRef(null);
const [playing, setPlaying] = useState(false);
const [playerReady, setPlayerReady] = useState(false);
const [playing, setPlaying] = useState(true);
const [loading, setLoading] = useState(true);
const [showWaveform, setShowWaveform] = useState(false);
@@ -73,17 +78,22 @@ const AudioPlayer = () => {
if (display) {
const waveSurfer = WaveSurfer.create({
container: waveSurferContainerRef.current,
autoplay: true,
barHeight: 0.8,
dragToSeek: true,
height: 35,
cursorColor: "#fb2376",
progressColor: "#fb2376",
waveColor: "#ffffff2f",
normalize: true,
});
waveSurfer.load(url);
waveSurfer.on("load", () => {
setLoading(true);
});
waveSurfer.on("ready", () => {
waveSurferRef.current = waveSurfer;
waveSurfer.play();
setLoading(false);
});
waveSurfer.on("timeupdate", (e) => {
setCurrentTime(e);
@@ -114,18 +124,27 @@ const AudioPlayer = () => {
setShowWaveform(false);
}
});
waveSurfer.on("destroy", () => {
waveSurfer.unAll();
setLoading(true);
});
return () => {
waveSurfer.destroy();
};
}
}, [url]);
}, [url, display, currentTrack]);
useEffect(() => {
if (playerReady) waveSurferRef.current.play();
}, [playerReady]);
const handlePlayPause = () => {
waveSurferRef.current.playPause();
};
const handleNext = () => {
setPlaying(false);
setCurrentTrack(currentTrack + 1);
setAudioUrl(
`${window.api.basePath}/Audio/${
@@ -139,6 +158,7 @@ const AudioPlayer = () => {
};
const handlePrevious = () => {
setPlaying(false);
setCurrentTrack(currentTrack - 1);
setAudioUrl(
`${window.api.basePath}/Audio/${
@@ -159,6 +179,14 @@ const AudioPlayer = () => {
transform: "translateY(100%)",
}}
animate={{ transform: "translateY(0)" }}
exit={{
transform: "translateY(100%)",
}}
style={{
width: `calc(100vw - ${theme.spacing(
13,
)} - 10px)`,
}}
className="audio-player"
>
<motion.div
@@ -178,7 +206,10 @@ const AudioPlayer = () => {
<img
className="audio-player-image"
src={window.api.getItemImageUrl(
item.Id,
Object.keys(item.ImageTags)
.length == 0
? item.AlbumId
: item.Id,
"Primary",
{
quality: 85,
@@ -197,7 +228,9 @@ const AudioPlayer = () => {
}}
fontWeight={500}
>
{item.IndexNumber}. {item.Name}
{!!item.IndexNumber
? `${item.IndexNumber}. ${item.Name}`
: item.Name}
</Typography>
<Typography
variant="subtitle2"
@@ -222,9 +255,34 @@ const AudioPlayer = () => {
>
<MdiSkipPrevious />
</IconButton>
<Fab size="small" onClick={handlePlayPause}>
{playing ? <MdiPause /> : <MdiPlay />}
</Fab>
<div
style={{
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
position: "relative",
}}
>
<CircularProgress
size={48}
style={{
position: "absolute",
zIndex: 1,
opacity: loading ? 1 : 0,
transition: "opacity 500ms",
}}
/>
<Fab
size="small"
onClick={handlePlayPause}
>
{playing ? (
<MdiPause />
) : (
<MdiPlay />
)}
</Fab>
</div>
<IconButton
onClick={handleNext}
disabled={
+2 -1
View File
@@ -5,7 +5,7 @@ import { useNavigate } from "react-router-dom";
import "./textLink.module.scss";
const TextLink = ({ text, location, variant }) => {
const TextLink = ({ text, location, variant, otherProps }) => {
const navigate = useNavigate();
return (
@@ -13,6 +13,7 @@ const TextLink = ({ text, location, variant }) => {
variant={variant}
className="link"
onClick={() => navigate(location)}
{...otherProps}
>
{text}
</Typography>