chore(web): start adding new queue implementaion
This commit is contained in:
9 files changed
+494
-213
No files matched your search
@@ -5,6 +5,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Jellyplayer</title>
|
||||
<script src="http://localhost:8097"></script>
|
||||
<style>
|
||||
.app-loading {
|
||||
position: fixed;
|
||||
|
||||
+2
-2
@@ -440,7 +440,7 @@ function AppReady() {
|
||||
<CssBaseline />
|
||||
{/* <SideMenu /> */}
|
||||
<AppBar />
|
||||
<AudioPlayer key={audioPlayerVisible} />
|
||||
{audioPlayerVisible && <AudioPlayer />}
|
||||
<ErrorBoundary FallbackComponent={ErrorNotice} key={location.key}>
|
||||
<Routes location={location}>
|
||||
{/* <Route
|
||||
@@ -510,7 +510,7 @@ function AppReady() {
|
||||
</Routes>
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
<ReactQueryDevtools buttonPosition="bottom-left" />
|
||||
<ReactQueryDevtools buttonPosition="top-left" />
|
||||
</ThemeProvider>
|
||||
</SnackbarProvider>
|
||||
);
|
||||
|
||||
@@ -24,6 +24,9 @@ import { useSnackbar } from "notistack";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { useAudioPlayback } from "../../utils/store/audioPlayback";
|
||||
|
||||
import useQueue, { setQueue } from "../../utils/store/queue";
|
||||
|
||||
import {
|
||||
setItem,
|
||||
usePlaybackDataLoadStore,
|
||||
@@ -195,13 +198,15 @@ const PlayButton = ({
|
||||
console.log(result.Items[0].MediaSources);
|
||||
if (trackIndex) {
|
||||
setPlaylistItemId(playlistItemId);
|
||||
setCurrentTrack(trackIndex);
|
||||
setAudioTracks(result.Items);
|
||||
// setCurrentTrack(trackIndex);
|
||||
// setAudioTracks(result.Items);
|
||||
setAudioUrl(
|
||||
`${api.basePath}/Audio/${result.Items[trackIndex].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${userId}&api_key=${api.accessToken}`,
|
||||
);
|
||||
setAudioItem(result.Items[trackIndex]);
|
||||
setAudioDisplay(true);
|
||||
|
||||
setQueue(result.Items, trackIndex);
|
||||
} else if (audio) {
|
||||
setAudioItem(result.Items[0]);
|
||||
setAudioTracks(result.Items);
|
||||
@@ -209,6 +214,7 @@ const PlayButton = ({
|
||||
`${api.basePath}/Audio/${result.Items[0].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${userId}&api_key=${api.accessToken}`,
|
||||
);
|
||||
setAudioDisplay(true);
|
||||
setQueue(result.Items, 0);
|
||||
} else {
|
||||
setUserId(userId);
|
||||
setItemId(result.Items[0].Id);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
$image-size: 4em;
|
||||
|
||||
.audio-player {
|
||||
position: fixed;
|
||||
@@ -6,16 +7,16 @@
|
||||
background: rgb(0 0 0 / 0.6);
|
||||
z-index: 10;
|
||||
display: grid;
|
||||
padding: 1em;
|
||||
padding: 0.5em 1em;
|
||||
// margin: 1em;
|
||||
backdrop-filter: blur(10px);
|
||||
// border-radius: 10px;
|
||||
overflow: hidden;
|
||||
// overflow: hidden;
|
||||
gap: 1em;
|
||||
box-shadow: 0 0 20px rgb(0 0 0 / 0.25);
|
||||
|
||||
border-top: 1.2px solid rgb(255 255 255 / 0.2);
|
||||
grid-template-columns: 25% 1fr 25%;
|
||||
|
||||
|
||||
#waveform {
|
||||
width: 100%;
|
||||
transform: scaleY(0);
|
||||
@@ -28,13 +29,14 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 1em;
|
||||
gap: 0.5em;
|
||||
padding: 0.5em 0;
|
||||
flex-flow: column;
|
||||
}
|
||||
&-info {
|
||||
display: grid;
|
||||
gap: 0.5em;
|
||||
grid-template-columns: minmax(0, 4.5em) minmax(0, 1fr);
|
||||
grid-template-columns: minmax(0, $image-size) minmax(0, 1fr);
|
||||
width: fit-content;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
@@ -42,21 +44,23 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
&-image {
|
||||
width: 4.5em;
|
||||
width: $image-size;
|
||||
aspect-ratio: 1;
|
||||
object-fit: cover;
|
||||
z-index: 1;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 1;
|
||||
|
||||
|
||||
position: relative;
|
||||
&-container {
|
||||
border-radius: $border-radius-default;
|
||||
border-radius: 5px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: $clr-gradient-dark;
|
||||
height: fit-content;
|
||||
aspect-ratio: 1;
|
||||
background: rgb(255 255 255 / 0.1);
|
||||
|
||||
border: 1.2px solid rgb(255 255 255 / 0.1);
|
||||
}
|
||||
&-icon {
|
||||
position: absolute;
|
||||
@@ -64,11 +68,49 @@
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 2em !important;
|
||||
fill: url(#clr-gradient-default) !important;
|
||||
z-index: 0;
|
||||
}
|
||||
}
|
||||
&-track {
|
||||
grid-template-columns: 4.5em 60% 0.5fr 0.5fr !important;
|
||||
grid-template-columns: $image-size 60% 0.5fr 0.5fr !important;
|
||||
}
|
||||
&-playlist{
|
||||
background: $clr-background-dark !important;
|
||||
border: 1.2px solid rgb(255 255 255 / 0.2);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
// Magic scrollbar
|
||||
&::-webkit-scrollbar {
|
||||
&-thumb {
|
||||
height: 150px;
|
||||
max-height: 33%;
|
||||
}
|
||||
&-track {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
background: transparent !important;
|
||||
}
|
||||
}
|
||||
|
||||
&-track{
|
||||
display: grid;
|
||||
gap: 1em;
|
||||
grid-template-columns: 4em 1fr 4em;
|
||||
cursor: pointer;
|
||||
&.active{
|
||||
color: $clr-accent-default;
|
||||
}
|
||||
&-image{
|
||||
background: rgb(255 255 255 / 0.1);
|
||||
border: 1.2px solid rgb(255 255 255 / 0.1);
|
||||
overflow: hidden;
|
||||
border-radius:5px;
|
||||
width: 100%;
|
||||
aspect-ratio: 1;
|
||||
height: 4em;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,16 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import React, {
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
import { motion } from "framer-motion";
|
||||
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Fab from "@mui/material/Fab";
|
||||
import Grow from "@mui/material/Grow";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Paper from "@mui/material/Paper";
|
||||
import Popper from "@mui/material/Popper";
|
||||
@@ -13,6 +20,7 @@ import Typography from "@mui/material/Typography";
|
||||
import WaveSurfer from "wavesurfer.js";
|
||||
|
||||
import { useAudioPlayback } from "../../../utils/store/audioPlayback";
|
||||
import useQueue, { setTrackIndex } from "../../../utils/store/queue";
|
||||
|
||||
import { AnimatePresence } from "framer-motion";
|
||||
import "./audioPlayer.module.scss";
|
||||
@@ -32,11 +40,10 @@ const AudioPlayer = () => {
|
||||
url,
|
||||
display,
|
||||
item,
|
||||
tracks,
|
||||
currentTrack,
|
||||
// tracks,
|
||||
// currentTrack,
|
||||
setCurrentTrack,
|
||||
setAudioUrl,
|
||||
setAudioDisplay,
|
||||
setAudioItem,
|
||||
setAudioTracks,
|
||||
resetPlayer,
|
||||
@@ -45,17 +52,21 @@ const AudioPlayer = () => {
|
||||
state.url,
|
||||
state.display,
|
||||
state.item,
|
||||
state.tracks,
|
||||
state.currentTrack,
|
||||
// state.tracks,
|
||||
// state.currentTrack,
|
||||
state.setCurrentTrack,
|
||||
state.setUrl,
|
||||
state.setDisplay,
|
||||
state.setItem,
|
||||
state.setTracks,
|
||||
state.reset,
|
||||
state.playlistItemId,
|
||||
]);
|
||||
|
||||
const [tracks, currentTrack] = useQueue((state) => [
|
||||
state.tracks,
|
||||
state.currentItemIndex,
|
||||
]);
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
queryFn: async () => {
|
||||
@@ -90,7 +101,7 @@ const AudioPlayer = () => {
|
||||
const waveSurfer = WaveSurfer.create({
|
||||
container: waveSurferContainerRef.current,
|
||||
dragToSeek: true,
|
||||
height: 35,
|
||||
height: 25,
|
||||
cursorColor: "#fb2376",
|
||||
progressColor: "#fb2376",
|
||||
waveColor: "#ffffff2f",
|
||||
@@ -110,8 +121,8 @@ const AudioPlayer = () => {
|
||||
setPlayerReady(true);
|
||||
setLoading(false);
|
||||
});
|
||||
waveSurfer.on("timeupdate", async (time) => {
|
||||
setCurrentTime(time);
|
||||
waveSurfer.on("timeupdate", async (atime) => {
|
||||
setCurrentTime(atime);
|
||||
});
|
||||
waveSurfer.on("redraw", () => {
|
||||
setShowWaveform(true);
|
||||
@@ -146,9 +157,9 @@ const AudioPlayer = () => {
|
||||
waveSurfer.destroy();
|
||||
};
|
||||
}
|
||||
}, [url, display, currentTrack]);
|
||||
}, [url, currentTrack]);
|
||||
|
||||
useEffect(() => {
|
||||
useLayoutEffect(() => {
|
||||
if (playerReady) {
|
||||
waveSurferRef.current.setVolume(volume);
|
||||
waveSurferRef.current.setMuted(isMuted);
|
||||
@@ -161,7 +172,7 @@ const AudioPlayer = () => {
|
||||
|
||||
const handleNext = () => {
|
||||
setPlaying(false);
|
||||
setCurrentTrack(currentTrack + 1);
|
||||
// setCurrentTrack(currentTrack + 1);
|
||||
setAudioUrl(
|
||||
`${api.basePath}/Audio/${
|
||||
tracks[currentTrack + 1].Id
|
||||
@@ -169,13 +180,19 @@ const AudioPlayer = () => {
|
||||
user.data.Id
|
||||
}&api_key=${api.accessToken}`,
|
||||
);
|
||||
setAudioItem(tracks[currentTrack + 1]);
|
||||
|
||||
setTrackIndex(currentTrack + 1);
|
||||
|
||||
// console.info(tracks[currentTrack + 1]);
|
||||
|
||||
console.log(currentTrack);
|
||||
// setAudioItem(tracks[currentTrack + 1]);
|
||||
setShowWaveform(false);
|
||||
};
|
||||
|
||||
const handlePrevious = () => {
|
||||
setPlaying(false);
|
||||
setCurrentTrack(currentTrack - 1);
|
||||
// setCurrentTrack(currentTrack - 1);
|
||||
setAudioUrl(
|
||||
`${api.basePath}/Audio/${
|
||||
tracks[currentTrack - 1].Id
|
||||
@@ -183,33 +200,322 @@ const AudioPlayer = () => {
|
||||
user.data.Id
|
||||
}&api_key=${api.accessToken}`,
|
||||
);
|
||||
setAudioItem(tracks[currentTrack - 1]);
|
||||
setTrackIndex(currentTrack - 1);
|
||||
// setAudioItem(tracks[currentTrack - 1]);
|
||||
setShowWaveform(false);
|
||||
};
|
||||
|
||||
const info = useMemo(
|
||||
() => (
|
||||
<div
|
||||
// initial={{
|
||||
// filter: "opacity(0)",
|
||||
// }}
|
||||
// animate={{
|
||||
// filter: "opacity(1)",
|
||||
// }}
|
||||
// exit={{
|
||||
// filter: "opacity(0)",
|
||||
// }}
|
||||
className="audio-player-info"
|
||||
>
|
||||
<div className="audio-player-image-container">
|
||||
<img
|
||||
alt={tracks[currentTrack].Name}
|
||||
className="audio-player-image"
|
||||
src={api.getItemImageUrl(
|
||||
Object.keys(tracks[currentTrack].ImageTags).length === 0
|
||||
? item.AlbumId
|
||||
: item.Id,
|
||||
"Primary",
|
||||
{
|
||||
quality: 85,
|
||||
fillHeight: 462,
|
||||
fillWidth: 462,
|
||||
},
|
||||
)}
|
||||
/>
|
||||
<span className="material-symbols-rounded audio-player-image-icon">
|
||||
music_note
|
||||
</span>
|
||||
</div>
|
||||
<div className="audio-player-info-text">
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
fontWeight={500}
|
||||
>
|
||||
{tracks[currentTrack].IndexNumber
|
||||
? `${tracks[currentTrack].IndexNumber}. ${tracks[currentTrack].Name}`
|
||||
: tracks[currentTrack].Name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
style={{
|
||||
opacity: 0.5,
|
||||
}}
|
||||
noWrap
|
||||
fontWeight={400}
|
||||
>
|
||||
by {tracks[currentTrack].Artists.map((artist) => artist).join(",")}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
[currentTrack],
|
||||
);
|
||||
|
||||
const controls = useMemo(
|
||||
() => (
|
||||
<div style={{ display: "flex", gap: "1em" }}>
|
||||
<IconButton onClick={handlePrevious} disabled={currentTrack === 0}>
|
||||
<div className="material-symbols-rounded">skip_previous</div>
|
||||
</IconButton>
|
||||
<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}>
|
||||
<div
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
fontSize: "2em",
|
||||
}}
|
||||
>
|
||||
{playing ? "pause" : "play_arrow"}
|
||||
</div>
|
||||
</Fab>
|
||||
</div>
|
||||
<IconButton
|
||||
onClick={handleNext}
|
||||
disabled={tracks.length - 1 === currentTrack}
|
||||
>
|
||||
<div className="material-symbols-rounded">skip_next</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
),
|
||||
[currentTrack, loading, playing, tracks.length],
|
||||
);
|
||||
|
||||
const buttons = useMemo(
|
||||
() => (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
}}
|
||||
>
|
||||
<Popper
|
||||
open={Boolean(queueButton)}
|
||||
anchorEl={queueButton}
|
||||
placement="top"
|
||||
style={{
|
||||
zIndex: 100,
|
||||
}}
|
||||
disablePortal
|
||||
modifiers={[
|
||||
{
|
||||
name: "flip",
|
||||
enabled: true,
|
||||
options: {
|
||||
altBoundary: true,
|
||||
rootBoundary: "document",
|
||||
padding: 8,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "preventOverflow",
|
||||
enabled: true,
|
||||
options: {
|
||||
altAxis: true,
|
||||
altBoundary: true,
|
||||
tether: true,
|
||||
rootBoundary: "document",
|
||||
padding: 8,
|
||||
},
|
||||
},
|
||||
]}
|
||||
transition
|
||||
>
|
||||
{({ TransitionProps }) => (
|
||||
<Grow
|
||||
{...TransitionProps}
|
||||
style={{
|
||||
transformOrigin: "50% 100% 0",
|
||||
}}
|
||||
timeout={250}
|
||||
>
|
||||
<Paper
|
||||
className="audio-player-playlist"
|
||||
style={{
|
||||
padding: "1em",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
width: "34em",
|
||||
maxHeight: "24em",
|
||||
overflowY: "auto",
|
||||
borderRadius: "20px",
|
||||
marginBottom: "2.4em",
|
||||
}}
|
||||
>
|
||||
{tracks.map((track, index) => {
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
track.Id === tracks[currentTrack].Id
|
||||
? "audio-player-playlist-track active"
|
||||
: "audio-player-playlist-track"
|
||||
}
|
||||
onClick={() => setTrackIndex(index)}
|
||||
>
|
||||
<div className="audio-player-playlist-track-image">
|
||||
{Object.keys(track.ImageTags).includes("Primary") ? (
|
||||
<img
|
||||
alt={track.Name}
|
||||
src={api.getItemImageUrl(track.Id, "Primary", {
|
||||
quality: 80,
|
||||
tag: track.ImageTags["Primary"],
|
||||
fillWidth: 92,
|
||||
fillHeight: 92,
|
||||
})}
|
||||
style={{
|
||||
width: "inherit",
|
||||
height: "inherit",
|
||||
objectFit: "cover",
|
||||
}}
|
||||
/>
|
||||
) : track.AlbumPrimaryImageTag ? (
|
||||
<img
|
||||
alt={track.Name}
|
||||
src={api.getItemImageUrl(track.AlbumId, "Primary", {
|
||||
quality: 80,
|
||||
tag: track.AlbumPrimaryImageTag,
|
||||
fillWidth: 102,
|
||||
fillHeight: 102,
|
||||
})}
|
||||
style={{
|
||||
width: "inherit",
|
||||
height: "inherit",
|
||||
objectFit: "cover",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<Typography variant="subtitle1">
|
||||
{track.Name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
style={{
|
||||
opacity: 0.5,
|
||||
}}
|
||||
>
|
||||
{track.Artists.join(", ")}
|
||||
</Typography>
|
||||
</div>
|
||||
<Typography variant="subtitle2">
|
||||
{getRuntimeMusic(track.RunTimeTicks)}
|
||||
</Typography>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</Paper>
|
||||
</Grow>
|
||||
)}
|
||||
</Popper>
|
||||
<IconButton onClick={handleOpenQueue}>
|
||||
<div className="material-symbols-rounded">queue_music</div>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
setIsMuted(!isMuted);
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">
|
||||
{isMuted ? "volume_mute" : "volume_up"}
|
||||
</div>
|
||||
</IconButton>
|
||||
<Slider
|
||||
value={isMuted ? 0 : volume * 100}
|
||||
step={1}
|
||||
max={100}
|
||||
onChange={(e, newVal) => setVolume(newVal / 100)}
|
||||
valueLabelDisplay="auto"
|
||||
valueLabelFormat={(value) => Math.floor(value)}
|
||||
size="small"
|
||||
sx={{
|
||||
mr: 1,
|
||||
ml: 1,
|
||||
width: "10em",
|
||||
"& .MuiSlider-valueLabel": {
|
||||
lineHeight: 1.2,
|
||||
fontSize: 24,
|
||||
background: "rgb(0 0 0 / 0.5)",
|
||||
backdropFilter: "blur(5px)",
|
||||
padding: 1,
|
||||
borderRadius: "10px",
|
||||
border: "1px solid rgb(255 255 255 / 0.15)",
|
||||
boxShadow: "0 0 10px rgb(0 0 0 / 0.4) ",
|
||||
transform: "translatey(-120%) scale(0)",
|
||||
"&:before": {
|
||||
display: "none",
|
||||
},
|
||||
"&.MuiSlider-valueLabelOpen": {
|
||||
transform: "translateY(-120%) scale(1)",
|
||||
},
|
||||
"& > *": {
|
||||
transform: "rotate(0deg)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<IconButton onClick={resetPlayer}>
|
||||
<div className="material-symbols-rounded">close</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
),
|
||||
[queueButton, volume, isMuted, currentTrack],
|
||||
);
|
||||
|
||||
return (
|
||||
<AnimatePresence mode="sync">
|
||||
{display && (
|
||||
<motion.div
|
||||
key={display}
|
||||
initial={{
|
||||
transform: "translateY(100%)",
|
||||
}}
|
||||
animate={{ transform: "translateY(0)" }}
|
||||
exit={{
|
||||
transform: "translateY(100%)",
|
||||
}}
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.2,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="audio-player"
|
||||
>
|
||||
<motion.div
|
||||
key={item.Id}
|
||||
<motion.div
|
||||
initial={{
|
||||
transform: "translateY(100%)",
|
||||
}}
|
||||
animate={{ transform: "translateY(0)" }}
|
||||
exit={{
|
||||
transform: "translateY(100%)",
|
||||
}}
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.2,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="audio-player"
|
||||
>
|
||||
{/* <motion.div
|
||||
initial={{
|
||||
filter: "opacity(0)",
|
||||
}}
|
||||
@@ -223,9 +529,10 @@ const AudioPlayer = () => {
|
||||
>
|
||||
<div className="audio-player-image-container">
|
||||
<img
|
||||
alt={tracks[currentTrack].Name}
|
||||
className="audio-player-image"
|
||||
src={api.getItemImageUrl(
|
||||
Object.keys(item.ImageTags).length === 0
|
||||
Object.keys(tracks[currentTrack].ImageTags).length === 0
|
||||
? item.AlbumId
|
||||
: item.Id,
|
||||
"Primary",
|
||||
@@ -248,9 +555,9 @@ const AudioPlayer = () => {
|
||||
}}
|
||||
fontWeight={500}
|
||||
>
|
||||
{item.IndexNumber
|
||||
? `${item.IndexNumber}. ${item.Name}`
|
||||
: item.Name}
|
||||
{tracks[currentTrack].IndexNumber
|
||||
? `${tracks[currentTrack].IndexNumber}. ${tracks[currentTrack].Name}`
|
||||
: tracks[currentTrack].Name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
@@ -260,175 +567,51 @@ const AudioPlayer = () => {
|
||||
noWrap
|
||||
fontWeight={400}
|
||||
>
|
||||
by {item.Artists.map((artist) => artist).join(",")}
|
||||
by{" "}
|
||||
{tracks[currentTrack].Artists.map((artist) => artist).join(",")}
|
||||
</Typography>
|
||||
</div>
|
||||
</motion.div>
|
||||
<div className="audio-player-controls">
|
||||
<div style={{ display: "flex", gap: "1em" }}>
|
||||
<IconButton
|
||||
onClick={handlePrevious}
|
||||
disabled={currentTrack === 0}
|
||||
>
|
||||
<div className="material-symbols-rounded">skip_previous</div>
|
||||
</IconButton>
|
||||
<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}>
|
||||
<div
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
fontSize: "2em",
|
||||
}}
|
||||
>
|
||||
{playing ? "pause" : "play_arrow"}
|
||||
</div>
|
||||
</Fab>
|
||||
</div>
|
||||
<IconButton
|
||||
onClick={handleNext}
|
||||
disabled={tracks.length - 1 === currentTrack}
|
||||
>
|
||||
<div className="material-symbols-rounded">skip_next</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
gap: "1em",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
style={{
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
{getRuntimeMusic(secToTicks(currentTime))}
|
||||
</Typography>
|
||||
<div
|
||||
id="waveform"
|
||||
ref={waveSurferContainerRef}
|
||||
data-show={Boolean(showWaveform)}
|
||||
/>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
style={{
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
{getRuntimeMusic(item.RunTimeTicks)}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div> */}
|
||||
{info}
|
||||
|
||||
<div className="audio-player-controls">
|
||||
{controls}
|
||||
<div
|
||||
style={{
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
gap: "1em",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Popper
|
||||
open={Boolean(queueButton)}
|
||||
anchorEl={queueButton}
|
||||
placement="top"
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
style={{
|
||||
zIndex: 100,
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
<Paper
|
||||
style={{
|
||||
padding: "1em",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
width: "36em",
|
||||
}}
|
||||
>
|
||||
{tracks.map((track, index) => {
|
||||
return (
|
||||
<MusicTrack
|
||||
item={track}
|
||||
key={track.Id}
|
||||
queryKey={[]}
|
||||
userId={user.data.Id}
|
||||
className="audio-player-track"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</Paper>
|
||||
</Popper>
|
||||
<IconButton onClick={handleOpenQueue} disabled>
|
||||
<div className="material-symbols-rounded">queue_music</div>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
setIsMuted(!isMuted);
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">
|
||||
{isMuted ? "volume_mute" : "volume_up"}
|
||||
</div>
|
||||
</IconButton>
|
||||
<Slider
|
||||
value={isMuted ? 0 : volume * 100}
|
||||
step={1}
|
||||
max={100}
|
||||
onChange={(e, newVal) => setVolume(newVal / 100)}
|
||||
valueLabelDisplay="auto"
|
||||
valueLabelFormat={(value) => Math.floor(value)}
|
||||
size="small"
|
||||
sx={{
|
||||
mr: 1,
|
||||
ml: 1,
|
||||
width: "10em",
|
||||
"& .MuiSlider-valueLabel": {
|
||||
lineHeight: 1.2,
|
||||
fontSize: 24,
|
||||
background: "rgb(0 0 0 / 0.5)",
|
||||
backdropFilter: "blur(5px)",
|
||||
padding: 1,
|
||||
borderRadius: "10px",
|
||||
border: "1px solid rgb(255 255 255 / 0.15)",
|
||||
boxShadow: "0 0 10px rgb(0 0 0 / 0.4) ",
|
||||
transform: "translatey(-120%) scale(0)",
|
||||
"&:before": {
|
||||
display: "none",
|
||||
},
|
||||
"&.MuiSlider-valueLabelOpen": {
|
||||
transform: "translateY(-120%) scale(1)",
|
||||
},
|
||||
"& > *": {
|
||||
transform: "rotate(0deg)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
{getRuntimeMusic(secToTicks(currentTime))}
|
||||
</Typography>
|
||||
<div
|
||||
id="waveform"
|
||||
ref={waveSurferContainerRef}
|
||||
data-show={Boolean(showWaveform)}
|
||||
/>
|
||||
<IconButton onClick={resetPlayer}>
|
||||
<div className="material-symbols-rounded">close</div>
|
||||
</IconButton>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
style={{
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
{getRuntimeMusic(tracks[currentTrack].RunTimeTicks)}
|
||||
</Typography>
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
</div>
|
||||
{buttons}
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -213,6 +213,12 @@ const EpisodeTitlePage = () => {
|
||||
if (audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes("truehd")) {
|
||||
return "TrueHD";
|
||||
}
|
||||
if (
|
||||
audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes("ddp") ||
|
||||
audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes("digital+")
|
||||
) {
|
||||
return "Dolby Digital+";
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
||||
|
||||
@@ -239,6 +239,12 @@ const ItemDetail = () => {
|
||||
if (audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes("truehd")) {
|
||||
return "TrueHD";
|
||||
}
|
||||
if (
|
||||
audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes("ddp") ||
|
||||
audioTracks[0]?.DisplayTitle.toLocaleLowerCase().includes("digital+")
|
||||
) {
|
||||
return "Dolby Digital+";
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { create } from "zustand";
|
||||
import { getRuntimeMusic, secToTicks } from "../date/time";
|
||||
|
||||
const usePlayer = create(() => ({
|
||||
timeString: 0,
|
||||
}));
|
||||
|
||||
export const setTime = (sec: number) => {
|
||||
const a = getRuntimeMusic(secToTicks(sec));
|
||||
console.log(a);
|
||||
usePlayer.setState(() => ({ timeString: a }));
|
||||
};
|
||||
|
||||
export default usePlayer;
|
||||
@@ -0,0 +1,23 @@
|
||||
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { create } from "zustand";
|
||||
|
||||
interface QueueStore {
|
||||
tracks: BaseItemDto[];
|
||||
currentItemIndex: number;
|
||||
}
|
||||
|
||||
const useQueue = create<QueueStore>(() => ({
|
||||
tracks: [],
|
||||
currentItemIndex: 0,
|
||||
}));
|
||||
|
||||
export const setQueue = (tracks: BaseItemDto[], currentItemIndex: number) => {
|
||||
useQueue.setState(() => ({ tracks, currentItemIndex }));
|
||||
};
|
||||
|
||||
export const setTrackIndex = (index: number) => {
|
||||
console.info(`Setting index ${index}`);
|
||||
useQueue.setState((state) => ({ ...state, currentItemIndex: index }));
|
||||
};
|
||||
|
||||
export default useQueue;
|
||||
Reference in new issue
Block a user