From 94decd674c65123960af199f4aa23e83b0d2d295 Mon Sep 17 00:00:00 2001 From: 1xDed Date: Tue, 1 Dec 2026 18:06:36 +0300 Subject: [PATCH] feat(player): restyle the floating media bar as liquid glass - cover-tinted translucent surface with a specular rim, grain and glow - centered transport dock and right-hand control capsule - adaptive accent colour, glass cover treatment and shared artwork between the bar and the full player --- .../playback/audioPlayer/audioPlayer.scss | 912 ++++++++++-------- src/components/playback/audioPlayer/index.tsx | 101 +- src/routes/_api/player/audio.tsx | 48 +- src/styles/global.scss | 23 + src/utils/methods/audioPlayerReturn.ts | 19 + src/utils/methods/coverColor.ts | 13 +- src/utils/methods/getImageUrlsApi.ts | 30 +- 7 files changed, 695 insertions(+), 451 deletions(-) create mode 100644 src/utils/methods/audioPlayerReturn.ts diff --git a/src/components/playback/audioPlayer/audioPlayer.scss b/src/components/playback/audioPlayer/audioPlayer.scss index e510676..1e85f8e 100644 --- a/src/components/playback/audioPlayer/audioPlayer.scss +++ b/src/components/playback/audioPlayer/audioPlayer.scss @@ -1,499 +1,589 @@ -$art-size: 48px; +/* Floating glass media bar — 2026 "liquid glass" treatment: + translucent saturated blur, cover-tinted ambient light, a thin specular rim + and an almost invisible grain layer so the surface reads as material rather + than as a flat translucent box. */ + +/* The full audio player is a route; keep the floating bar in the DOM until + the view transition has captured the old frame, then hide it. */ +html.player-full-open .audio-player { + display: none !important; +} .audio-player { + --player-accent: #{$clr-accent-default}; + --player-base: #1b0f2e; + --player-deep: #09040f; + position: fixed; - bottom: 0.75rem; - left: 50%; - transform: translateX(-50%); - width: min(1100px, calc(100% - 1.5rem)); - height: 80px; + left: 0; + right: 0; + bottom: 0.9rem; + margin: 0 auto; + width: min(1460px, calc(100% - 2rem)); + height: 84px; box-sizing: border-box; z-index: 100; + isolation: isolate; + overflow: hidden; display: grid; - // Equal side columns keep the transport truly centred - grid-template-columns: minmax(0, 1fr) minmax(0, 540px) minmax(0, 1fr); + grid-template-columns: + minmax(0, 1fr) + minmax(320px, 560px) + minmax(0, 1fr); align-items: center; - gap: 1.5rem; - padding: 0 0.75rem 0 1rem; + gap: 1.1rem; + padding: 0 0.75rem 0 0.85rem; + color: #fff; + border-radius: 24px; + border: 1px solid rgb(255 255 255 / 0.14); - color: white; - // Opaque bar: backdrop-filter over the virtualized grid caused constant - // compositing/shifting on WebKit. - background: rgb(18 18 24 / 0.98); - border: 1px solid rgb(255 255 255 / 0.08); - border-radius: 14px; - box-shadow: 0 12px 40px rgb(0 0 0 / 0.45); + background-color: rgb(14 11 24 / 0.55); + background-image: + radial-gradient( + 100% 190% at 0% 50%, + rgb(255 255 255 / 0.08), + transparent 62% + ), + linear-gradient( + 120deg, + rgb(255 255 255 / 0.11), + rgb(255 255 255 / 0.025) 38%, + rgb(7 5 14 / 0.38) 100% + ); + background-image: + radial-gradient( + 100% 190% at 0% 50%, + color-mix(in srgb, var(--player-accent) 20%, transparent), + transparent 62% + ), + radial-gradient( + 90% 160% at 100% 30%, + color-mix(in srgb, var(--player-deep) 42%, transparent), + transparent 68% + ), + linear-gradient( + 120deg, + rgb(255 255 255 / 0.11), + rgb(255 255 255 / 0.025) 38%, + rgb(7 5 14 / 0.38) 100% + ); + -webkit-backdrop-filter: blur(24px) saturate(170%) brightness(1.06); + backdrop-filter: blur(24px) saturate(170%) brightness(1.06); + box-shadow: + 0 28px 70px rgb(0 0 0 / 0.55), + 0 6px 18px rgb(0 0 0 / 0.35), + inset 0 1px 0 rgb(255 255 255 / 0.18), + inset 0 -1px 0 rgb(0 0 0 / 0.22); + box-shadow: + 0 28px 70px rgb(0 0 0 / 0.55), + 0 6px 18px rgb(0 0 0 / 0.35), + 0 0 55px color-mix(in srgb, var(--player-accent) 13%, transparent), + inset 0 1px 0 rgb(255 255 255 / 0.18), + inset 0 -1px 0 rgb(0 0 0 / 0.22); + + will-change: transform, opacity; + transform-origin: 50% 100%; + + /* Grain, kept below the content. */ + &::before { + content: ""; + position: absolute; + inset: 0; + z-index: 0; + border-radius: inherit; + pointer-events: none; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E"); + background-size: 140px 140px; + opacity: 0.035; + mix-blend-mode: soft-light; + } + + /* Specular gradient rim. */ + &::after { + content: ""; + position: absolute; + inset: 0; + z-index: 1; + border-radius: inherit; + padding: 1px; + pointer-events: none; + background: linear-gradient( + 135deg, + rgb(255 255 255 / 0.45), + rgb(255 255 255 / 0.06) 30%, + rgb(255 255 255 / 0.02) 62%, + rgb(255 255 255 / 0.25) + ); + -webkit-mask: + linear-gradient(#000 0 0) content-box, + linear-gradient(#000 0 0); + -webkit-mask-composite: xor; + mask: + linear-gradient(#000 0 0) content-box, + linear-gradient(#000 0 0); + mask-composite: exclude; + opacity: 0.9; + } + + > * { + position: relative; + z-index: 2; + } +} + +.media-bar { + &-left { + display: flex; + align-items: center; + gap: 0.8rem; + width: 100%; + min-width: 0; + max-width: 380px; + } + + &-cover { + position: relative; + width: 58px; + height: 58px; + flex: 0 0 58px; + padding: 0; + border: 1px solid rgb(255 255 255 / 0.16); + border-radius: 16px; + overflow: hidden; + display: flex; + align-items: center; + justify-content: center; + background: rgb(255 255 255 / 0.08); + color: rgb(255 255 255 / 0.55); + cursor: pointer; + box-shadow: + 0 8px 22px rgb(0 0 0 / 0.45), + inset 0 0 0 1px rgb(255 255 255 / 0.06); + box-shadow: + 0 8px 22px rgb(0 0 0 / 0.45), + 0 0 22px color-mix(in srgb, var(--player-accent) 22%, transparent), + inset 0 0 0 1px rgb(255 255 255 / 0.06); + + img { + width: 100%; + height: 100%; + display: block; + object-fit: cover; + transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1); + } + + &::after { + content: ""; + position: absolute; + inset: 0; + border-radius: inherit; + pointer-events: none; + background: linear-gradient( + 180deg, + rgb(255 255 255 / 0.2), + transparent 34%, + rgb(0 0 0 / 0.2) + ); + opacity: 0.55; + } + + &:hover img, + &:focus-visible img { + transform: scale(1.06); + } + + .material-symbols-rounded { + font-size: 1.5rem; + } + } &-info { display: flex; - align-items: center; - gap: 0.75rem; + flex-direction: column; min-width: 0; + flex: 1; + gap: 3px; + } - > .MuiIconButton-root { - flex-shrink: 0; - color: rgb(255 255 255 / 0.75); - .material-symbols-rounded { - font-size: 1.25rem; - } - } + &-title { + font-size: 0.92rem !important; + font-weight: 650 !important; + line-height: 1.2 !important; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + cursor: pointer; + text-shadow: 0 1px 10px rgb(0 0 0 / 0.25); - &-text { - display: flex; - flex-direction: column; - min-width: 0; - } - - &-title { - all: unset; - cursor: pointer; - font-weight: 600 !important; - line-height: 1.25 !important; - // Wrap long titles onto a second line before truncating - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 2; - overflow: hidden; - overflow-wrap: anywhere; - - &:hover, - &:focus-visible { - text-decoration: underline; - } - } - - &-artist { - opacity: 0.6; - - a { - color: inherit; - text-decoration: none; - &:hover { - text-decoration: underline; - } - } + &:hover, + &:focus-visible { + text-decoration: underline; + text-decoration-color: rgb(255 255 255 / 0.35); + text-underline-offset: 3px; } } - &-image { - position: absolute; - inset: 0; - width: 100%; - height: 100%; - object-fit: cover; - z-index: 1; + &-subtitle { + font-size: 0.72rem !important; + line-height: 1.3 !important; + opacity: 0.55; + letter-spacing: 0.01em; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } - &-container { - all: unset; - position: relative; - flex-shrink: 0; - width: $art-size; - height: $art-size; - border-radius: 8px; - overflow: hidden; - cursor: pointer; - background: rgb(255 255 255 / 0.08); + &-more { + flex-shrink: 0; + color: rgb(255 255 255 / 0.55) !important; + transition: + color 0.15s ease, + background-color 0.15s ease; - &:hover .audio-player-image-expand, - &:focus-visible .audio-player-image-expand { - opacity: 1; - } - } - - &-icon, - &-expand { - position: absolute; - left: 50%; - top: 50%; - transform: translate(-50%, -50%); - } - - &-icon { - font-size: 1.5rem !important; - opacity: 0.5; - } - - // "Open player" affordance shown over the art on hover - &-expand { - z-index: 2; - inset: 0; - transform: none; - display: flex; - align-items: center; - justify-content: center; - background: rgb(0 0 0 / 0.5); - opacity: 0; - transition: opacity 0.15s ease; + &:hover { + color: #fff !important; + background: rgb(255 255 255 / 0.08) !important; } } - // Transport on top, compact seek row underneath &-center { display: flex; - flex-direction: column; - align-items: center; - gap: 2px; + flex: 1; min-width: 0; + flex-direction: column; + align-items: stretch; + gap: 1px; + } - .player-controls { - gap: 0.5rem !important; + &-controls { + display: flex; + align-items: center; + align-self: center; + gap: 0.05rem; + padding: 3px; + border-radius: 999px; + background: rgb(255 255 255 / 0.045); + border: 1px solid rgb(255 255 255 / 0.07); + box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08); - .MuiFab-root { - width: 36px; - height: 36px; - min-height: 36px; - box-shadow: none; + .MuiIconButton-root { + width: 34px; + height: 34px; + border-radius: 50%; + color: rgb(255 255 255 / 0.68); + transition: + color 0.15s ease, + background-color 0.15s ease, + transform 0.15s ease; - .material-symbols-rounded { - font-size: 1.6rem !important; - } + &:hover { + color: #fff; + background: rgb(255 255 255 / 0.09); + transform: translateY(-1px); } + + &.active { + color: var(--player-accent); + background: color-mix( + in srgb, + var(--player-accent) 13%, + transparent + ); + } + + .material-symbols-rounded { + font-size: 1.2rem; + } + } + } + + &-play { + width: 44px !important; + height: 44px !important; + margin: 0 0.3rem; + background: #fff !important; + color: #100a1b !important; + box-shadow: + 0 8px 24px rgb(0 0 0 / 0.45), + 0 0 0 1px rgb(255 255 255 / 0.25); + box-shadow: + 0 8px 24px rgb(0 0 0 / 0.45), + 0 0 0 1px rgb(255 255 255 / 0.25), + 0 0 26px color-mix(in srgb, var(--player-accent) 24%, transparent); + transition: + transform 0.16s ease, + box-shadow 0.2s ease; + + &:hover { + background: #fff !important; + transform: scale(1.06); + box-shadow: + 0 10px 28px rgb(0 0 0 / 0.5), + 0 0 0 1px rgb(255 255 255 / 0.35), + 0 0 34px color-mix( + in srgb, + var(--player-accent) 34%, + transparent + ); + } + + .material-symbols-rounded { + font-size: 1.55rem !important; + font-variation-settings: "FILL" 1; } } &-progress { - gap: 0.6rem !important; - - .MuiTypography-root { - min-width: 2.75em !important; - font-size: 0.7rem; - opacity: 0.6 !important; - } + flex: 1; + min-width: 140px; .MuiSlider-root { - padding: 8px 0; + padding: 7px 0; + color: var(--player-accent); } - .MuiSlider-thumb { - width: 10px; - height: 10px; - opacity: 0; - transition: opacity 0.15s ease; - } - &:hover .MuiSlider-thumb, - .MuiSlider-root.Mui-active .MuiSlider-thumb { + + .MuiSlider-rail { + height: 4px; + border-radius: 999px; + background: rgb(255 255 255 / 0.13); opacity: 1; } + + .MuiSlider-track { + height: 4px; + border: 0; + border-radius: 999px; + background: linear-gradient( + 90deg, + rgb(255 255 255 / 0.95), + var(--player-accent) + ); + box-shadow: 0 0 12px + color-mix(in srgb, var(--player-accent) 45%, transparent); + } + + .MuiSlider-thumb { + width: 12px; + height: 12px; + background: #fff; + box-shadow: + 0 0 0 4px color-mix( + in srgb, + var(--player-accent) 16%, + transparent + ), + 0 2px 8px rgb(0 0 0 / 0.5); + transition: + transform 0.15s ease, + box-shadow 0.2s ease; + + &:hover, + &.Mui-focusVisible { + transform: scale(1.15); + box-shadow: + 0 0 0 6px color-mix( + in srgb, + var(--player-accent) 20%, + transparent + ), + 0 2px 10px rgb(0 0 0 / 0.55); + } + } + + .MuiTypography-root { + min-width: 2.6em !important; + font-family: var(--font-mono); + font-size: 0.66rem; + opacity: 0.5 !important; + font-variant-numeric: tabular-nums; + } } - &-actions { + &-right { display: flex; align-items: center; justify-content: flex-end; - gap: 0.25rem; - min-width: 0; + gap: 0.05rem; + flex-shrink: 0; + padding: 3px 4px; + border-radius: 999px; + background: rgb(255 255 255 / 0.035); + border: 1px solid rgb(255 255 255 / 0.055); + box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06); .MuiIconButton-root { - color: rgb(255 255 255 / 0.75); + width: 34px; + height: 34px; + border-radius: 50%; + color: rgb(255 255 255 / 0.62); + transition: + color 0.15s ease, + background-color 0.15s ease; + &:hover { - color: white; + color: #fff; + background: rgb(255 255 255 / 0.08); + } + + .material-symbols-rounded { + font-size: 1.2rem; } } } &-volume { - display: flex; - align-items: center; - min-width: 0; + width: 92px !important; + margin: 0 0.25rem 0 0 !important; + color: var(--player-accent) !important; - // Secondary control: neutral and compact - .MuiSlider-root { - width: 5.5rem !important; - color: rgb(255 255 255 / 0.85); + .MuiSlider-rail { + height: 3px; + border-radius: 999px; + background: rgb(255 255 255 / 0.14); + opacity: 1; } - } - @media (max-width: 900px) { - .audio-player-volume, - .audio-player-progress .MuiTypography-root { - display: none; + .MuiSlider-track { + height: 3px; + border: 0; + border-radius: 999px; + background: linear-gradient( + 90deg, + rgb(255 255 255 / 0.9), + var(--player-accent) + ); } - } - @media (max-width: 640px) { - grid-template-columns: minmax(0, 1fr) auto auto; - gap: 0.5rem; - bottom: 0.5rem; - width: calc(100% - 1rem); - height: 64px; - - .audio-player-center .player-controls > :not(:has(.MuiFab-root)), - .audio-player-progress { - display: none; - } - .audio-player-actions > :not(:last-child) { - display: none; + .MuiSlider-thumb { + width: 10px; + height: 10px; + background: #fff; + box-shadow: 0 0 0 3px + color-mix(in srgb, var(--player-accent) 16%, transparent); } } } -/* Unified, minimal media bar (local playback + remote device control). */ -.audio-player { - display: flex; - align-items: center; - width: min(1440px, calc(100% - 1.5rem)); - height: 82px; - gap: 1.25rem; - padding: 0 0.9rem; - background: #0b0816; - border: 1px solid rgb(255 255 255 / 0.08); - border-radius: 18px; +@supports not ( + (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) +) { + .audio-player { + background: rgb(14 11 24 / 0.96); + } - .media-bar { - &-left { - display: flex; - align-items: center; - gap: 0.75rem; - width: 30%; - min-width: 220px; - max-width: 360px; - } + .audio-player::before { + display: none; + } +} - &-cover { - width: 52px; - height: 52px; - flex: 0 0 52px; - padding: 0; - border: 0; - border-radius: 6px; - overflow: hidden; - background: rgb(255 255 255 / 0.06); - color: rgb(255 255 255 / 0.5); - display: flex; - align-items: center; - justify-content: center; - cursor: pointer; +@media (prefers-reduced-transparency: reduce) { + .audio-player { + background: rgb(14 11 24 / 0.96); + -webkit-backdrop-filter: none; + backdrop-filter: none; + } - img { - width: 100%; - height: 100%; - object-fit: cover; - display: block; - } - } + .audio-player::before { + display: none; + } +} - &-info { - display: flex; - flex-direction: column; - min-width: 0; - flex: 1; - } +@media (max-width: 1100px) { + .audio-player { + gap: 0.8rem; + } - &-title { - font-weight: 600 !important; - line-height: 1.2 !important; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - cursor: pointer; - &:hover { - text-decoration: underline; - } - } + .media-bar-left { + max-width: 320px; + } - &-subtitle { - opacity: 0.55; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - - &-more { - flex-shrink: 0; - color: rgb(255 255 255 / 0.6); - } - - &-center { - display: flex; - align-items: center; - gap: 1.25rem; - flex: 1; - min-width: 0; - } - - &-controls { - display: flex; - align-items: center; - gap: 0.15rem; - flex-shrink: 0; - - .MuiIconButton-root { - color: rgb(255 255 255 / 0.7); - transition: color 0.15s ease, transform 0.15s ease; - &:hover { - color: #fff; - background: rgb(255 255 255 / 0.06); - } - &.active { - color: $clr-accent-default; - } - .material-symbols-rounded { - font-size: 1.25rem; - } - } - } - - &-play { - width: 46px !important; - height: 46px !important; - margin: 0 0.5rem; - background: #fff !important; - border: 0; - color: #0b0417 !important; - box-shadow: 0 6px 18px rgb(0 0 0 / 0.35); - transition: transform 0.15s ease; - - &:hover { - background: #fff !important; - transform: scale(1.04); - } - .material-symbols-rounded { - font-size: 1.6rem !important; - } - } - - &-progress { - flex: 1; - min-width: 140px; - - .MuiSlider-root { - padding: 10px 0; - color: $clr-accent-default; - } - .MuiSlider-rail { - background: rgb(255 255 255 / 0.16); - opacity: 1; - } - .MuiSlider-track { - border: 0; - } - .MuiSlider-thumb { - width: 12px; - height: 12px; - background: #fff; - box-shadow: none; - &:hover, - &.Mui-focusVisible { - box-shadow: 0 0 0 6px rgb(124 199 255 / 0.16); - } - } - .MuiTypography-root { - opacity: 0.55; - font-variant-numeric: tabular-nums; - font-weight: 400; - } - } - - &-right { - display: flex; - align-items: center; - gap: 0.1rem; - flex-shrink: 0; - - .MuiIconButton-root { - color: rgb(255 255 255 / 0.65); - &:hover { - color: #fff; - background: rgb(255 255 255 / 0.06); - } - .material-symbols-rounded { - font-size: 1.3rem; - } - } - } - - &-volume { - width: 84px !important; - margin: 0 0.35rem 0 0 !important; - color: $clr-accent-default !important; - - .MuiSlider-rail { - background: rgb(255 255 255 / 0.16); - opacity: 1; - } - .MuiSlider-thumb { - width: 10px; - height: 10px; - background: #fff; - box-shadow: none; - } - } + .media-bar-volume { + width: 72px !important; } } @media (max-width: 900px) { .audio-player { - .media-bar-left { - min-width: 160px; - } - .media-bar-volume, - .media-bar-right .MuiSlider-root { - display: none; - } + width: calc(100% - 1.5rem); + } + + .media-bar-left { + min-width: 180px; + max-width: none; + } + + .media-bar-volume, + .media-bar-right .MuiSlider-root { + display: none; } } - @media (max-width: 700px) { .audio-player { + display: flex; width: calc(100% - 1rem); - height: 66px; - bottom: 0.5rem; + height: 68px; + bottom: 0.55rem; padding: 0 0.55rem; - gap: 0.5rem; - border-radius: 14px; - box-sizing: border-box; + gap: 0.45rem; + border-radius: 20px; + } - .media-bar-left { - width: auto; - min-width: 0; - max-width: none; - flex: 1 1 auto; - gap: 0.55rem; - } + .media-bar-left { + width: auto; + min-width: 0; + max-width: none; + flex: 1 1 auto; + gap: 0.55rem; + } - .media-bar-cover { - width: 44px; - height: 44px; - flex: 0 0 44px; - } + .media-bar-cover { + width: 46px; + height: 46px; + flex: 0 0 46px; + border-radius: 13px; + } - .media-bar-more { + .media-bar-more { + display: none; + } + + .media-bar-center { + flex: 0 0 auto; + gap: 0; + } + + .media-bar-controls { + padding: 2px; + + > :first-child, + > :last-child { display: none; } - .media-bar-center { - flex: 0 0 auto; - gap: 0; - } - - .media-bar-controls { - gap: 0; - - > :first-child, - > :last-child { - display: none; - } - - .MuiIconButton-root { - width: 36px; - height: 36px; - } - } - - .media-bar-play { - width: 40px !important; - height: 40px !important; - margin: 0 0.1rem; - } - - .media-bar-progress, - .media-bar-right { - display: none !important; - } - - .media-bar-title { - font-size: 0.9rem; + .MuiIconButton-root { + width: 32px; + height: 32px; } } + + .media-bar-play { + width: 40px !important; + height: 40px !important; + margin: 0 0.15rem; + } + + .media-bar-progress, + .media-bar-right { + display: none !important; + } + + .media-bar-title { + font-size: 0.86rem !important; + } + + .media-bar-subtitle { + font-size: 0.67rem !important; + } } diff --git a/src/components/playback/audioPlayer/index.tsx b/src/components/playback/audioPlayer/index.tsx index 67e89ca..a6f02a8 100644 --- a/src/components/playback/audioPlayer/index.tsx +++ b/src/components/playback/audioPlayer/index.tsx @@ -18,13 +18,23 @@ import Tooltip from "@mui/material/Tooltip"; import Typography from "@mui/material/Typography"; import { useQuery } from "@tanstack/react-query"; import { useLocation, useNavigate } from "@tanstack/react-router"; -import { AnimatePresence, motion } from "motion/react"; +import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { useSnackbar } from "notistack"; -import React, { type SyntheticEvent, useEffect, useRef, useState } from "react"; +import React, { + type SyntheticEvent, + useEffect, + useMemo, + useRef, + useState, +} from "react"; import QueueButton from "@/components/buttons/queueButton"; import { secToTicks, ticksToSec } from "@/utils/date/time"; -import getImageUrlsApi from "@/utils/methods/getImageUrlsApi"; +import { getCoverPalette } from "@/utils/methods/coverColor"; +import getImageUrlsApi, { + getPlayerCoverUrl, +} from "@/utils/methods/getImageUrlsApi"; import { startInstantMix } from "@/utils/methods/instantMix"; +import { rememberAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn"; import { playOnSession, queueStartingWith, @@ -57,6 +67,8 @@ const AudioPlayer = () => { const user = useCentralStore((s) => s.currentUser); const navigate = useNavigate(); const location = useLocation(); + const reduceMotion = useReducedMotion(); + const previousPathRef = useRef(location.pathname); const { enqueueSnackbar } = useSnackbar(); const openRemoteDialog = useRemoteControlStore((s) => s.openDialog); @@ -163,14 +175,15 @@ const AudioPlayer = () => { ? `${artistNames.join(", ")} · ${remoteDevice}` : `Идёт на ${remoteDevice}` : artistNames.join(", ") || activeItem?.Album || ""; - const coverUrl = - api && activeItem?.Id - ? getImageUrlsApi(api).getItemImageUrlById( - activeItem.AlbumId ?? activeItem.Id, - "Primary", - { quality: 85, fillHeight: 120, fillWidth: 120 }, - ) - : undefined; + const coverUrl = getPlayerCoverUrl(api, activeItem, 600); + const fullCoverUrl = getPlayerCoverUrl(api, item, 600); + const palette = useMemo(() => getCoverPalette(activeItem), [activeItem]); + useEffect(() => { + if (!fullCoverUrl) return; + const image = new Image(); + image.src = fullCoverUrl; + void image.decode?.().catch(() => undefined); + }, [fullCoverUrl]); const isPlaying = remote ? !remote.PlayState?.IsPaused : playing; @@ -218,6 +231,22 @@ const AudioPlayer = () => { location.pathname === "/player" || location.pathname === "/player/audio" || location.pathname === "/remote"; + + // The audio route keeps the floating bar mounted (hidden by the + // `player-full-open` class) until the view transition has captured the old + // frame. Other full-screen pages can remove it immediately. + const hideBarForFullPage = + isFullPlayer && location.pathname !== "/player/audio"; + + // Returning from the full audio player: the bar must already be in its + // final place when the view-transition snapshot is taken, otherwise the + // cover would morph towards an off-screen/transparent target. + const cameFromFullPlayer = + previousPathRef.current === "/player/audio" && !isFullPlayer; + useEffect(() => { + previousPathRef.current = location.pathname; + }, [location.pathname]); + useEffect(() => { const visible = barVisible && !isFullPlayer; document.body.classList.toggle("has-player-bar", visible); @@ -354,6 +383,7 @@ const AudioPlayer = () => { if (remote) { openRemoteDialog(remote.NowPlayingItem); } else { + rememberAudioPlayerReturn(); navigate({ to: "/player/audio" }); } }; @@ -576,19 +606,39 @@ const AudioPlayer = () => { /> ) : null; - if (!barVisible && !display) { - return null; - } - const bar = ( - - +