Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dddaea0b8f |
No files matched your search
@@ -42,6 +42,3 @@ target/
|
|||||||
generateBanner
|
generateBanner
|
||||||
# Million Lint
|
# Million Lint
|
||||||
.million
|
.million
|
||||||
|
|
||||||
# TypeScript incremental build cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
+27
-37
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="ru">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
@@ -7,64 +7,54 @@
|
|||||||
<!-- <script src="http://localhost:8097"></script> -->
|
<!-- <script src="http://localhost:8097"></script> -->
|
||||||
<title>Blink</title>
|
<title>Blink</title>
|
||||||
<style>
|
<style>
|
||||||
html,
|
|
||||||
body {
|
|
||||||
background: #08001f;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app-loading {
|
.app-loading {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%,-50%);
|
transform: translate(-50%,-50%);
|
||||||
|
width: 10em;
|
||||||
|
height: 10em;
|
||||||
|
background: rgb(180 180 180);
|
||||||
z-index: 100000;
|
z-index: 100000;
|
||||||
display: flex;
|
mask-image: url("./src/assets/icon-outline.png");
|
||||||
align-items: center;
|
mask-size: contain;
|
||||||
justify-content: center;
|
|
||||||
pointer-events: none;
|
|
||||||
transition: opacity 0.2s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-loading.hidden {
|
.app-loading.hidden {
|
||||||
opacity: 0;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-loading-logo {
|
|
||||||
display: block;
|
.app-loading-anim{
|
||||||
width: min(230px, 62vw);
|
width: 150%;
|
||||||
height: auto;
|
height: 100%;
|
||||||
filter: drop-shadow(0 10px 30px rgb(0 0 0 / 0.35));
|
position: absolute;
|
||||||
animation: splashPulse 1.4s ease-in-out infinite;
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background: linear-gradient(to right,transparent,rgb(255 255 255),transparent);
|
||||||
|
transform: scaleX(0);
|
||||||
|
animation: loading 0.75s linear infinite both;
|
||||||
|
transform-origin: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes splashPulse {
|
@keyframes loading {
|
||||||
0%,
|
0%{
|
||||||
100% {
|
transform: translate(-100%);
|
||||||
opacity: 1;
|
|
||||||
}
|
}
|
||||||
50%{
|
50%{
|
||||||
opacity: 0.62;
|
transform: translate(0%);
|
||||||
}
|
}
|
||||||
}
|
100%{
|
||||||
|
transform: translate(100%);
|
||||||
@media (prefers-reduced-motion: reduce) {
|
|
||||||
.app-loading-logo {
|
|
||||||
animation: none;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="app-loading" role="status" aria-label="Загрузка Blink">
|
<div class="app-loading">
|
||||||
<img
|
<!-- <img src="./src/assets/icon-outline.svg" class="app-loading-logo" /> -->
|
||||||
class="app-loading-logo"
|
<div class="app-loading-anim"></div>
|
||||||
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAX8AAACqCAYAAABFwE9PAAAAAXNSR0IArs4c6QAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAABf6ADAAQAAAABAAAAqgAAAAAX35FHAAA3E0lEQVR4Ae2dB/wcRfn/CSGEGgi9hNB7b9IhQAhFQHqTjhRFQRB/gAiIggIK/hWkozQhRIr03nsvIiWUQCD03kNJ/u9PuPt6ue/e3c7sM3u7d/O8Xs/3dmdnPk+Z2Wdnp+y3zySRGnpg/Pjxfbk4KzwQnq7C/fn9HP64wh/y+2afPn3G8RspeiB6IHqgFB7oUwotc1KSYD8Fos6BB8FzwXPCegC0orFkeBEeCT9fw8/xUHiD80jRA9ED0QOF8kBXBX+C+0J4fw14PlgBfnJYPXcF/QHwyvAcsCW9ANgN8I3wbTwMPrEEj1jRA9ED0QM+Hujo4E+w74dT1oO3rfzO7uMkwzJfg3UfrAfBCB4EekuIlMID1KXaKi6Lw2sp3BWzlNgDtHV1SteE1RmdDdbQ85Swhprfgx+Ab+ZeeJPfSFUP4LhJ4SHw6fC7cFFpHIpdDevhFKnGA/hkefhgeAT8CPwO/C38MjxPTdZ4GD3QMR6gbU8GHwZ/ArcixY/jYHVwu5twwvfgE+ExcNnovyi8NzxVt9Yitg+CFfBvhptRfAB0ayPpYLtp8Oq0XtWs4Te4diXpaeYlO8t7GD0APgB+Hu4Eeg8j9oQ7ejiuvhVi7+rw23Baig+AeifG81J7gIZ/fNrGn5Dv9FIb76o8DvgZrGDZiXQHRi3s6pMy5sfOGWCXwF+tbz0A5i6jzVHn6IFaD9CO14Y1jJOFtqrF7NhjPKTecafTlxh4BKzJn44l7MvS43mB8lqOGyl6oJQeoP1OA6sjk5XeAsBp/H/SUnpskkkGl1RvF7W1mewo+FEqtZN7uKu7OKUu7/yc34J/tBoiUvRAGT1wJEpb3N+zgLOMiwPKGvy1VLJbaHEM1TDQPB1qsOzLQhoe0yTxTFlAYtnogbw9QJtdApk/N5S7ggtWWYP/3Rj5uouhJc+rnoEeANqc1jFUsUeb67KSbqIzs4LE8tEDOXvgb8ibzFDmNy5YpQz+bG4Yj5FXuBjaAXk11HU7AVNDHZ1CQwwN2QzfrGuIF6GiB4J5gLaqjadrGgt4zgWvlMG/YuBx/L7rYmwH5NX3hvQAmL4DbJEJGxjbsb8xXoSLHjD3APevdusebwysXv9TLpilDf70/l/BUH03p9toEAYfUXajuQG0MmGYsR0a/okUPVB0DxyEgnqTt6QriYnvuwCWejMRAWQMxlp/iM3Ff+3Kq28ELUllO73mtUvZJLnU3VDSb0q6liFNw4FT4ZcvM2DEotEDwTxAu9fS5JGw9W7+YbR7p/uptD1/nKghkG4M/GqY6jWfqIMS02aBdNcDIFL0QFE98AcUsw78GgG52dXg0gZ/DF3f1dgOy78RD8ANy2gTeqvdbRFA99fo/YwNgBshowcye4B2vzwgO2YG6g3wO9q9c6enzMF/694+6LqUY0pq8WroPXsA3dUDihQ9UFQPnIBi1kPtj4F5vo/BlmtMfeR7leEJqt1seS3rew1Z+n62+GH4LVgTK+JxsHaXKpCJF4KHwFrCNQAOTcvii8E89UeHFmSMH+rBHYO/cUVFOBsPcJ9uCtJaNmgToRzk0+ufCKFMJzjyIDgkvQ/4ybBe05yJcn1hfWL6LPgrOCTt7axgGwvgiD7wa4Ec8n9tNC2Kjh5I9ABtXd/pfyZAm78mUWCnJuJABY+RARwpyG/gk2CzdfRgzVXBDPUQKNVmN3yxGhyKNu/Udh/tKq8HaOz7BGjw+udGi5XXKx6aY/A6ARxZhdzBQ6VURRCwPpzmP/RUdUn7+ykZS/PlT3T9S1rDHPPpK6h5DLWlqu+YKXpAHqBN6qudbzq25TTZR3Sdh/HKFWk845HHa9LEpQLQaXlYn161Jq2ZLzxhtP5b0evWxlfwLiu8A6KCXecB2uZvArX35bI6s1SrfXDi/Bi8cVajG5S/vkG6WTITM48ApiWO35qBfgc0xBgvFJz0DLHKR/oO159I0QNF8QDxSotBfhFAn5uIJY9mxS1V8MfYn8GhdH4yqzPTlKfS7iGf9RLNsmx22z6Njzzy6BtPpZr78LAxFimfB45E5WkCqK3/89E9xFNUY2cfwSFIkyf98/ImsjT7/x9DQ67KS3dfOdjaD9YqqhB0rK9esVz0QAgP0MgXhL8O0Ngvt9I3VC/aSr9anF04CTWh9yI98rG1wkIeI+sb8G80lDGzIVYoKO3IHhgAXHstTguAGyGjB7J4QG/31vuovgLz4CxK1Za1Vq4W2+yYp6d2xf3UDLA30Dm9k4Kn3G8ooQzBP9SQz7U8TF/29SVtSw+kTWHNJ+l+GA0/A99TeUhzGCl6IL0HaFMrknvr9CVS5zyONjkyde5OyIgzh8KhSMsvZ8jbT8hcwdCgj/PW30UedmrITktSQ5DXSicU6Q8fCzfS6x2unQ7P62JrzBs9QJu5FbYm7W3KbWi6MLWI0aGWd6qCNImcOyF3Twk3pMI2DGzcxdDOWqgnfCsOkHNqgZoca//A7+EQE3e+6sdyBfUA7UT7eUJQXp+zKY5n8eK8sCZkQ5D+L25b5j2Qe6GxQbMVp9Ym1gQ7Q/SE5D7NAzkT5bZQYUfS/oSdnYXFAl3jAdqHvj7wiGO7SpP9oq5xYq2heOaPabzjkWcMZdoSMJE7PfyZh87NirTFltq6SjpG4cHwuGaKe17T94H6JclslkaZaeE3PGWq2GHN8OO17vUAbWOrDO2qUVENS+ofwJhTW3q9aa3AaP3Tgz3S5nfM92cmT950LGOVfTeALP+hw0fg6WujRaSdUEoT9tb0/6i/rz1A96NMlgfl0bTLUG3Sw5xYpAgeoE30RY+jA+jye9r5mAC4xYbEodbj4kBOII3jzt0O65HbD35xghZ2f25phy1pZGLic3Zm9iB9yJHzsl/KqNf/Xg+K/4E+ALhJGvtjnu7wAO1hd//m1LDkK1yZIpQHC93zx+hQk7FH8TR9JZRTW+D+iOvztcjjevkh1wJ55Kfhrowc/Y8DazqV+vNZ4aT2ZLGyS728M7BPv5G63AO0Ay220G5ea/oV7fxLa9DC4+HQtWBrGg3glXBbHnrInQoO8WGzrYpYodh6CmxNemtzHrahjFWvv9Yer2WmRayrqJO/B2gQ+9U2CqPjB8EJMVzaY2hbgmCP9OYHIXr92lm7A09T7QptBx2AUOsPm30B5s3tMKaZTBquekPbNcvjee1c6s9nrsaq11+r9g61J/G4+zxAO9ewzCEBLD+Kdj4+AG6xIXHoXLDGVa3p1HZZjiFzw9YrfOSfv7fLpmZy0SvEyge1iQWayU26RpkQvX5gx8d/G5nk8C5Kow3sr4ZgTC+BF7xjHlyAZzv4CeWsx1P1XYzjPPWxKPYXQCxX+FR1Oq16ULDfEGvi/0VvyCfghuj1y92DuEmDvpoXrE6jOjUeoO7V6zf71k4N9MG083aNTtSokfOhHAq/C1vTCTmb0iMOQza2NqaC90iPkAIdoNsscIgvGi7taiZ6hOr1V6pgwjfbXdWK+TvAAzSAEGP9ub3JF7Hnrw+AzWjcNt4G77fGmKngaCAa+1avPwQVtdevsfDJjA3WB9ye8MAM1euvqmKxeqiKFX9L4gHua/3r1F8aq7srbXx3Y8zywOHUx2Br2q1dHsCQg62NqeDpw2NTt8uuZnLR69EANq/ZTGbSNXQI3euXmdYT+EmmxLSCeYB630uVb0jayWs91F0wrzVRB+NXN3RmFeoRDtoyLovcWeGPq4oY/+7fxJVtu4SNSxrbKbgHfQyi3DEBdKmF1GcrrN9wfEyNZXL0AHWujZqjYEsy+yctaV1RtGGfEN/s/wWvUu1aMvV7KmLatJXhkG8Uedu2cqmFnru2uO5z+U+uhbgr16JMiMm4WlWeoW1p+XCk7vKAFjPMY2zyxcZ45YHjZp0d/sryUQrWte3yALKXg0N9jbSQ68uxd3L4bdiStOzN6XWY/DPC+vBbaDq8Xe0rym2PB2hQk8HWn2d5C0zNIeRKRer5743lzl9pbOGto1tcD3KZipwS4PPgEP59FNyLgiieHVT/Ecv6v4rpA27fOqqmJb1BvoRYp8fwuvN42vke0MbF+YzNPJs2rqXo3UcES42hWX/24LZ2eRJbzoRD0dB22dVKLgZfb2y0/uG786Q2ZZ4w1iMJrpDfU2pVR/F6Ng/QEPTZBUvS6MDc2bTyKx2iZ+qjyZYUsl41cayPIlnLUJHbgvGjrDgNyl9ND6Fwn3KQrtg9mJ/1Gujtm3wa9n7mUVibb0LT+aEFRPxieYA2vgoarWis1XW08VeMMVPBFSX4W0/0Pof1N6bygGEmGodeB88whKyF+oiTfWoTCnas5bSW7UmvwSd52vi+Z7m0xZ4kY1En3NPaEPO5eyDECrvT3dWwKWF5s3ppRMBchoKreRVuXOhknqbjG1+2v4Id+r68lmvpNwQdiE2F/KcO2K52tLux0Rdg7xuemArOoUire7QZx+cfyYTSKeIG9gBtXHNIGqGwpFcBa9uilLYHf4y37vV/Aua5ljXUCouGoZn6y+ClWuX1vH4DwSa3bd8eOmq4R8M+VjQOoCzfYbrPSpEEnGOoi8cS0mNSZ3tA3xuz3tNxFm3JdTFDZ3iZoDkQ/hy2pFDDLolOR3H90+YLLA2ow9ImsbkShRckEf0urdM562mmNc8Inwb+JKsSCeUfJ816RVpBajGq0cgD1Lm+N6Yd9Zakb1/N0UhmHunt7vnvgZFaFmlJZ1uCpcD6A3l+mCKfb5aD6B3o9bCQRAOeDcU2MVbu+Cx4+OtTyl+YBSOh7Aek7Qh2HO5JcE6HJ+2AfTMZ2ziCtvS6MWY54Agak8LWmyWeytN69N8XDklX5WmPjyLine truncated
|
|
||||||
alt="Blink"
|
|
||||||
width="383"
|
|
||||||
height="170"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<svg style="width: 0; height: 0; position: absolute" aria-hidden="true" focusable="false">
|
<svg style="width: 0; height: 0; position: absolute" aria-hidden="true" focusable="false">
|
||||||
|
|||||||
+4
-6
@@ -4,7 +4,7 @@
|
|||||||
"version": "1.0.0-alpha.4",
|
"version": "1.0.0-alpha.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite && tsr watch",
|
"dev": "vite --force && tsr watch",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.14.1",
|
"@emotion/styled": "^11.14.1",
|
||||||
"@fontsource-variable/caveat": "^5.3.0",
|
|
||||||
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
||||||
"@fontsource-variable/noto-sans": "^5.3.0",
|
"@fontsource-variable/noto-sans": "^5.3.0",
|
||||||
"@fontsource-variable/plus-jakarta-sans": "^5.3.0",
|
"@fontsource-variable/plus-jakarta-sans": "^5.3.0",
|
||||||
@@ -30,13 +29,15 @@
|
|||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"@react-spring/web": "^10.1.2",
|
"@react-spring/web": "^10.1.2",
|
||||||
"@tanem/react-nprogress": "^7.1.7",
|
"@tanem/react-nprogress": "^7.1.7",
|
||||||
|
"@tanstack/react-devtools": "^0.10.13",
|
||||||
"@tanstack/react-form": "^1.33.5",
|
"@tanstack/react-form": "^1.33.5",
|
||||||
"@tanstack/react-query": "^5.104.4",
|
"@tanstack/react-query": "^5.104.4",
|
||||||
|
"@tanstack/react-query-devtools": "^5.104.4",
|
||||||
"@tanstack/react-router": "^1.170.45",
|
"@tanstack/react-router": "^1.170.45",
|
||||||
|
"@tanstack/react-router-devtools": "^1.167.2",
|
||||||
"@tanstack/react-virtual": "^3.14.21",
|
"@tanstack/react-virtual": "^3.14.21",
|
||||||
"@tauri-apps/api": "2.12.4",
|
"@tauri-apps/api": "2.12.4",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "2.5.0",
|
"@tauri-apps/plugin-clipboard-manager": "2.5.0",
|
||||||
"@tauri-apps/plugin-deep-link": "2.6.3",
|
|
||||||
"@tauri-apps/plugin-dialog": "2.8.3",
|
"@tauri-apps/plugin-dialog": "2.8.3",
|
||||||
"@tauri-apps/plugin-global-shortcut": "~2.4.1",
|
"@tauri-apps/plugin-global-shortcut": "~2.4.1",
|
||||||
"@tauri-apps/plugin-notification": "2.7.0",
|
"@tauri-apps/plugin-notification": "2.7.0",
|
||||||
@@ -45,7 +46,6 @@
|
|||||||
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
||||||
"@tauri-apps/plugin-updater": "2.14.0",
|
"@tauri-apps/plugin-updater": "2.14.0",
|
||||||
"@tauri-apps/plugin-upload": "2.5.0",
|
"@tauri-apps/plugin-upload": "2.5.0",
|
||||||
"@tauri-apps/plugin-websocket": "2.5.0",
|
|
||||||
"@tauri-apps/plugin-window-state": "~2.5.0",
|
"@tauri-apps/plugin-window-state": "~2.5.0",
|
||||||
"@types/node": "^26.6.5",
|
"@types/node": "^26.6.5",
|
||||||
"@types/react": "^19.3.0",
|
"@types/react": "^19.3.0",
|
||||||
@@ -61,7 +61,6 @@
|
|||||||
"material-symbols": "^0.48.0",
|
"material-symbols": "^0.48.0",
|
||||||
"motion": "^14.4.0",
|
"motion": "^14.4.0",
|
||||||
"notistack": "^3.0.2",
|
"notistack": "^3.0.2",
|
||||||
"qrcode": "^1.5.4",
|
|
||||||
"react": "^19.3.1",
|
"react": "^19.3.1",
|
||||||
"react-blurhash": "^0.3.0",
|
"react-blurhash": "^0.3.0",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
@@ -87,7 +86,6 @@
|
|||||||
"@tanstack/router-vite-plugin": "^1.167.47",
|
"@tanstack/router-vite-plugin": "^1.167.47",
|
||||||
"@tauri-apps/cli": "2.12.3",
|
"@tauri-apps/cli": "2.12.3",
|
||||||
"@types/lodash": "^4.17.26",
|
"@types/lodash": "^4.17.26",
|
||||||
"@types/qrcode": "^1.5.6",
|
|
||||||
"@vitejs/plugin-react": "^6.1.2",
|
"@vitejs/plugin-react": "^6.1.2",
|
||||||
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
||||||
"eslint-plugin-react-hooks": "7.1.1",
|
"eslint-plugin-react-hooks": "7.1.1",
|
||||||
|
|||||||
Generated
+492
-247
File diff suppressed because it is too large.
Load diff
Generated
+93
-549
File diff suppressed because it is too large.
Load diff
@@ -30,16 +30,11 @@ tauri-plugin-notification = "2.0.0-rc.1"
|
|||||||
tauri-plugin-upload = "2.0.0"
|
tauri-plugin-upload = "2.0.0"
|
||||||
tauri-plugin-dialog = "2.0.0"
|
tauri-plugin-dialog = "2.0.0"
|
||||||
tauri-plugin-shell = "2.3.5"
|
tauri-plugin-shell = "2.3.5"
|
||||||
tauri-plugin-websocket = "2.5.0"
|
|
||||||
tauri-plugin-deep-link = "2.6.3"
|
|
||||||
tauri-plugin-mcp-bridge = { version = "0.13.2", optional = true }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# by default Tauri runs in production mode
|
# by default Tauri runs in production mode
|
||||||
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
||||||
default = [ "custom-protocol" ]
|
default = [ "custom-protocol" ]
|
||||||
# Dev-only MCP bridge for UI automation: `pnpm tauri dev -- --features mcp-bridge`
|
|
||||||
mcp-bridge = ["dep:tauri-plugin-mcp-bridge"]
|
|
||||||
# this feature is used for production builds where `devPath` points to the filesystem
|
# this feature is used for production builds where `devPath` points to the filesystem
|
||||||
# DO NOT remove this
|
# DO NOT remove this
|
||||||
custom-protocol = [ "tauri/custom-protocol" ]
|
custom-protocol = [ "tauri/custom-protocol" ]
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
"global-shortcut:allow-is-registered",
|
"global-shortcut:allow-is-registered",
|
||||||
"global-shortcut:allow-register",
|
"global-shortcut:allow-register",
|
||||||
"global-shortcut:allow-unregister",
|
"global-shortcut:allow-unregister",
|
||||||
"websocket:default",
|
|
||||||
"shell:default"
|
"shell:default"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -17,19 +17,9 @@
|
|||||||
"updater:allow-install",
|
"updater:allow-install",
|
||||||
"notification:default",
|
"notification:default",
|
||||||
"core:webview:allow-internal-toggle-devtools",
|
"core:webview:allow-internal-toggle-devtools",
|
||||||
"core:window:allow-start-dragging",
|
|
||||||
"core:window:allow-start-resize-dragging",
|
|
||||||
"core:window:allow-minimize",
|
|
||||||
"core:window:allow-maximize",
|
|
||||||
"core:window:allow-unmaximize",
|
|
||||||
"core:window:allow-toggle-maximize",
|
|
||||||
"core:window:allow-close",
|
|
||||||
"core:window:allow-is-maximized",
|
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
"upload:allow-download",
|
"upload:allow-download",
|
||||||
"clipboard-manager:allow-write-text",
|
"clipboard-manager:allow-write-text",
|
||||||
"websocket:default",
|
|
||||||
"deep-link:default",
|
|
||||||
"shell:default",
|
"shell:default",
|
||||||
"shell:allow-open"
|
"shell:allow-open"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-secret":{"identifier":"allow-write-secret","description":"Enables the write_secret command without any pre-configured scope.","commands":{"allow":["write_secret"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-secret":{"identifier":"deny-write-secret","description":"Denies the write_secret command without any pre-configured scope.","commands":{"allow":[],"deny":["write_secret"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-exit":{"identifier":"allow-exit","description":"Enables the exit command without any pre-configured scope.","commands":{"allow":["exit"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","coLine truncated
|
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-secret":{"identifier":"allow-write-secret","description":"Enables the write_secret command without any pre-configured scope.","commands":{"allow":["write_secret"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-secret":{"identifier":"deny-write-secret","description":"Denies the write_secret command without any pre-configured scope.","commands":{"allow":[],"deny":["write_secret"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-exit":{"identifier":"allow-exit","description":"Enables the exit command without any pre-configured scope.","commands":{"allow":["exit"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","coLine truncated
|
||||||
@@ -1 +1 @@
|
|||||||
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"windows":["main"],"permissions":["window-state:default","global-shortcut:default","global-shortcut:allow-is-registered","global-shortcut:allow-register","global-shortcut:allow-unregister","websocket:default","shell:default"],"platforms":["macOS","windows","linux"]},"main-capabilities":{"identifier":"main-capabilities","description":"Capability for desktop window","local":true,"windows":["main"],"permissions":["store:allow-get","store:allow-set","store:allow-save","store:allow-clear","store:allow-delete","store:allow-keys","store:allow-load","updater:allow-check","updater:allow-download-and-install","updater:allow-download","updater:allow-install","notification:default","core:webview:allow-internal-toggle-devtools","core:window:allow-start-dragging","core:window:allow-start-resize-dragging","core:window:allow-minimize","core:window:allow-maximize","core:window:allow-unmaximize","core:window:allow-toggle-maximize","core:window:allow-close","core:window:allow-is-maximized","dialog:default","upload:allow-download","clipboard-manager:allow-write-text","websocket:default","deep-link:default","shell:default","shell:allow-open"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-fullscreen","shell:default"]}}
|
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"windows":["main"],"permissions":["window-state:default","global-shortcut:default","global-shortcut:allow-is-registered","global-shortcut:allow-register","global-shortcut:allow-unregister","shell:default"],"platforms":["macOS","windows","linux"]},"main-capabilities":{"identifier":"main-capabilities","description":"Capability for desktop window","local":true,"windows":["main"],"permissions":["store:allow-get","store:allow-set","store:allow-save","store:allow-clear","store:allow-delete","store:allow-keys","store:allow-load","updater:allow-check","updater:allow-download-and-install","updater:allow-download","updater:allow-install","notification:default","core:webview:allow-internal-toggle-devtools","dialog:default","upload:allow-download","clipboard-manager:allow-write-text","shell:default","shell:allow-open"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-fullscreen","shell:default"]}}
|
||||||
@@ -2516,60 +2516,6 @@
|
|||||||
"const": "core:window:deny-unminimize",
|
"const": "core:window:deny-unminimize",
|
||||||
"markdownDescription": "Denies the unminimize command without any pre-configured scope."
|
"markdownDescription": "Denies the unminimize command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"description": "Allows reading the opened deep link via the get_current command\n#### This default permission set includes:\n\n- `allow-get-current`",
|
|
||||||
"type": "string",
|
|
||||||
"const": "deep-link:default",
|
|
||||||
"markdownDescription": "Allows reading the opened deep link via the get_current command\n#### This default permission set includes:\n\n- `allow-get-current`"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the get_current command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "deep-link:allow-get-current",
|
|
||||||
"markdownDescription": "Enables the get_current command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the is_registered command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "deep-link:allow-is-registered",
|
|
||||||
"markdownDescription": "Enables the is_registered command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the register command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "deep-link:allow-register",
|
|
||||||
"markdownDescription": "Enables the register command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the unregister command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "deep-link:allow-unregister",
|
|
||||||
"markdownDescription": "Enables the unregister command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the get_current command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "deep-link:deny-get-current",
|
|
||||||
"markdownDescription": "Denies the get_current command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the is_registered command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "deep-link:deny-is-registered",
|
|
||||||
"markdownDescription": "Denies the is_registered command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the register command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "deep-link:deny-register",
|
|
||||||
"markdownDescription": "Denies the register command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the unregister command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "deep-link:deny-unregister",
|
|
||||||
"markdownDescription": "Denies the unregister command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"description": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n\n#### This default permission set includes:\n\n- `allow-message`\n- `allow-save`\n- `allow-open`",
|
"description": "This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n\n#### This default permission set includes:\n\n- `allow-message`\n- `allow-save`\n- `allow-open`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -2720,168 +2666,6 @@
|
|||||||
"const": "log:deny-log",
|
"const": "log:deny-log",
|
||||||
"markdownDescription": "Denies the log command without any pre-configured scope."
|
"markdownDescription": "Denies the log command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"description": "Default permissions for MCP Bridge plugin\n#### This default permission set includes:\n\n- `allow-capture-native-screenshot`\n- `allow-emit-event`\n- `allow-execute-command`\n- `allow-execute-js`\n- `allow-get-backend-state`\n- `allow-get-ipc-events`\n- `allow-get-window-info`\n- `allow-list-windows`\n- `allow-report-ipc-event`\n- `allow-request-script-injection`\n- `allow-script-result`\n- `allow-start-ipc-monitor`\n- `allow-stop-ipc-monitor`",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:default",
|
|
||||||
"markdownDescription": "Default permissions for MCP Bridge plugin\n#### This default permission set includes:\n\n- `allow-capture-native-screenshot`\n- `allow-emit-event`\n- `allow-execute-command`\n- `allow-execute-js`\n- `allow-get-backend-state`\n- `allow-get-ipc-events`\n- `allow-get-window-info`\n- `allow-list-windows`\n- `allow-report-ipc-event`\n- `allow-request-script-injection`\n- `allow-script-result`\n- `allow-start-ipc-monitor`\n- `allow-stop-ipc-monitor`"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the capture_native_screenshot command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-capture-native-screenshot",
|
|
||||||
"markdownDescription": "Enables the capture_native_screenshot command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the emit_event command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-emit-event",
|
|
||||||
"markdownDescription": "Enables the emit_event command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the execute_command command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-execute-command",
|
|
||||||
"markdownDescription": "Enables the execute_command command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the execute_js command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-execute-js",
|
|
||||||
"markdownDescription": "Enables the execute_js command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the get_backend_state command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-get-backend-state",
|
|
||||||
"markdownDescription": "Enables the get_backend_state command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the get_ipc_events command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-get-ipc-events",
|
|
||||||
"markdownDescription": "Enables the get_ipc_events command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the get_window_info command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-get-window-info",
|
|
||||||
"markdownDescription": "Enables the get_window_info command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the list_windows command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-list-windows",
|
|
||||||
"markdownDescription": "Enables the list_windows command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the report_ipc_event command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-report-ipc-event",
|
|
||||||
"markdownDescription": "Enables the report_ipc_event command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the request_script_injection command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-request-script-injection",
|
|
||||||
"markdownDescription": "Enables the request_script_injection command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the script_result command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-script-result",
|
|
||||||
"markdownDescription": "Enables the script_result command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the start_ipc_monitor command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-start-ipc-monitor",
|
|
||||||
"markdownDescription": "Enables the start_ipc_monitor command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the stop_ipc_monitor command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:allow-stop-ipc-monitor",
|
|
||||||
"markdownDescription": "Enables the stop_ipc_monitor command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the capture_native_screenshot command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-capture-native-screenshot",
|
|
||||||
"markdownDescription": "Denies the capture_native_screenshot command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the emit_event command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-emit-event",
|
|
||||||
"markdownDescription": "Denies the emit_event command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the execute_command command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-execute-command",
|
|
||||||
"markdownDescription": "Denies the execute_command command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the execute_js command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-execute-js",
|
|
||||||
"markdownDescription": "Denies the execute_js command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the get_backend_state command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-get-backend-state",
|
|
||||||
"markdownDescription": "Denies the get_backend_state command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the get_ipc_events command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-get-ipc-events",
|
|
||||||
"markdownDescription": "Denies the get_ipc_events command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the get_window_info command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-get-window-info",
|
|
||||||
"markdownDescription": "Denies the get_window_info command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the list_windows command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-list-windows",
|
|
||||||
"markdownDescription": "Denies the list_windows command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the report_ipc_event command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-report-ipc-event",
|
|
||||||
"markdownDescription": "Denies the report_ipc_event command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the request_script_injection command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-request-script-injection",
|
|
||||||
"markdownDescription": "Denies the request_script_injection command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the script_result command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-script-result",
|
|
||||||
"markdownDescription": "Denies the script_result command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the start_ipc_monitor command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-start-ipc-monitor",
|
|
||||||
"markdownDescription": "Denies the start_ipc_monitor command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the stop_ipc_monitor command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "mcp-bridge:deny-stop-ipc-monitor",
|
|
||||||
"markdownDescription": "Denies the stop_ipc_monitor command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"description": "This permission set configures which\nnotification features are by default exposed.\n\n#### Granted Permissions\n\nIt allows all notification related features.\n\n\n#### This default permission set includes:\n\n- `allow-is-permission-granted`\n- `allow-request-permission`\n- `allow-notify`\n- `allow-register-action-types`\n- `allow-register-listener`\n- `allow-remove-listener`\n- `allow-cancel`\n- `allow-get-pending`\n- `allow-remove-active`\n- `allow-get-active`\n- `allow-check-permissions`\n- `allow-show`\n- `allow-batch`\n- `allow-list-channels`\n- `allow-delete-channel`\n- `allow-create-channel`\n- `allow-permission-state`",
|
"description": "This permission set configures which\nnotification features are by default exposed.\n\n#### Granted Permissions\n\nIt allows all notification related features.\n\n\n#### This default permission set includes:\n\n- `allow-is-permission-granted`\n- `allow-request-permission`\n- `allow-notify`\n- `allow-register-action-types`\n- `allow-register-listener`\n- `allow-remove-listener`\n- `allow-cancel`\n- `allow-get-pending`\n- `allow-remove-active`\n- `allow-get-active`\n- `allow-check-permissions`\n- `allow-show`\n- `allow-batch`\n- `allow-list-channels`\n- `allow-delete-channel`\n- `allow-create-channel`\n- `allow-permission-state`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -3446,36 +3230,6 @@
|
|||||||
"const": "upload:deny-upload",
|
"const": "upload:deny-upload",
|
||||||
"markdownDescription": "Denies the upload command without any pre-configured scope."
|
"markdownDescription": "Denies the upload command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"description": "Allows connecting and sending data to a WebSocket server\n#### This default permission set includes:\n\n- `allow-connect`\n- `allow-send`",
|
|
||||||
"type": "string",
|
|
||||||
"const": "websocket:default",
|
|
||||||
"markdownDescription": "Allows connecting and sending data to a WebSocket server\n#### This default permission set includes:\n\n- `allow-connect`\n- `allow-send`"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the connect command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "websocket:allow-connect",
|
|
||||||
"markdownDescription": "Enables the connect command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Enables the send command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "websocket:allow-send",
|
|
||||||
"markdownDescription": "Enables the send command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the connect command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "websocket:deny-connect",
|
|
||||||
"markdownDescription": "Denies the connect command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Denies the send command without any pre-configured scope.",
|
|
||||||
"type": "string",
|
|
||||||
"const": "websocket:deny-send",
|
|
||||||
"markdownDescription": "Denies the send command without any pre-configured scope."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"description": "This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-filename`\n- `allow-restore-state`\n- `allow-save-window-state`",
|
"description": "This permission set configures what kind of\noperations are available from the window state plugin.\n\n#### Granted Permissions\n\nAll operations are enabled by default.\n\n\n#### This default permission set includes:\n\n- `allow-filename`\n- `allow-restore-state`\n- `allow-save-window-state`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
+1
-25
@@ -3,29 +3,7 @@
|
|||||||
use tauri_plugin_log::{fern::colors::ColoredLevelConfig, Target, TargetKind};
|
use tauri_plugin_log::{fern::colors::ColoredLevelConfig, Target, TargetKind};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let builder = tauri::Builder::default();
|
tauri::Builder::default()
|
||||||
|
|
||||||
// Dev-only MCP bridge: `pnpm tauri dev -- --features mcp-bridge`.
|
|
||||||
#[cfg(all(debug_assertions, feature = "mcp-bridge"))]
|
|
||||||
let builder = builder.plugin(
|
|
||||||
tauri_plugin_mcp_bridge::Builder::new()
|
|
||||||
.bind_address("127.0.0.1")
|
|
||||||
.build(),
|
|
||||||
);
|
|
||||||
|
|
||||||
builder
|
|
||||||
.setup(|_app| {
|
|
||||||
// Frameless window outside macOS. macOS uses the native overlay
|
|
||||||
// titlebar with its traffic lights.
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
{
|
|
||||||
use tauri::Manager;
|
|
||||||
if let Some(window) = _app.get_webview_window("main") {
|
|
||||||
window.set_decorations(false)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||||
.plugin(tauri_plugin_window_state::Builder::new().build())
|
.plugin(tauri_plugin_window_state::Builder::new().build())
|
||||||
@@ -33,8 +11,6 @@ fn main() {
|
|||||||
.plugin(tauri_plugin_upload::init())
|
.plugin(tauri_plugin_upload::init())
|
||||||
.plugin(tauri_plugin_notification::init())
|
.plugin(tauri_plugin_notification::init())
|
||||||
.plugin(tauri_plugin_clipboard_manager::init())
|
.plugin(tauri_plugin_clipboard_manager::init())
|
||||||
.plugin(tauri_plugin_websocket::init())
|
|
||||||
.plugin(tauri_plugin_deep_link::init())
|
|
||||||
.plugin(
|
.plugin(
|
||||||
tauri_plugin_log::Builder::default()
|
tauri_plugin_log::Builder::default()
|
||||||
.targets([Target::new(TargetKind::Webview)])
|
.targets([Target::new(TargetKind::Webview)])
|
||||||
|
|||||||
@@ -54,11 +54,6 @@
|
|||||||
"version": "../package.json",
|
"version": "../package.json",
|
||||||
"identifier": "com.blink.prayag17",
|
"identifier": "com.blink.prayag17",
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"deep-link": {
|
|
||||||
"desktop": {
|
|
||||||
"schemes": ["blink"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"updater": {
|
"updater": {
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZBOTJGNzM3REU2Q0JEMEYKUldRUHZXemVOL2VTK2k2andMWTZYbEN6SnIwV0V0L2Z3NlA4RzFabThPaXRqSFRMc004WGhCb2kK",
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZBOTJGNzM3REU2Q0JEMEYKUldRUHZXemVOL2VTK2k2andMWTZYbEN6SnIwV0V0L2Z3NlA4RzFabThPaXRqSFRMc004WGhCb2kK",
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
@@ -82,10 +77,7 @@
|
|||||||
"label": "main",
|
"label": "main",
|
||||||
"dragDropEnabled": false,
|
"dragDropEnabled": false,
|
||||||
"backgroundColor": "#08001f",
|
"backgroundColor": "#08001f",
|
||||||
"transparent": false,
|
"transparent": false
|
||||||
"titleBarStyle": "Overlay",
|
|
||||||
"hiddenTitle": true,
|
|
||||||
"trafficLightPosition": { "x": 18, "y": 31 }
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
await setServer(bestServer.systemInfo?.Id ?? "", bestServer);
|
await setServer(bestServer.systemInfo?.Id ?? "", bestServer);
|
||||||
setAddServerDialog(false);
|
setAddServerDialog(false);
|
||||||
enqueueSnackbar(
|
enqueueSnackbar(
|
||||||
"Сервер добавлен. Возможно, потребуется обновить список серверов.",
|
"Client added successfully. You might need to refresh client list.",
|
||||||
{
|
{
|
||||||
variant: "success",
|
variant: "success",
|
||||||
},
|
},
|
||||||
@@ -50,11 +50,11 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
onError: (err) => {
|
onError: (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
enqueueSnackbar(`${err}`, { variant: "error" });
|
enqueueSnackbar(`${err}`, { variant: "error" });
|
||||||
enqueueSnackbar("Что-то пошло не так", { variant: "error" });
|
enqueueSnackbar("Something went wrong", { variant: "error" });
|
||||||
},
|
},
|
||||||
onSettled: async (bestServer) => {
|
onSettled: async (bestServer) => {
|
||||||
if (!bestServer) {
|
if (!bestServer) {
|
||||||
enqueueSnackbar("Указанный адрес не является сервером Jellyfin.", {
|
enqueueSnackbar("Provided server address is not a Jellyfin server.", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Подключиться к серверу
|
Connect to Server
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="body2"
|
variant="body2"
|
||||||
@@ -121,7 +121,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Введите адрес сервера Jellyfin, чтобы продолжить
|
Enter your Jellyfin server address to continue
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
variant="text"
|
variant="text"
|
||||||
sx={{ borderRadius: 2 }}
|
sx={{ borderRadius: 2 }}
|
||||||
>
|
>
|
||||||
Отмена
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
loading={addServer.isPending}
|
loading={addServer.isPending}
|
||||||
@@ -184,7 +184,7 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
|||||||
sx={{ borderRadius: 2, px: 3 }}
|
sx={{ borderRadius: 2, px: 3 }}
|
||||||
disabled={!serverIp}
|
disabled={!serverIp}
|
||||||
>
|
>
|
||||||
Подключиться
|
Connect
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
|||||||
) => {
|
) => {
|
||||||
if (!user?.Id || !api) {
|
if (!user?.Id || !api) {
|
||||||
console.error("User not logged in");
|
console.error("User not logged in");
|
||||||
enqueueSnackbar("Войдите, чтобы слушать музыку", {
|
enqueueSnackbar("You need to be logged in to play music", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -96,7 +96,7 @@ export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
|||||||
fontWeight: 300,
|
fontWeight: 300,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{track.HasLyrics && <img src={lyricsIcon} alt="Текст песни" />}
|
{track.HasLyrics && <img src={lyricsIcon} alt="lyrics" />}
|
||||||
{track.Artists?.join(", ")}
|
{track.Artists?.join(", ")}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ export const AlphaSelector = React.memo(function AlphaSelector() {
|
|||||||
const arr = Array.from({ length: 26 }, (_, i) =>
|
const arr = Array.from({ length: 26 }, (_, i) =>
|
||||||
String.fromCharCode(65 + i),
|
String.fromCharCode(65 + i),
|
||||||
);
|
);
|
||||||
return ["Все", ...arr];
|
return ["All", ...arr];
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleSelect = (letter: string) => {
|
const handleSelect = (letter: string) => {
|
||||||
const value = letter === "Все" ? undefined : letter;
|
const value = letter === "All" ? undefined : letter;
|
||||||
if (currentLibraryId)
|
if (currentLibraryId)
|
||||||
updateLibrary(currentLibraryId, { nameStartsWith: value });
|
updateLibrary(currentLibraryId, { nameStartsWith: value });
|
||||||
};
|
};
|
||||||
@@ -31,13 +31,13 @@ export const AlphaSelector = React.memo(function AlphaSelector() {
|
|||||||
return (
|
return (
|
||||||
<div className="alpha-selector">
|
<div className="alpha-selector">
|
||||||
{letters.map((l) => {
|
{letters.map((l) => {
|
||||||
const active = (nameStartsWith || "Все") === l;
|
const active = (nameStartsWith || "All") === l;
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={l}
|
key={l}
|
||||||
className={active ? "alpha-letter active" : "alpha-letter"}
|
className={active ? "alpha-letter active" : "alpha-letter"}
|
||||||
onClick={() => handleSelect(l)}
|
onClick={() => handleSelect(l)}
|
||||||
aria-label={`Фильтр по букве ${l}`}
|
aria-label={`Filter by ${l}`}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
{l}
|
{l}
|
||||||
|
|||||||
@@ -1,52 +1,50 @@
|
|||||||
|
|
||||||
.appBar {
|
.appBar {
|
||||||
// Custom titlebar: the app header itself sits at the very top of the window,
|
// Limit transitions to cheaper properties; avoid animating box-shadow directly
|
||||||
// under the native overlay titlebar (no native glass strip, no blur panels).
|
|
||||||
transition: background-color $transition-time-fast;
|
transition: background-color $transition-time-fast;
|
||||||
// Same vertical rhythm as the home page header so every page's controls
|
padding: 0.8em ($page-margin - 1.7em);
|
||||||
// sit on one consistent level.
|
|
||||||
padding: 1.3rem ($page-margin - 1.7em);
|
|
||||||
z-index: 999 !important;
|
z-index: 999 !important;
|
||||||
top: 0 !important;
|
|
||||||
|
|
||||||
// Keep the left controls clear of the macOS traffic lights and put the
|
|
||||||
// header row on the same level as them.
|
|
||||||
html.is-macos & {
|
|
||||||
padding-top: 0.6rem;
|
|
||||||
padding-left: calc(#{$page-margin} - 1.7em + 72px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.flex {
|
.flex {
|
||||||
// Avoid animating padding; it causes layout reflow on each frame.
|
// Avoid animating padding; it causes layout reflow on each frame.
|
||||||
transition: background-color $transition-time-fast;
|
transition: background-color $transition-time-fast;
|
||||||
|
// Avoid using will-change: scroll-position; it can degrade performance when misused
|
||||||
|
// will-change: opacity, transform;
|
||||||
border-radius: 1000px;
|
border-radius: 1000px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
|
||||||
|
|
||||||
// Solid, part-of-the-screen titlebar background once the page scrolls.
|
// Pseudo-element handles elevation shadow; we animate its opacity
|
||||||
&.elevated {
|
&::after {
|
||||||
background-color: $clr-background-default !important;
|
content: "";
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.06);
|
|
||||||
box-shadow: none !important;
|
|
||||||
background-image: none !important;
|
|
||||||
backdrop-filter: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-title {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
inset: -0.35em;
|
||||||
top: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
max-width: min(38vw, 520px);
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
color: rgb(255 255 255 / 0.72);
|
|
||||||
font-size: 0.9rem !important;
|
|
||||||
font-weight: 500 !important;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
border-radius: inherit;
|
||||||
|
|
||||||
|
@include glass-effect;
|
||||||
|
|
||||||
|
opacity: 0;
|
||||||
|
z-index: -1;
|
||||||
|
transition: all $transition-time-fast;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inner content wrapper that we can scale without causing layout reflow
|
||||||
|
.flex-inner {
|
||||||
|
transform-origin: top center;
|
||||||
|
transition: transform $transition-time-fast;
|
||||||
|
}
|
||||||
|
&.elevated{
|
||||||
|
.flex {
|
||||||
|
&::after {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply a subtle scale to simulate shrink without layout changes
|
||||||
|
.flex-inner {
|
||||||
|
transform: scaleY(0.95);
|
||||||
|
}
|
||||||
|
}
|
||||||
&-avatar {
|
&-avatar {
|
||||||
background: rgb(255 255 255 / 0.1) !important;
|
background: rgb(255 255 255 / 0.1) !important;
|
||||||
&-icon {
|
&-icon {
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
import MuiAppBar from "@mui/material/AppBar";
|
import MuiAppBar from "@mui/material/AppBar";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||||
import React, { useCallback, useState } from "react";
|
import React, { useCallback, useMemo, useState } from "react";
|
||||||
|
|
||||||
import "./appBar.scss";
|
import "./appBar.scss";
|
||||||
|
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
// removed search placeholder; library state now managed via zustand
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import useHeaderStore from "@/utils/store/header";
|
import useHeaderStore from "@/utils/store/header";
|
||||||
import useSearchStore from "@/utils/store/search";
|
import useSearchStore from "@/utils/store/search";
|
||||||
import BackButton from "../buttons/backButton";
|
import BackButton from "../buttons/backButton";
|
||||||
import CastButton from "../buttons/castButton";
|
|
||||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||||
import { NavigationDrawer } from "./navigationDrawer";
|
import { NavigationDrawer } from "./navigationDrawer";
|
||||||
import WindowControls from "../windowControls";
|
|
||||||
|
|
||||||
const MemoizeBackButton = React.memo(BackButton);
|
const MemoizeBackButton = React.memo(BackButton);
|
||||||
|
|
||||||
@@ -29,19 +27,9 @@ const HIDDEN_PATHS = [
|
|||||||
"/settings",
|
"/settings",
|
||||||
"/library",
|
"/library",
|
||||||
"/search",
|
"/search",
|
||||||
// The home page draws its own header inside the hero frame.
|
|
||||||
"/home",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/** Whether the global app header is drawn for this route. */
|
export const AppBar = () => {
|
||||||
export const shouldShowAppBar = (pathname: string) =>
|
|
||||||
!HIDDEN_PATHS.some(
|
|
||||||
(path) =>
|
|
||||||
(pathname.startsWith(path) && pathname !== "/player/audio") ||
|
|
||||||
pathname === "/",
|
|
||||||
);
|
|
||||||
|
|
||||||
const AppBarContent = () => {
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
@@ -49,7 +37,13 @@ const AppBarContent = () => {
|
|||||||
useShallow((s) => s.toggleSearchDialog),
|
useShallow((s) => s.toggleSearchDialog),
|
||||||
);
|
);
|
||||||
|
|
||||||
// This hook subscribes to page scroll; keep it out of hidden routes.
|
const display = !HIDDEN_PATHS.some(
|
||||||
|
(path) =>
|
||||||
|
(location.pathname.startsWith(path) &&
|
||||||
|
location.pathname !== "/player/audio") ||
|
||||||
|
location.pathname === "/",
|
||||||
|
);
|
||||||
|
|
||||||
const trigger = useScrollTrigger({
|
const trigger = useScrollTrigger({
|
||||||
disableHysteresis: true,
|
disableHysteresis: true,
|
||||||
threshold: 20,
|
threshold: 20,
|
||||||
@@ -57,6 +51,18 @@ const AppBarContent = () => {
|
|||||||
|
|
||||||
const [showDrawer, setShowDrawer] = useState(false);
|
const [showDrawer, setShowDrawer] = useState(false);
|
||||||
|
|
||||||
|
const appBarStyling = useMemo(() => {
|
||||||
|
return {
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
paddingRight: "0 !important",
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const _handleNavigateToSearch = useCallback(
|
||||||
|
() => navigate({ to: "/search", search: { query: "" } }),
|
||||||
|
[navigate],
|
||||||
|
);
|
||||||
|
|
||||||
const handleDrawerClose = useCallback(() => {
|
const handleDrawerClose = useCallback(() => {
|
||||||
setShowDrawer(false);
|
setShowDrawer(false);
|
||||||
}, []);
|
}, []);
|
||||||
@@ -70,23 +76,16 @@ const AppBarContent = () => {
|
|||||||
navigate({ to: "/favorite" });
|
navigate({ to: "/favorite" });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const { pageTitle } = useHeaderStore(
|
useHeaderStore(useShallow((s) => ({ pageTitle: s.pageTitle })));
|
||||||
useShallow((s) => ({ pageTitle: s.pageTitle })),
|
|
||||||
);
|
|
||||||
|
|
||||||
const fallbackTitle = (() => {
|
|
||||||
const path = location.pathname;
|
|
||||||
if (path === "/favorite") return "Избранное";
|
|
||||||
if (path.startsWith("/music/")) return "Музыка";
|
|
||||||
if (path.startsWith("/player/audio")) return "Сейчас играет";
|
|
||||||
return "";
|
|
||||||
})();
|
|
||||||
const title = pageTitle || fallbackTitle;
|
|
||||||
|
|
||||||
|
if (!display) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (display) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<MuiAppBar
|
<MuiAppBar
|
||||||
data-tauri-drag-region
|
style={appBarStyling}
|
||||||
className={
|
className={
|
||||||
trigger
|
trigger
|
||||||
? "appBar flex flex-row flex-justify-spaced-between elevated"
|
? "appBar flex flex-row flex-justify-spaced-between elevated"
|
||||||
@@ -95,19 +94,12 @@ const AppBarContent = () => {
|
|||||||
elevation={0}
|
elevation={0}
|
||||||
color="transparent"
|
color="transparent"
|
||||||
>
|
>
|
||||||
<div
|
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||||
className="flex flex-row"
|
<IconButton onClick={handleDrawerOpen}>
|
||||||
data-tauri-drag-region
|
|
||||||
style={{ gap: "0.6em" }}
|
|
||||||
>
|
|
||||||
<Tooltip title="Открыть меню">
|
|
||||||
<IconButton onClick={handleDrawerOpen} aria-label="Открыть меню">
|
|
||||||
<span className="material-symbols-rounded">menu</span>
|
<span className="material-symbols-rounded">menu</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
|
||||||
<MemoizeBackButton />
|
<MemoizeBackButton />
|
||||||
<Tooltip title="Главная">
|
<IconButton onClick={handleNavigateToHome}>
|
||||||
<IconButton onClick={handleNavigateToHome} aria-label="Главная">
|
|
||||||
<span
|
<span
|
||||||
className={
|
className={
|
||||||
location.pathname === "/home"
|
location.pathname === "/home"
|
||||||
@@ -118,53 +110,20 @@ const AppBarContent = () => {
|
|||||||
home
|
home
|
||||||
</span>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{title && (
|
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||||
<Typography className="appBar-title" noWrap>
|
<IconButton onClick={toggleSearchDialog}>
|
||||||
{title}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div
|
|
||||||
className="flex flex-row"
|
|
||||||
data-tauri-drag-region
|
|
||||||
style={{ gap: "0.6em" }}
|
|
||||||
>
|
|
||||||
<Tooltip title="Смотреть вместе">
|
|
||||||
<IconButton
|
|
||||||
onClick={openSyncPlayDialog}
|
|
||||||
aria-label="Смотреть вместе"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">groups</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<CastButton />
|
|
||||||
<Tooltip title="Поиск">
|
|
||||||
<IconButton onClick={toggleSearchDialog} aria-label="Поиск">
|
|
||||||
<span className="material-symbols-rounded">search</span>
|
<span className="material-symbols-rounded">search</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
<IconButton onClick={handleNavigateToFavorite}>
|
||||||
<Tooltip title="Избранное">
|
|
||||||
<IconButton
|
|
||||||
onClick={handleNavigateToFavorite}
|
|
||||||
aria-label="Избранное"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">favorite</span>
|
<span className="material-symbols-rounded">favorite</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
|
||||||
<UserAvatarMenu />
|
<UserAvatarMenu />
|
||||||
<WindowControls />
|
|
||||||
</div>
|
</div>
|
||||||
</MuiAppBar>
|
</MuiAppBar>
|
||||||
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
export const AppBar = () => {
|
|
||||||
const location = useLocation();
|
|
||||||
if (!shouldShowAppBar(location.pathname)) return null;
|
|
||||||
return <AppBarContent />;
|
|
||||||
};
|
};
|
||||||
@@ -23,7 +23,7 @@ export default function AppBarBackOnly() {
|
|||||||
edge="start"
|
edge="start"
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
aria-label="Назад"
|
aria-label="back"
|
||||||
disabled={history.length <= 1}
|
disabled={history.length <= 1}
|
||||||
onClick={handleBack}
|
onClick={handleBack}
|
||||||
sx={{ mr: 2 }}
|
sx={{ mr: 2 }}
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
import { getUserViewApi } from "@jellyfin/sdk/lib/utils/api/user-view-api";
|
import { getUserViewApi } from "@jellyfin/sdk/lib/utils/api/user-view-api";
|
||||||
import {
|
import { Divider, Drawer, List, ListItem, ListItemButton } from "@mui/material";
|
||||||
Divider,
|
|
||||||
Drawer,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
ListItemButton,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import React, { useEffect, useMemo } from "react";
|
import React, { useMemo } from "react";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import ListItemLink from "../listItemLink";
|
import ListItemLink from "../listItemLink";
|
||||||
@@ -21,7 +14,7 @@ interface NavigationDrawerProps {
|
|||||||
|
|
||||||
export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const [user] = useCentralStore((s) => [s.currentUser]);
|
||||||
|
|
||||||
const libraries = useQuery({
|
const libraries = useQuery({
|
||||||
queryKey: ["libraries"],
|
queryKey: ["libraries"],
|
||||||
@@ -38,13 +31,6 @@ export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
|||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Libraries can be added on the server while the app is running; refresh
|
|
||||||
// the view list every time the drawer opens so they show up without restart.
|
|
||||||
const refetchLibraries = libraries.refetch;
|
|
||||||
useEffect(() => {
|
|
||||||
if (open) refetchLibraries();
|
|
||||||
}, [open, refetchLibraries]);
|
|
||||||
|
|
||||||
const drawerPaperProps = useMemo(() => {
|
const drawerPaperProps = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
className: "glass library-drawer",
|
className: "glass library-drawer",
|
||||||
@@ -63,38 +49,17 @@ export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
|||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemButton onClick={onClose}>
|
<ListItemButton onClick={onClose}>
|
||||||
<span className="material-symbols-rounded">menu_open</span>
|
<span className="material-symbols-rounded">menu_open</span>
|
||||||
<div style={{ marginLeft: "8px" }}>Закрыть</div>
|
<div style={{ marginLeft: "8px" }}>Close</div>
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
<Divider variant="middle" />
|
<Divider variant="middle" />
|
||||||
<Typography
|
|
||||||
variant="overline"
|
|
||||||
sx={{ display: "block", px: 2, pt: 1.5, opacity: 0.55 }}
|
|
||||||
>
|
|
||||||
Обзор
|
|
||||||
</Typography>
|
|
||||||
<List>
|
<List>
|
||||||
<ListItemLink
|
<ListItemLink
|
||||||
className="library-drawer-item"
|
className="library-drawer-item"
|
||||||
to="/home"
|
to="/home"
|
||||||
icon="home"
|
icon="home"
|
||||||
primary="Главная"
|
primary="Home"
|
||||||
onClick={onClose}
|
|
||||||
/>
|
|
||||||
<ListItemLink
|
|
||||||
className="library-drawer-item"
|
|
||||||
to="/search"
|
|
||||||
search={{ query: "" }}
|
|
||||||
icon="search"
|
|
||||||
primary="Поиск"
|
|
||||||
onClick={onClose}
|
|
||||||
/>
|
|
||||||
<ListItemLink
|
|
||||||
className="library-drawer-item"
|
|
||||||
to="/favorite"
|
|
||||||
icon="favorite"
|
|
||||||
primary="Избранное"
|
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
/>
|
/>
|
||||||
{libraries.isSuccess &&
|
{libraries.isSuccess &&
|
||||||
@@ -107,37 +72,31 @@ export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
|||||||
icon={
|
icon={
|
||||||
library.CollectionType && getTypeIcon(library.CollectionType)
|
library.CollectionType && getTypeIcon(library.CollectionType)
|
||||||
}
|
}
|
||||||
primary={library.Name ?? "Библиотека"}
|
primary={library.Name ?? "Library"}
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
<Divider variant="middle" />
|
<Divider variant="middle" />
|
||||||
<Typography
|
|
||||||
variant="overline"
|
|
||||||
sx={{ display: "block", px: 2, pt: 1.5, opacity: 0.55 }}
|
|
||||||
>
|
|
||||||
Настройки
|
|
||||||
</Typography>
|
|
||||||
<List>
|
<List>
|
||||||
<ListItemLink
|
<ListItemLink
|
||||||
to="/settings/preferences"
|
to="/settings/preferences"
|
||||||
icon="settings"
|
icon="settings"
|
||||||
primary="Настройки"
|
primary="Settings"
|
||||||
className="library-drawer-item"
|
className="library-drawer-item"
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
/>
|
/>
|
||||||
<ListItemLink
|
<ListItemLink
|
||||||
to="/settings/changeServer"
|
to="/settings/changeServer"
|
||||||
icon="dns"
|
icon="dns"
|
||||||
primary="Сменить сервер"
|
primary="Change Server"
|
||||||
className="library-drawer-item"
|
className="library-drawer-item"
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
/>
|
/>
|
||||||
<ListItemLink
|
<ListItemLink
|
||||||
to="/settings/about"
|
to="/settings/about"
|
||||||
icon="info"
|
icon="info"
|
||||||
primary="О приложении"
|
primary="About"
|
||||||
className="library-drawer-item"
|
className="library-drawer-item"
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,20 +5,15 @@ import { useBackdropStore } from "@/utils/store/backdrop";
|
|||||||
import BlurhashCanvas from "../blurhash-canvas";
|
import BlurhashCanvas from "../blurhash-canvas";
|
||||||
|
|
||||||
export default function Backdrop() {
|
export default function Backdrop() {
|
||||||
|
// const [backdropLoading, setBackdropLoading] = useState(true);
|
||||||
|
|
||||||
const { backdropHash } = useBackdropStore(
|
const { backdropHash } = useBackdropStore(
|
||||||
useShallow((state) => ({
|
useShallow((state) => ({
|
||||||
backdropHash: state.backdropHash,
|
backdropHash: state.backdropHash,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Routes clear the backdrop when they mount ("") and some set it later.
|
if (!backdropHash) {
|
||||||
// Keep the last non-empty hash so the app background never blanks out
|
|
||||||
// (which looked like a flash on every page open).
|
|
||||||
const lastHash = React.useRef<string | undefined>(undefined);
|
|
||||||
if (backdropHash) lastHash.current = backdropHash;
|
|
||||||
const hash = backdropHash || lastHash.current;
|
|
||||||
|
|
||||||
if (!hash) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,16 +22,16 @@ export default function Backdrop() {
|
|||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
key={hash}
|
key={backdropHash}
|
||||||
exit={{ opacity: 0 }}
|
exit={{ opacity: 0 }}
|
||||||
transition={{
|
transition={{
|
||||||
duration: 0.45,
|
duration: 2,
|
||||||
ease: "easeInOut",
|
ease: "easeInOut",
|
||||||
}}
|
}}
|
||||||
className="app-backdrop-container"
|
className="app-backdrop-container"
|
||||||
>
|
>
|
||||||
<BlurhashCanvas
|
<BlurhashCanvas
|
||||||
blurhashString={hash}
|
blurhashString={backdropHash}
|
||||||
width={300}
|
width={300}
|
||||||
height={150}
|
height={150}
|
||||||
canvasProps={{
|
canvasProps={{
|
||||||
|
|||||||
@@ -9,12 +9,7 @@ export default function BackButton() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton onClick={handleClick} disabled={history.length === 0}>
|
||||||
onClick={handleClick}
|
|
||||||
disabled={history.length === 0}
|
|
||||||
aria-label="Назад"
|
|
||||||
title="Назад"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">arrow_back</span>
|
<span className="material-symbols-rounded">arrow_back</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
|
||||||
import React from "react";
|
|
||||||
import useRemoteControlStore, {
|
|
||||||
type RemoteTransfer,
|
|
||||||
} from "@/utils/store/remoteControl";
|
|
||||||
|
|
||||||
type CastButtonProps = {
|
|
||||||
item?: BaseItemDto | null;
|
|
||||||
transfer?: Omit<RemoteTransfer, "item">;
|
|
||||||
/** Computed on click so playback position/queue are current. */
|
|
||||||
getTransfer?: () => Omit<RemoteTransfer, "item">;
|
|
||||||
size?: "small" | "medium" | "large";
|
|
||||||
};
|
|
||||||
|
|
||||||
const CastButton = ({
|
|
||||||
item,
|
|
||||||
transfer,
|
|
||||||
getTransfer,
|
|
||||||
size = "medium",
|
|
||||||
}: CastButtonProps) => {
|
|
||||||
const openDialog = useRemoteControlStore((s) => s.openDialog);
|
|
||||||
return (
|
|
||||||
<Tooltip title={item ? "Воспроизвести на другом устройстве" : "Удалённое управление"}>
|
|
||||||
<IconButton
|
|
||||||
size={size}
|
|
||||||
aria-label={item ? "Воспроизвести на другом устройстве" : "Удалённое управление"}
|
|
||||||
onClick={() =>
|
|
||||||
openDialog({
|
|
||||||
...(getTransfer ? getTransfer() : transfer),
|
|
||||||
item: item ?? null,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">cast</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default CastButton;
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import React, { useState } from "react";
|
|
||||||
import { startInstantMix } from "@/utils/methods/instantMix";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
|
|
||||||
type InstantMixButtonProps = {
|
|
||||||
item?: BaseItemDto | null;
|
|
||||||
/** Render a text button instead of an icon (e.g. on the album page). */
|
|
||||||
withLabel?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const InstantMixButton = ({ item, withLabel = false }: InstantMixButtonProps) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
const [busy, setBusy] = useState(false);
|
|
||||||
|
|
||||||
const handleClick = async () => {
|
|
||||||
if (!api || !user?.Id || !item) return;
|
|
||||||
setBusy(true);
|
|
||||||
try {
|
|
||||||
const { count } = await startInstantMix(api, user.Id, item);
|
|
||||||
if (count === 0) {
|
|
||||||
enqueueSnackbar("Треки для микса не найдены", {
|
|
||||||
variant: "warning",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
enqueueSnackbar(`Микс: ${count} треков`, {
|
|
||||||
variant: "success",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Instant Mix failed", error);
|
|
||||||
enqueueSnackbar("Не удалось запустить микс", { variant: "error" });
|
|
||||||
} finally {
|
|
||||||
setBusy(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tooltip title="Микс">
|
|
||||||
<span>
|
|
||||||
{withLabel ? (
|
|
||||||
<IconButton
|
|
||||||
aria-label="Микс"
|
|
||||||
onClick={handleClick}
|
|
||||||
disabled={busy || !item}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">radio</span>
|
|
||||||
</IconButton>
|
|
||||||
) : (
|
|
||||||
<IconButton
|
|
||||||
aria-label="Микс"
|
|
||||||
onClick={handleClick}
|
|
||||||
disabled={busy || !item}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">radio</span>
|
|
||||||
</IconButton>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default InstantMixButton;
|
|
||||||
@@ -50,7 +50,7 @@ export default function LikeButton({
|
|||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: handleLiking,
|
mutationFn: handleLiking,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar(`Не удалось обновить «${itemName}»`, {
|
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export default function MarkPlayedButton({
|
|||||||
enqueueSnackbar(`${error}`, {
|
enqueueSnackbar(`${error}`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
enqueueSnackbar(`Не удалось обновить «${itemName}»`, {
|
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -90,13 +90,13 @@ const PlayButton = ({
|
|||||||
mutationKey: ["playButton", item?.Id, userId],
|
mutationKey: ["playButton", item?.Id, userId],
|
||||||
mutationFn: async (currentEpisodeId?: string) => {
|
mutationFn: async (currentEpisodeId?: string) => {
|
||||||
if (!api) {
|
if (!api) {
|
||||||
throw new Error("API недоступно");
|
throw new Error("API is not available");
|
||||||
}
|
}
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
throw new Error("Не указан пользователь");
|
throw new Error("User ID is not available");
|
||||||
}
|
}
|
||||||
if (!item.Id) {
|
if (!item.Id) {
|
||||||
throw new Error("Не найден идентификатор элемента");
|
throw new Error("Item ID is not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
return await getPlaybackInfo(api, userId, item, {
|
return await getPlaybackInfo(api, userId, item, {
|
||||||
@@ -109,23 +109,23 @@ const PlayButton = ({
|
|||||||
},
|
},
|
||||||
onSuccess: async (result: PlayResult | null) => {
|
onSuccess: async (result: PlayResult | null) => {
|
||||||
if (!api) {
|
if (!api) {
|
||||||
console.error("API недоступно");
|
console.error("API is not available");
|
||||||
enqueueSnackbar("API недоступно", { variant: "error" });
|
enqueueSnackbar("API is not available", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
console.error("Не указан пользователь");
|
console.error("User ID is not available");
|
||||||
enqueueSnackbar("Не указан пользователь", { variant: "error" });
|
enqueueSnackbar("User ID is not available", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!result?.item?.Items?.length) {
|
if (!result?.item?.Items?.length) {
|
||||||
console.error("Ничего не найдено");
|
console.error("No items found");
|
||||||
enqueueSnackbar("Ничего не найдено", { variant: "error" });
|
enqueueSnackbar("No items found", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!result?.item?.Items?.[0]?.Id) {
|
if (!result?.item?.Items?.[0]?.Id) {
|
||||||
console.error("Не найден идентификатор элемента");
|
console.error("No item ID found");
|
||||||
enqueueSnackbar("Не найден идентификатор элемента", { variant: "error" });
|
enqueueSnackbar("No item ID found", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,8 +148,8 @@ const PlayButton = ({
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
||||||
console.error("Не найден источник медиа");
|
console.error("No media source ID found");
|
||||||
enqueueSnackbar("Не найден источник медиа", { variant: "error" });
|
enqueueSnackbar("No media source ID found", { variant: "error" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const episodeIndex = result.episodeIndex;
|
const episodeIndex = result.episodeIndex;
|
||||||
@@ -195,7 +195,7 @@ const PlayButton = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const handleClick = (
|
const handleClick = (
|
||||||
e: MouseEvent<HTMLElement>,
|
e: MouseEvent<HTMLAnchorElement | MouseEvent>,
|
||||||
currentEpisodeId?: string | undefined,
|
currentEpisodeId?: string | undefined,
|
||||||
) => {
|
) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -205,13 +205,13 @@ const PlayButton = ({
|
|||||||
queryKey: ["playButton", "currentEpisode", item?.Id],
|
queryKey: ["playButton", "currentEpisode", item?.Id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api) {
|
if (!api) {
|
||||||
throw new Error("API недоступно");
|
throw new Error("API is not available");
|
||||||
}
|
}
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
throw new Error("Не указан пользователь");
|
throw new Error("User ID is not available");
|
||||||
}
|
}
|
||||||
if (!item.Id) {
|
if (!item.Id) {
|
||||||
throw new Error("Не найден идентификатор элемента");
|
throw new Error("Item ID is not available");
|
||||||
}
|
}
|
||||||
const seasons = await getShowApi(api).getSeasons({
|
const seasons = await getShowApi(api).getSeasons({
|
||||||
seriesId: item.Id,
|
seriesId: item.Id,
|
||||||
@@ -237,26 +237,12 @@ const PlayButton = ({
|
|||||||
enabled: itemType === BaseItemKind.Series,
|
enabled: itemType === BaseItemKind.Series,
|
||||||
});
|
});
|
||||||
|
|
||||||
const isAudioItem =
|
|
||||||
item?.Type === "MusicAlbum" ||
|
|
||||||
item?.Type === "Audio" ||
|
|
||||||
item?.Type === "AudioBook" ||
|
|
||||||
item?.Type === "Playlist" ||
|
|
||||||
audio;
|
|
||||||
const playLabel = item.UserData?.PlaybackPositionTicks
|
|
||||||
? isAudioItem
|
|
||||||
? "Продолжить прослушивание"
|
|
||||||
: "Продолжить просмотр"
|
|
||||||
: isAudioItem
|
|
||||||
? "Слушать"
|
|
||||||
: "Смотреть";
|
|
||||||
|
|
||||||
if (iconOnly) {
|
if (iconOnly) {
|
||||||
return (
|
return (
|
||||||
//@ts-expect-error
|
//@ts-expect-error
|
||||||
<Fab
|
<Fab
|
||||||
color="primary"
|
color="primary"
|
||||||
aria-label={isAudioItem ? "Слушать" : "Смотреть"}
|
aria-label="Play"
|
||||||
className={className}
|
className={className}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (item.Type === "Episode") {
|
if (item.Type === "Episode") {
|
||||||
@@ -336,14 +322,14 @@ const PlayButton = ({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{currentEpisode.isPending ? (
|
{currentEpisode.isPending ? (
|
||||||
"Загрузка..."
|
"Loading..."
|
||||||
) : !currentEpisode.data ||
|
) : !currentEpisode.data ||
|
||||||
!currentEpisode.data.Items ||
|
!currentEpisode.data.Items ||
|
||||||
currentEpisode.data.Items.length === 0 ? (
|
currentEpisode.data.Items.length === 0 ? (
|
||||||
"Нет серий для просмотра"
|
"No episodes to watch found"
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
Смотреть S{currentEpisode.data.Items[0].ParentIndexNumber ?? 1}E
|
Watch S{currentEpisode.data.Items[0].ParentIndexNumber ?? 1}E
|
||||||
{currentEpisode.data.Items[0]?.IndexNumber ?? 1}
|
{currentEpisode.data.Items[0]?.IndexNumber ?? 1}
|
||||||
<MemoizedLinearProgress
|
<MemoizedLinearProgress
|
||||||
//@ts-expect-error
|
//@ts-expect-error
|
||||||
@@ -377,7 +363,7 @@ const PlayButton = ({
|
|||||||
(currentEpisode.data?.Items?.[0]?.UserData
|
(currentEpisode.data?.Items?.[0]?.UserData
|
||||||
?.PlaybackPositionTicks ?? 0),
|
?.PlaybackPositionTicks ?? 0),
|
||||||
)}{" "}
|
)}{" "}
|
||||||
осталось
|
left
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -417,7 +403,15 @@ const PlayButton = ({
|
|||||||
color="white"
|
color="white"
|
||||||
size={size}
|
size={size}
|
||||||
>
|
>
|
||||||
{playLabel}
|
{item.UserData?.PlaybackPositionTicks
|
||||||
|
? "Continue Watching"
|
||||||
|
: item?.Type === "MusicAlbum" ||
|
||||||
|
item?.Type === "Audio" ||
|
||||||
|
item?.Type === "AudioBook" ||
|
||||||
|
item?.Type === "Playlist" ||
|
||||||
|
audio
|
||||||
|
? "Play Now"
|
||||||
|
: "Watch Now"}
|
||||||
<MemoizedLinearProgress
|
<MemoizedLinearProgress
|
||||||
//@ts-expect-error
|
//@ts-expect-error
|
||||||
value={
|
value={
|
||||||
@@ -443,7 +437,7 @@ const PlayButton = ({
|
|||||||
(item.RunTimeTicks ?? 0) -
|
(item.RunTimeTicks ?? 0) -
|
||||||
(item.UserData?.PlaybackPositionTicks ?? 0),
|
(item.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
)}{" "}
|
)}{" "}
|
||||||
осталось
|
left
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
|
import useQueue from "@/utils/store/queue";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { IconButton } from "@mui/material";
|
import { IconButton } from "@mui/material";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { playItemFromQueue } from "@/utils/store/playback";
|
|
||||||
import useQueue, { getNextTrackIndex } from "@/utils/store/queue";
|
|
||||||
|
|
||||||
const PlayNextButton = () => {
|
const PlayNextButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -19,18 +19,18 @@ const PlayNextButton = () => {
|
|||||||
});
|
});
|
||||||
const handlePlayNext = useMutation({
|
const handlePlayNext = useMutation({
|
||||||
mutationKey: ["playNextButton"],
|
mutationKey: ["playNextButton"],
|
||||||
mutationFn: async () => {
|
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
||||||
const nextIndex = getNextTrackIndex();
|
|
||||||
if (nextIndex === undefined) return;
|
|
||||||
return playItemFromQueue(nextIndex, user.data?.Id, api);
|
|
||||||
},
|
|
||||||
onError: (error) => console.error(error),
|
onError: (error) => console.error(error),
|
||||||
});
|
});
|
||||||
// Re-render when the queue position or repeat mode changes.
|
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||||
useQueue((state) => [state.tracks, state.currentItemIndex, state.repeatMode]);
|
state.tracks,
|
||||||
const hasNext = getNextTrackIndex() !== undefined;
|
state.currentItemIndex,
|
||||||
|
]);
|
||||||
return (
|
return (
|
||||||
<IconButton disabled={!hasNext} onClick={() => handlePlayNext.mutate()}>
|
<IconButton
|
||||||
|
disabled={queueItems?.length === currentItemIndex + 1}
|
||||||
|
onClick={() => handlePlayNext.mutate()}
|
||||||
|
>
|
||||||
<span className="material-symbols-rounded">skip_next</span>
|
<span className="material-symbols-rounded">skip_next</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,31 +1,390 @@
|
|||||||
import Drawer from "@mui/material/Drawer";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import {
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
Box,
|
||||||
import React, { useState } from "react";
|
Drawer,
|
||||||
import QueueView from "@/components/queue/queueView";
|
IconButton,
|
||||||
|
List,
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import React, { useMemo, useState } from "react";
|
||||||
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
|
import useQueue, {
|
||||||
|
clearUpcoming,
|
||||||
|
removeFromQueue,
|
||||||
|
reorderQueue,
|
||||||
|
shuffleUpcoming,
|
||||||
|
} from "@/utils/store/queue";
|
||||||
|
import "./queueButton.scss";
|
||||||
|
import {
|
||||||
|
closestCenter,
|
||||||
|
DndContext,
|
||||||
|
type DragEndEvent,
|
||||||
|
KeyboardSensor,
|
||||||
|
PointerSensor,
|
||||||
|
useSensor,
|
||||||
|
useSensors,
|
||||||
|
} from "@dnd-kit/core";
|
||||||
|
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
||||||
|
import {
|
||||||
|
arrayMove,
|
||||||
|
SortableContext,
|
||||||
|
sortableKeyboardCoordinates,
|
||||||
|
useSortable,
|
||||||
|
verticalListSortingStrategy,
|
||||||
|
} from "@dnd-kit/sortable";
|
||||||
|
import { CSS } from "@dnd-kit/utilities";
|
||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import QueueListItem from "../queueListItem";
|
||||||
|
|
||||||
|
function SortableQueueItem({
|
||||||
|
item,
|
||||||
|
onDelete,
|
||||||
|
onPlay,
|
||||||
|
index,
|
||||||
|
}: {
|
||||||
|
item: BaseItemDto;
|
||||||
|
onDelete: () => void;
|
||||||
|
onPlay: () => void;
|
||||||
|
index: number;
|
||||||
|
}) {
|
||||||
|
const {
|
||||||
|
attributes,
|
||||||
|
listeners,
|
||||||
|
setNodeRef,
|
||||||
|
transform,
|
||||||
|
transition,
|
||||||
|
isDragging,
|
||||||
|
} = useSortable({ id: item.Id || "" });
|
||||||
|
|
||||||
|
const style = {
|
||||||
|
transform: CSS.Transform.toString(transform),
|
||||||
|
transition,
|
||||||
|
opacity: isDragging ? 0.5 : 1,
|
||||||
|
position: "relative" as const,
|
||||||
|
zIndex: isDragging ? 2 : 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={setNodeRef} style={style}>
|
||||||
|
<QueueListItem
|
||||||
|
queueItem={item}
|
||||||
|
onDelete={onDelete}
|
||||||
|
onPlay={onPlay}
|
||||||
|
dragHandleProps={{ ...attributes, ...listeners }}
|
||||||
|
isEpisode={item.Type === "Episode"}
|
||||||
|
index={index}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/** Opens the play queue in a side drawer. */
|
|
||||||
const QueueButton = () => {
|
const QueueButton = () => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
|
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||||
|
state.tracks,
|
||||||
|
state.currentItemIndex,
|
||||||
|
]);
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const user = useQuery({
|
||||||
|
queryKey: ["currentUser"],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) throw new Error("API not available");
|
||||||
|
return (await getUserApi(api).getCurrentUser()).data;
|
||||||
|
},
|
||||||
|
enabled: !!api,
|
||||||
|
});
|
||||||
|
|
||||||
|
const sensors = useSensors(
|
||||||
|
useSensor(PointerSensor),
|
||||||
|
useSensor(KeyboardSensor, {
|
||||||
|
coordinateGetter: sortableKeyboardCoordinates,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const upcomingItems = useMemo(() => {
|
||||||
|
return queueItems ? queueItems.slice(currentItemIndex + 1) : [];
|
||||||
|
}, [queueItems, currentItemIndex]);
|
||||||
|
|
||||||
|
const upcomingIds = useMemo(() => {
|
||||||
|
return upcomingItems.map((item) => item.Id || "");
|
||||||
|
}, [upcomingItems]);
|
||||||
|
|
||||||
|
const handleDragEnd = (event: DragEndEvent) => {
|
||||||
|
const { active, over } = event;
|
||||||
|
|
||||||
|
if (active.id !== over?.id && queueItems) {
|
||||||
|
const oldIndex = upcomingItems.findIndex((item) => item.Id === active.id);
|
||||||
|
const newIndex = upcomingItems.findIndex((item) => item.Id === over?.id);
|
||||||
|
|
||||||
|
if (oldIndex !== -1 && newIndex !== -1) {
|
||||||
|
const newUpcoming = arrayMove(upcomingItems, oldIndex, newIndex);
|
||||||
|
const newQueue = [
|
||||||
|
...queueItems.slice(0, currentItemIndex + 1),
|
||||||
|
...newUpcoming,
|
||||||
|
];
|
||||||
|
reorderQueue(newQueue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = (index: number) => {
|
||||||
|
removeFromQueue(index);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePlay = (index: number) => {
|
||||||
|
playItemFromQueue(index, user.data?.Id, api);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClear = () => {
|
||||||
|
clearUpcoming();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleShuffle = () => {
|
||||||
|
shuffleUpcoming();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Tooltip title="Очередь">
|
|
||||||
<IconButton onClick={() => setOpen(true)} aria-label="Открыть очередь">
|
|
||||||
<span className="material-symbols-rounded">queue_music</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<Drawer
|
<Drawer
|
||||||
anchor="right"
|
anchor="right"
|
||||||
open={open}
|
open={open}
|
||||||
onClose={() => setOpen(false)}
|
onClose={() => setOpen(false)}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
backdrop: { sx: { backgroundColor: "rgb(0 0 0 / 0.3)" } },
|
backdrop: {
|
||||||
paper: { className: "queue-drawer-paper" },
|
sx: {
|
||||||
|
backgroundColor: "rgba(0, 0, 0, 0.2)",
|
||||||
|
backdropFilter: "blur(4px)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
paper: {
|
||||||
|
className: "glass",
|
||||||
|
sx: {
|
||||||
|
width: 450,
|
||||||
|
maxWidth: "100%",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
borderLeft: "1px solid rgba(255, 255, 255, 0.08)",
|
||||||
|
},
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<QueueView variant="drawer" onClose={() => setOpen(false)} />
|
<Box
|
||||||
|
sx={{
|
||||||
|
p: 3,
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignItems: "center",
|
||||||
|
position: "sticky",
|
||||||
|
top: 0,
|
||||||
|
zIndex: 20,
|
||||||
|
borderBottom: "1px solid",
|
||||||
|
borderColor: "rgba(255, 255, 255, 0.08)",
|
||||||
|
backgroundColor: "rgba(20, 20, 30, 0.4)",
|
||||||
|
backdropFilter: "blur(12px)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
variant="h5"
|
||||||
|
sx={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Play Queue
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
sx={{
|
||||||
|
color: "text.secondary",
|
||||||
|
ml: 1,
|
||||||
|
fontWeight: 600,
|
||||||
|
bgcolor: "rgba(255, 255, 255, 0.08)",
|
||||||
|
px: 1,
|
||||||
|
py: 0.5,
|
||||||
|
borderRadius: 2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{queueItems?.length || 0}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
gap: 0.5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tooltip title="Shuffle Upcoming">
|
||||||
|
<span>
|
||||||
|
<IconButton
|
||||||
|
onClick={handleShuffle}
|
||||||
|
size="small"
|
||||||
|
disabled={upcomingItems.length < 2}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">shuffle</span>
|
||||||
|
</IconButton>
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="Clear Upcoming">
|
||||||
|
<span>
|
||||||
|
<IconButton
|
||||||
|
onClick={handleClear}
|
||||||
|
size="small"
|
||||||
|
disabled={upcomingItems.length === 0}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">clear_all</span>
|
||||||
|
</IconButton>
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
<IconButton onClick={() => setOpen(false)} size="small">
|
||||||
|
<span className="material-symbols-rounded">close</span>
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
overflowY: "auto",
|
||||||
|
flex: 1,
|
||||||
|
p: 2,
|
||||||
|
"&::-webkit-scrollbar": { width: 8 },
|
||||||
|
"&::-webkit-scrollbar-track": { background: "transparent" },
|
||||||
|
"&::-webkit-scrollbar-thumb": {
|
||||||
|
background: "rgba(128,128,128,0.2)",
|
||||||
|
borderRadius: 4,
|
||||||
|
},
|
||||||
|
"&::-webkit-scrollbar-thumb:hover": {
|
||||||
|
background: "rgba(128,128,128,0.3)",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{queueItems && queueItems.length > 0 ? (
|
||||||
|
<List disablePadding>
|
||||||
|
{/* Current Item */}
|
||||||
|
{queueItems[currentItemIndex] && (
|
||||||
|
<Box sx={{ mb: 4 }}>
|
||||||
|
<Typography
|
||||||
|
variant="overline"
|
||||||
|
sx={{
|
||||||
|
display: "block",
|
||||||
|
opacity: 0.6,
|
||||||
|
mb: 1,
|
||||||
|
fontWeight: 600,
|
||||||
|
letterSpacing: 1.2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
NOW PLAYING
|
||||||
|
</Typography>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
bgcolor: "background.paper",
|
||||||
|
borderRadius: 3,
|
||||||
|
overflow: "hidden",
|
||||||
|
boxShadow: 4,
|
||||||
|
border: "1px solid",
|
||||||
|
borderColor: "divider",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<QueueListItem
|
||||||
|
queueItem={queueItems[currentItemIndex]}
|
||||||
|
active={true}
|
||||||
|
isEpisode={
|
||||||
|
queueItems[currentItemIndex].Type === "Episode"
|
||||||
|
}
|
||||||
|
index={currentItemIndex + 1}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Upcoming Items */}
|
||||||
|
{upcomingItems.length > 0 && (
|
||||||
|
<>
|
||||||
|
<Typography
|
||||||
|
variant="overline"
|
||||||
|
sx={{
|
||||||
|
display: "block",
|
||||||
|
opacity: 0.6,
|
||||||
|
mb: 1,
|
||||||
|
fontWeight: 600,
|
||||||
|
letterSpacing: 1.2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
NEXT UP
|
||||||
|
</Typography>
|
||||||
|
<DndContext
|
||||||
|
sensors={sensors}
|
||||||
|
collisionDetection={closestCenter}
|
||||||
|
onDragEnd={handleDragEnd}
|
||||||
|
modifiers={[restrictToVerticalAxis]}
|
||||||
|
>
|
||||||
|
<SortableContext
|
||||||
|
items={upcomingIds}
|
||||||
|
strategy={verticalListSortingStrategy}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{upcomingItems.map((item, index) => (
|
||||||
|
<SortableQueueItem
|
||||||
|
key={item.Id || index}
|
||||||
|
item={item}
|
||||||
|
onDelete={() =>
|
||||||
|
handleDelete(currentItemIndex + 1 + index)
|
||||||
|
}
|
||||||
|
onPlay={() =>
|
||||||
|
handlePlay(currentItemIndex + 1 + index)
|
||||||
|
}
|
||||||
|
index={currentItemIndex + 1 + index + 1}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
</SortableContext>
|
||||||
|
</DndContext>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</List>
|
||||||
|
) : (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
p: 4,
|
||||||
|
textAlign: "center",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 2,
|
||||||
|
opacity: 0.5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{ fontSize: 48 }}
|
||||||
|
>
|
||||||
|
queue_music
|
||||||
|
</span>
|
||||||
|
<Typography>Your queue is empty</Typography>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
<IconButton onClick={() => setOpen(true)}>
|
||||||
|
<span className="material-symbols-rounded">playlist_play</span>
|
||||||
|
</IconButton>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,12 +14,10 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import type { TransitionProps } from "@mui/material/transitions";
|
import type { TransitionProps } from "@mui/material/transitions";
|
||||||
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { useNavigate, useRouter } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import React, { useCallback, useState } from "react";
|
import React, { useCallback, useState } from "react";
|
||||||
import QRCodeImage from "@/components/qrCode";
|
|
||||||
import { buildQuickConnectDeepLink } from "@/utils/deepLinks";
|
|
||||||
import useInterval from "@/utils/hooks/useInterval";
|
import useInterval from "@/utils/hooks/useInterval";
|
||||||
import { saveUser } from "@/utils/storage/user";
|
import { saveUser } from "@/utils/storage/user";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
@@ -57,7 +55,6 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const quickConnectEnabled = useQuery({
|
const quickConnectEnabled = useQuery({
|
||||||
queryKey: ["quick-connect-button", "check-quick-connect-enabled"],
|
queryKey: ["quick-connect-button", "check-quick-connect-enabled"],
|
||||||
@@ -82,24 +79,22 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSuccess: async (result) => {
|
onSuccess: (result) => {
|
||||||
const { AccessToken, User } = result?.data ?? {};
|
if (api && result?.data?.AccessToken && result.data.User?.Name) {
|
||||||
if (api && AccessToken && User?.Name && User.Id) {
|
|
||||||
setCheckForQuickConnect(false);
|
setCheckForQuickConnect(false);
|
||||||
enqueueSnackbar(`Вы вошли как ${User.Name}!`, {
|
// saveUser({ username, password, rememberMe: rememberUser });
|
||||||
|
enqueueSnackbar(`Logged in as ${result.data.User?.Name}!`, {
|
||||||
variant: "success",
|
variant: "success",
|
||||||
});
|
});
|
||||||
createApi(api.basePath, AccessToken);
|
createApi(api.basePath, result.data.AccessToken);
|
||||||
if (rememberUser) {
|
if (rememberUser) {
|
||||||
await saveUser(User.Name, AccessToken, User.Id);
|
saveUser(result.data.User?.Name, result.data.AccessToken);
|
||||||
}
|
}
|
||||||
router.invalidate().finally(() => {
|
|
||||||
navigate({ to: "/home", replace: true });
|
navigate({ to: "/home", replace: true });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar("Не удалось войти.", { variant: "error" });
|
enqueueSnackbar("Error authenticating user.", { variant: "error" });
|
||||||
console.error(error);
|
console.error(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -126,7 +121,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
mutationKey: ["quick-connect-button", "initiate-connection"],
|
mutationKey: ["quick-connect-button", "initiate-connection"],
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (!quickConnectEnabled.data?.data) {
|
if (!quickConnectEnabled.data?.data) {
|
||||||
enqueueSnackbar("Quick Connect не включён на сервере.", {
|
enqueueSnackbar("Quick Connect is not enabled on server.", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -142,7 +137,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
setCheckForQuickConnect(true);
|
setCheckForQuickConnect(true);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar("Не удалось запустить Quick Connect.", { variant: "error" });
|
enqueueSnackbar("Error initiating Quick Connect.", { variant: "error" });
|
||||||
console.error(error);
|
console.error(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -182,8 +177,8 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
onClick={() => initQuickConnect.mutate()}
|
onClick={() => initQuickConnect.mutate()}
|
||||||
>
|
>
|
||||||
{quickConnectEnabled.data?.data
|
{quickConnectEnabled.data?.data
|
||||||
? "Войти через Quick Connect"
|
? "Use Quick Connect"
|
||||||
: "Quick Connect недоступен"}
|
: "Quick Connect Disabled"}
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={Boolean(quickConnectCode)}
|
open={Boolean(quickConnectCode)}
|
||||||
@@ -213,22 +208,22 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
mb: 2,
|
mb: 2,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Код Quick Connect:
|
Quick Connect Code:
|
||||||
</Typography>
|
</Typography>
|
||||||
<DialogContentText>
|
<DialogContentText>
|
||||||
Введите этот код в разделе Quick Connect на сервере, чтобы войти.
|
Use this code in the Quick Connect tab in your server to login.
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
<div
|
<div
|
||||||
className="flex flex-row"
|
className="flex flex-row"
|
||||||
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
style={{ gap: "1em", alignItems: "center", marginTop: "1em" }}
|
||||||
>
|
>
|
||||||
<Tooltip title="Нажмите, чтобы скопировать" arrow placement="top">
|
<Tooltip title="Click to copy" arrow placement="top">
|
||||||
<Typography
|
<Typography
|
||||||
variant="h3"
|
variant="h3"
|
||||||
color="textPrimary"
|
color="textPrimary"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
quickConnectCode && (await writeText(quickConnectCode));
|
quickConnectCode && (await writeText(quickConnectCode));
|
||||||
enqueueSnackbar("Код Quick Connect скопирован!", {
|
enqueueSnackbar("Quick Connect Code copied!", {
|
||||||
variant: "info",
|
variant: "info",
|
||||||
key: "copiedText",
|
key: "copiedText",
|
||||||
});
|
});
|
||||||
@@ -246,22 +241,6 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
{quickConnectCode && (
|
|
||||||
<>
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
sx={{ mt: 2, opacity: 0.75, textAlign: "center" }}
|
|
||||||
>
|
|
||||||
Или отсканируйте код в Blink на телефоне, чтобы подтвердить вход.
|
|
||||||
</Typography>
|
|
||||||
<div style={{ marginTop: "1em", background: "#08001f", borderRadius: 12, padding: 8 }}>
|
|
||||||
<QRCodeImage
|
|
||||||
value={buildQuickConnectDeepLink(quickConnectCode)}
|
|
||||||
size={180}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions
|
<DialogActions
|
||||||
className="flex flex-row"
|
className="flex flex-row"
|
||||||
@@ -277,10 +256,10 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
onChange={(e) => setRememberUser(e.target.checked)}
|
onChange={(e) => setRememberUser(e.target.checked)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label="Запомнить устройство"
|
label="Remember device"
|
||||||
/>
|
/>
|
||||||
<Button variant="contained" onClick={handleQuickConnectClose}>
|
<Button variant="contained" onClick={handleQuickConnectClose}>
|
||||||
Закрыть
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
|
transition: all $transition-time-fast;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
@@ -6,11 +6,10 @@ import {
|
|||||||
type ImageType,
|
type ImageType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import React, { memo, type Ref, useCallback } from "react";
|
import React, { memo, type Ref, useCallback, useState } from "react";
|
||||||
import { ErrorBoundary } from "react-error-boundary";
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
import { useInView } from "react-intersection-observer";
|
import { useInView } from "react-intersection-observer";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { resolveItemImage } from "@/utils/methods/itemImages";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
@@ -57,10 +56,6 @@ const CardContent = ({
|
|||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const image = resolveItemImage(item, imageType, {
|
|
||||||
seriesId: seriesId ? (item.SeriesId ?? undefined) : undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
const defaultOnClick = useCallback(() => {
|
const defaultOnClick = useCallback(() => {
|
||||||
if (item?.Id) {
|
if (item?.Id) {
|
||||||
navigate(getItemLinkOptions(item.Id, item?.Type));
|
navigate(getItemLinkOptions(item.Id, item?.Type));
|
||||||
@@ -107,21 +102,20 @@ const CardContent = ({
|
|||||||
? getTypeIcon(overrideIcon)
|
? getTypeIcon(overrideIcon)
|
||||||
: getTypeIcon(item.Type ?? "universal")}
|
: getTypeIcon(item.Type ?? "universal")}
|
||||||
</div>
|
</div>
|
||||||
{image && (
|
{inView && (
|
||||||
<img
|
<img
|
||||||
alt={item.Name ?? "blink"}
|
alt={item.Name ?? "blink"}
|
||||||
decoding="async"
|
|
||||||
src={
|
src={
|
||||||
api && image
|
api
|
||||||
? overrideIcon === "User"
|
? overrideIcon === "User"
|
||||||
? `${api?.basePath}/Users/${item.Id}/Images/Primary`
|
? `${api?.basePath}/Users/${item.Id}/Images/Primary`
|
||||||
: getImageUrlsApi(api).getItemImageUrlById(
|
: getImageUrlsApi(api).getItemImageUrlById(
|
||||||
image.itemId,
|
(seriesId ? item.SeriesId : (item.AlbumId ?? item.Id)) ??
|
||||||
image.imageType,
|
"",
|
||||||
|
imageType,
|
||||||
{
|
{
|
||||||
quality: 90,
|
quality: 90,
|
||||||
fillWidth: cardType === "thumb" ? 560 : 320,
|
fillWidth: cardType === "thumb" ? 560 : 320,
|
||||||
tag: image.tag,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: ""
|
: ""
|
||||||
@@ -129,9 +123,14 @@ const CardContent = ({
|
|||||||
style={{
|
style={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
opacity: 0,
|
||||||
display: "block",
|
display: "block",
|
||||||
|
transition: "opacity 0.3s ease-in-out",
|
||||||
}}
|
}}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
className="card-image"
|
className="card-image"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -99,14 +99,14 @@ export default function CardScroller({
|
|||||||
},
|
},
|
||||||
tablet: {
|
tablet: {
|
||||||
breakpoint: { max: 925, min: 600 },
|
breakpoint: { max: 925, min: 600 },
|
||||||
items: Math.max(2, displayCards - 2),
|
items: displayCards - 3,
|
||||||
slidesToSlide: Math.max(2, displayCards - 2),
|
slidesToSlide: displayCards - 3,
|
||||||
partialVisibilityGutter: 20,
|
partialVisibilityGutter: 20,
|
||||||
},
|
},
|
||||||
mobile: {
|
mobile: {
|
||||||
breakpoint: { max: 600, min: 424 },
|
breakpoint: { max: 600, min: 424 },
|
||||||
items: Math.max(1, displayCards - 4),
|
items: displayCards - 5,
|
||||||
slidesToSlide: Math.max(1, displayCards - 4),
|
slidesToSlide: displayCards - 5,
|
||||||
partialVisibilityGutter: 10,
|
partialVisibilityGutter: 10,
|
||||||
},
|
},
|
||||||
smallScreen: {
|
smallScreen: {
|
||||||
|
|||||||
@@ -1,329 +1,31 @@
|
|||||||
@use "@/styles/variables.scss" as *;
|
.carousel {
|
||||||
|
|
||||||
/* Cinematic home hero: full-bleed artwork, integrated type, bottom rail. */
|
|
||||||
.cinema-hero {
|
|
||||||
position: relative;
|
position: relative;
|
||||||
height: calc(100vh - 16px);
|
overflow: visible;
|
||||||
min-height: 620px;
|
height: 65vh;
|
||||||
overflow: hidden;
|
margin-bottom: 3em;
|
||||||
isolation: isolate;
|
display: grid;
|
||||||
|
grid-template-areas: "main sidebar";
|
||||||
|
grid-template-columns: 1fr 340px;
|
||||||
|
gap: 1.5em;
|
||||||
|
|
||||||
.hero-carousel-slide {
|
&-sidebar {
|
||||||
position: absolute;
|
overflow-y: auto;
|
||||||
inset: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 0;
|
|
||||||
border-radius: 0;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-background-container {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 0;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 2;
|
|
||||||
background:
|
|
||||||
linear-gradient(
|
|
||||||
90deg,
|
|
||||||
rgb(6 8 12 / 0.94) 0%,
|
|
||||||
rgb(6 8 12 / 0.72) 28%,
|
|
||||||
rgb(6 8 12 / 0.28) 52%,
|
|
||||||
rgb(6 8 12 / 0) 72%
|
|
||||||
),
|
|
||||||
linear-gradient(
|
|
||||||
0deg,
|
|
||||||
rgb(6 8 12 / 0.96) 0%,
|
|
||||||
rgb(6 8 12 / 0.55) 26%,
|
|
||||||
rgb(6 8 12 / 0) 56%
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-background-image {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
position: relative;
|
||||||
object-position: center;
|
@include glass-effect($bg-color: rgba(10, 10, 14, 0.4));
|
||||||
|
border-radius: 24px;
|
||||||
&.is-poster {
|
grid-area: sidebar;
|
||||||
filter: blur(42px) saturate(1.5) brightness(0.55);
|
|
||||||
transform: scale(1.25);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-background-blurhash {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
width: 100% !important;
|
|
||||||
height: 100% !important;
|
|
||||||
z-index: 0;
|
|
||||||
filter: blur(40px) saturate(1.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-background-icon-container {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 0;
|
|
||||||
background: linear-gradient(135deg, #12141a, #1d2028);
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
position: absolute;
|
|
||||||
left: 50%;
|
|
||||||
top: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
font-size: 15em !important;
|
|
||||||
opacity: 0.35;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-detail {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 3;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-end;
|
padding: 12px;
|
||||||
align-items: flex-start;
|
gap: 8px;
|
||||||
gap: 0.9rem;
|
|
||||||
max-width: none;
|
|
||||||
padding: 0 clamp(2rem, 5vw, 4.5rem) calc(var(--home-trending-space, 200px) + 4rem);
|
|
||||||
background: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-label {
|
// Ensure programmatic scroll respects padding
|
||||||
display: inline-flex;
|
scroll-padding-block: 24px;
|
||||||
align-items: center;
|
|
||||||
height: 34px;
|
|
||||||
padding: 0 16px;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: rgb(255 255 255 / 0.16);
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.18);
|
|
||||||
backdrop-filter: blur(14px);
|
|
||||||
color: #fff;
|
|
||||||
font-size: 0.86rem;
|
|
||||||
font-weight: 500;
|
|
||||||
letter-spacing: 0.01em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-text {
|
// Hide scrollbar but keep functionality
|
||||||
display: block;
|
|
||||||
overflow: visible;
|
|
||||||
margin: 0;
|
|
||||||
max-width: 16ch;
|
|
||||||
font-size: clamp(2.4rem, 4.1vw, 4.4rem) !important;
|
|
||||||
line-height: 0.98 !important;
|
|
||||||
font-weight: 650 !important;
|
|
||||||
letter-spacing: -0.035em;
|
|
||||||
text-shadow: 0 2px 30px rgb(0 0 0 / 0.35);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-info {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.9em !important;
|
|
||||||
margin-top: 0.1em !important;
|
|
||||||
color: rgb(255 255 255 / 0.78);
|
|
||||||
font-size: 0.9rem;
|
|
||||||
text-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
|
|
||||||
|
|
||||||
.MuiTypography-root {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MuiChip-root {
|
|
||||||
height: 24px;
|
|
||||||
background: rgb(255 255 255 / 0.14);
|
|
||||||
color: #fff;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
backdrop-filter: blur(8px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-info-rating {
|
|
||||||
gap: 0.2em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-overview {
|
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
-webkit-line-clamp: 4;
|
|
||||||
overflow: hidden;
|
|
||||||
max-width: 34rem;
|
|
||||||
margin: 0.15rem 0 0;
|
|
||||||
color: rgb(255 255 255 / 0.82);
|
|
||||||
font-size: 1rem;
|
|
||||||
line-height: 1.55;
|
|
||||||
text-shadow: 0 1px 3px rgb(0 0 0 / 0.55);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-button-container {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.85rem;
|
|
||||||
width: auto;
|
|
||||||
margin-top: 0.6rem;
|
|
||||||
|
|
||||||
.MuiButton-root {
|
|
||||||
min-height: 50px;
|
|
||||||
padding: 0 24px;
|
|
||||||
border-radius: 999px;
|
|
||||||
text-transform: none;
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: -0.01em;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.play-button .MuiButton-root,
|
|
||||||
.MuiButton-contained {
|
|
||||||
background: #f5f5f4;
|
|
||||||
color: #101116;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
color: #101116;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.MuiButton-outlined {
|
|
||||||
border-color: rgb(255 255 255 / 0.34);
|
|
||||||
color: #fff;
|
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: rgb(255 255 255 / 0.1);
|
|
||||||
border-color: rgb(255 255 255 / 0.6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.MuiIconButton-root {
|
|
||||||
color: rgb(255 255 255 / 0.75);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: #fff;
|
|
||||||
background: rgb(255 255 255 / 0.1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Big cinematic arrows */
|
|
||||||
.cinema-arrow {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
z-index: 7;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
border-radius: 50%;
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.18);
|
|
||||||
background: rgb(14 16 21 / 0.36);
|
|
||||||
backdrop-filter: blur(14px);
|
|
||||||
color: #fff;
|
|
||||||
cursor: pointer;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
opacity: 0;
|
|
||||||
transition:
|
|
||||||
opacity 0.2s ease,
|
|
||||||
background-color 0.2s ease,
|
|
||||||
color 0.2s ease;
|
|
||||||
|
|
||||||
&.right {
|
|
||||||
right: 1.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.7rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: #f5f5f4;
|
|
||||||
color: #101116;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover .cinema-arrow,
|
|
||||||
&.paused .cinema-arrow {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bottom rail */
|
|
||||||
.cinema-trending {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
z-index: 6;
|
|
||||||
padding: 2rem clamp(2rem, 5vw, 4.5rem) 1.5rem;
|
|
||||||
background: linear-gradient(
|
|
||||||
0deg,
|
|
||||||
rgb(7 8 12 / 0.98) 0%,
|
|
||||||
rgb(7 8 12 / 0.9) 46%,
|
|
||||||
rgb(7 8 12 / 0) 100%
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-trending-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 1rem;
|
|
||||||
margin-bottom: 0.9rem;
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: -0.01em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-dots {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
|
|
||||||
button {
|
|
||||||
width: 26px;
|
|
||||||
height: 3px;
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: rgb(255 255 255 / 0.3);
|
|
||||||
cursor: pointer;
|
|
||||||
transition:
|
|
||||||
background-color 0.2s ease,
|
|
||||||
width 0.2s ease;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
width: 38px;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-trending-rail {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.75rem;
|
|
||||||
overflow-x: auto;
|
|
||||||
overflow-y: hidden;
|
|
||||||
padding-bottom: 2px;
|
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
-ms-overflow-style: none;
|
-ms-overflow-style: none;
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
@@ -331,179 +33,155 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cinema-trending-card {
|
&-button {
|
||||||
position: relative;
|
position: absolute !important;
|
||||||
flex: 0 0 auto;
|
top: 50%;
|
||||||
width: clamp(200px, 21vw, 300px);
|
transform: translateY(-50%);
|
||||||
aspect-ratio: 16 / 9;
|
z-index: 100;
|
||||||
padding: 0;
|
|
||||||
|
&.right {
|
||||||
|
right: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.left {
|
||||||
|
left: 0.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-ticker{
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border: 1px solid rgb(255 255 255 / 0.12);
|
height: 72px;
|
||||||
border-radius: 12px;
|
display: flex;
|
||||||
background: rgb(255 255 255 / 0.05);
|
padding: 8px;
|
||||||
cursor: pointer;
|
align-items: center;
|
||||||
opacity: 0.72;
|
gap: 12px;
|
||||||
transition:
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
opacity 0.2s ease,
|
position: relative;
|
||||||
border-color 0.2s ease,
|
border-radius: 12px; // Slightly smaller radius to work with the bar
|
||||||
transform 0.2s ease;
|
background: transparent;
|
||||||
|
border: 1px solid transparent;
|
||||||
img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
background: linear-gradient(0deg, rgb(0 0 0 / 0.35), transparent 55%);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
opacity: 1;
|
background: rgba(255, 255, 255, 0.05);
|
||||||
border-color: rgb(255 255 255 / 0.4);
|
cursor: pointer;
|
||||||
transform: translateY(-2px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
opacity: 1;
|
background: rgba(255, 255, 255, 0.08); // Subtle background
|
||||||
border-color: rgb(255 255 255 / 0.7);
|
|
||||||
box-shadow: 0 0 0 1px rgb(255 255 255 / 0.25);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-trending-chip {
|
// Vertical Progress Bar
|
||||||
|
&::after {
|
||||||
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
left: 0;
|
||||||
left: 10px;
|
bottom: 0;
|
||||||
z-index: 1;
|
width: 4px;
|
||||||
padding: 3px 10px;
|
background-color: var(--mui-palette-primary-main, #fff);
|
||||||
border-radius: 8px;
|
height: 0%;
|
||||||
background: rgb(245 245 244 / 0.9);
|
animation: ticker-v-progress 8s linear;
|
||||||
color: #131419;
|
}
|
||||||
font-size: 0.75rem;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cinema-trending-placeholder {
|
&-image {
|
||||||
|
height: 56px;
|
||||||
|
width: 100px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-radius: 8px;
|
||||||
|
object-fit: cover;
|
||||||
|
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
||||||
|
|
||||||
|
&.placeholder {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgb(100 100 100 / 0.1);
|
||||||
|
color: rgb(200 200 200 / 0.7);
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 0; // flexible text truncation
|
||||||
|
padding-left: 4px; // compensate for visual weight of potential bar
|
||||||
|
|
||||||
|
.carousel-ticker-title {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
font-weight: 500; // Slightly lighter
|
||||||
|
font-size: 0.95rem;
|
||||||
|
line-height: 1.2;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
.carousel-ticker-year {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pause progress when carousel is paused
|
||||||
|
&.paused {
|
||||||
|
.carousel-ticker.active::after {
|
||||||
|
animation-play-state: paused;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes ticker-v-progress {
|
||||||
|
from { height: 0%; }
|
||||||
|
to { height: 100%; }
|
||||||
|
}
|
||||||
|
|
||||||
|
&-indicator {
|
||||||
|
aspect-ratio: 1.77777;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 2px;
|
||||||
|
transition: opacity $transition-time-fast;
|
||||||
|
opacity: 0.5;
|
||||||
|
width: auto;
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-container {
|
||||||
|
display: flex;
|
||||||
|
gap: 1em;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
&-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
color: rgb(255 255 255 / 0.5);
|
background: rgb(155 155 155 / 0.4);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
&.active {
|
||||||
|
opacity: 1;
|
||||||
|
|
||||||
.material-symbols-rounded {
|
.material-symbols-rounded {
|
||||||
font-size: 2rem;
|
|
||||||
|
--fill: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
.carousel-ticker-wrapper {
|
||||||
|
scroll-margin-block: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Reserve room for the floating player bar so the rail is never covered. */
|
|
||||||
body.has-player-bar .cinema-trending {
|
|
||||||
padding-bottom: 116px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* With the player bar visible the hero has less vertical room, so keep the
|
|
||||||
copy compact instead of pushing it under the header. */
|
|
||||||
body.has-player-bar .cinema-hero .hero-carousel-text {
|
|
||||||
font-size: clamp(2.1rem, 3.6vw, 4rem) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
body.has-player-bar .cinema-hero .hero-carousel-overview {
|
|
||||||
-webkit-line-clamp: 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 1100px) {
|
|
||||||
.cinema-hero {
|
|
||||||
height: calc(100vh - 16px);
|
|
||||||
min-height: 560px;
|
|
||||||
|
|
||||||
.hero-carousel-detail {
|
|
||||||
padding-left: 2rem;
|
|
||||||
padding-right: 2rem;
|
|
||||||
padding-bottom: calc(var(--home-trending-space, 200px) + 1.5rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-text {
|
|
||||||
font-size: 2.6rem !important;
|
|
||||||
max-width: 14ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-overview {
|
|
||||||
-webkit-line-clamp: 3;
|
|
||||||
max-width: 30rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-trending {
|
|
||||||
padding-left: 2rem;
|
|
||||||
padding-right: 2rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Short windows (and the player bar) leave little vertical room: drop the
|
|
||||||
secondary copy instead of pushing the headline under the header. */
|
|
||||||
@media (max-height: 760px) {
|
|
||||||
.cinema-hero {
|
|
||||||
height: calc(100vh - 16px);
|
|
||||||
min-height: 540px;
|
|
||||||
|
|
||||||
.hero-carousel-detail {
|
|
||||||
gap: 0.65rem;
|
|
||||||
padding-bottom: calc(var(--home-trending-space, 200px) + 1rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-overview,
|
|
||||||
.hero-carousel-info {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-text {
|
|
||||||
max-width: 18ch;
|
|
||||||
font-size: clamp(2rem, 3.2vw, 3rem) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-trending {
|
|
||||||
padding-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-trending-head {
|
|
||||||
margin-bottom: 0.6rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-trending-card {
|
|
||||||
width: clamp(150px, 15vw, 220px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 700px) {
|
|
||||||
.cinema-hero {
|
|
||||||
min-height: 520px;
|
|
||||||
|
|
||||||
.hero-carousel-text {
|
|
||||||
font-size: 2.1rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-info {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-carousel-overview {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-arrow {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cinema-trending-card {
|
|
||||||
width: 160px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +1,20 @@
|
|||||||
|
import { AnimatePresence } from "motion/react";
|
||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
import type { Api } from "@jellyfin/sdk";
|
|
||||||
|
import { useCarouselStore } from "../../utils/store/carousel";
|
||||||
|
import "./carousel.scss";
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { useCarouselStore } from "../../utils/store/carousel";
|
|
||||||
import "./carousel.scss";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { resolveItemImage } from "@/utils/methods/itemImages";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import CarouselSlide from "../carouselSlide";
|
import CarouselSlide from "../carouselSlide";
|
||||||
|
import CarouselTickers from "./tickers";
|
||||||
const AUTOPLAY_MS = 9000;
|
|
||||||
|
|
||||||
// Memoize CarouselSlide to prevent unnecessary re-renders
|
// Memoize CarouselSlide to prevent unnecessary re-renders
|
||||||
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
||||||
|
|
||||||
/** Wide artwork for the trending rail, falling back through the item's images. */
|
|
||||||
const trendingImageUrl = (
|
|
||||||
api: Api,
|
|
||||||
item: BaseItemDto,
|
|
||||||
): string | undefined => {
|
|
||||||
const image = resolveItemImage(item, "Thumb");
|
|
||||||
if (!image) return undefined;
|
|
||||||
return getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
image.itemId,
|
|
||||||
image.imageType,
|
|
||||||
{
|
|
||||||
quality: 85,
|
|
||||||
fillWidth: 480,
|
|
||||||
tag: image.tag,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const trendingLabel = (item: BaseItemDto): string => {
|
|
||||||
const genre = item.Genres?.[0];
|
|
||||||
if (genre) return genre.charAt(0).toUpperCase() + genre.slice(1);
|
|
||||||
return item.Type === BaseItemKind.Series ? "Сериал" : "Фильм";
|
|
||||||
};
|
|
||||||
|
|
||||||
const Carousel = ({
|
const Carousel = ({
|
||||||
content,
|
content,
|
||||||
onChange,
|
onChange,
|
||||||
@@ -49,125 +24,121 @@ const Carousel = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [currentSlide, setCurrentSlide] = useState(0);
|
const [currentSlide, setCurrentSlide] = useState(0);
|
||||||
const [isPaused, setIsPaused] = useState(false);
|
const [isPaused, setIsPaused] = useState(false);
|
||||||
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
const sidebarRef = React.useRef<HTMLDivElement>(null);
|
||||||
const api = useApiInContext((s) => s.api);
|
const tickerRefs = React.useRef<(HTMLDivElement | null)[]>([]);
|
||||||
|
const currentSlideRef = React.useRef(currentSlide);
|
||||||
|
|
||||||
const total = content.length;
|
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentSlide >= total && total > 0) {
|
currentSlideRef.current = currentSlide;
|
||||||
setCurrentSlide(total - 1);
|
}, [currentSlide]);
|
||||||
}
|
|
||||||
}, [currentSlide, total]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onChange(currentSlide);
|
onChange(currentSlide);
|
||||||
}, [currentSlide, onChange]);
|
|
||||||
|
|
||||||
const goTo = useCallback(
|
// Auto-scroll sidebar to keep active item in view
|
||||||
|
const activeTicker = tickerRefs.current[currentSlide];
|
||||||
|
const sidebar = sidebarRef.current;
|
||||||
|
|
||||||
|
if (activeTicker && sidebar) {
|
||||||
|
const sidebarTop = sidebar.scrollTop;
|
||||||
|
const sidebarBottom = sidebarTop + sidebar.clientHeight;
|
||||||
|
const activeTickerTop = activeTicker.offsetTop;
|
||||||
|
const activeTickerBottom =
|
||||||
|
activeTicker.offsetTop + activeTicker.offsetHeight;
|
||||||
|
|
||||||
|
// If element is below the visible area
|
||||||
|
if (activeTickerBottom > sidebarBottom) {
|
||||||
|
sidebar.scrollTo({
|
||||||
|
top: activeTickerBottom - sidebar.clientHeight + 24, // 24px padding
|
||||||
|
behavior: "smooth",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// If element is above the visible area
|
||||||
|
else if (activeTickerTop < sidebarTop) {
|
||||||
|
sidebar.scrollTo({
|
||||||
|
top: activeTickerTop - 24, // 24px padding
|
||||||
|
behavior: "smooth",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [currentSlide, content, onChange]);
|
||||||
|
|
||||||
|
// Autoplay functionality
|
||||||
|
useEffect(() => {
|
||||||
|
if (isPaused || content.length === 0) return;
|
||||||
|
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
setDirection("right");
|
||||||
|
setCurrentSlide((prev) => (prev + 1) % content.length);
|
||||||
|
}, 8000);
|
||||||
|
|
||||||
|
return () => clearInterval(timer);
|
||||||
|
}, [isPaused, content.length, setDirection, currentSlide]);
|
||||||
|
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
|
const handleTickerClick = useCallback(
|
||||||
(index: number) => {
|
(index: number) => {
|
||||||
if (index === currentSlide) return;
|
if (index === currentSlideRef.current) return;
|
||||||
setDirection(index > currentSlide ? "right" : "left");
|
setDirection(index > currentSlideRef.current ? "right" : "left");
|
||||||
setCurrentSlide(index);
|
setCurrentSlide(index);
|
||||||
},
|
},
|
||||||
[currentSlide, setDirection],
|
[setDirection],
|
||||||
);
|
);
|
||||||
|
|
||||||
const next = useCallback(() => {
|
if (!api) return null;
|
||||||
if (total < 2) return;
|
|
||||||
setDirection("right");
|
|
||||||
setCurrentSlide((prev) => (prev + 1) % total);
|
|
||||||
}, [total, setDirection]);
|
|
||||||
|
|
||||||
// Autoplay; pauses while the pointer is over the hero.
|
|
||||||
useEffect(() => {
|
|
||||||
if (isPaused || total < 2) return;
|
|
||||||
const timer = window.setInterval(() => {
|
|
||||||
setDirection("right");
|
|
||||||
setCurrentSlide((prev) => (prev + 1) % total);
|
|
||||||
}, AUTOPLAY_MS);
|
|
||||||
return () => window.clearInterval(timer);
|
|
||||||
}, [isPaused, total, setDirection]);
|
|
||||||
|
|
||||||
if (!api || total === 0) return null;
|
|
||||||
|
|
||||||
const currentItem = content[currentSlide];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<div
|
||||||
className={`cinema-hero ${isPaused ? "paused" : ""}`}
|
className={`carousel ${isPaused ? "paused" : ""}`}
|
||||||
aria-roledescription="carousel"
|
|
||||||
aria-label="Рекомендуемое"
|
|
||||||
onMouseEnter={() => setIsPaused(true)}
|
onMouseEnter={() => setIsPaused(true)}
|
||||||
onMouseLeave={() => setIsPaused(false)}
|
onMouseLeave={() => setIsPaused(false)}
|
||||||
>
|
>
|
||||||
<MemoizedCarouselSlide key={currentItem.Id} item={currentItem} />
|
<AnimatePresence mode="sync">
|
||||||
|
<MemoizedCarouselSlide
|
||||||
{total > 1 && (
|
item={content[currentSlide]}
|
||||||
<button
|
key={content[currentSlide].Id}
|
||||||
type="button"
|
|
||||||
className="cinema-arrow right"
|
|
||||||
onClick={next}
|
|
||||||
aria-label="Далее"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">chevron_right</span>
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="cinema-trending">
|
|
||||||
<div className="cinema-trending-head">
|
|
||||||
<h3>В тренде</h3>
|
|
||||||
{total > 1 && (
|
|
||||||
<div className="cinema-dots">
|
|
||||||
{content.map((item, index) => (
|
|
||||||
<button
|
|
||||||
key={item.Id}
|
|
||||||
type="button"
|
|
||||||
className={index === currentSlide ? "active" : ""}
|
|
||||||
onClick={() => goTo(index)}
|
|
||||||
aria-label={item.Name ?? `Slide ${index + 1}`}
|
|
||||||
aria-current={index === currentSlide}
|
|
||||||
/>
|
/>
|
||||||
|
</AnimatePresence>
|
||||||
|
<div className="carousel-sidebar" ref={sidebarRef}>
|
||||||
|
{content.map((item, index) => (
|
||||||
|
<div
|
||||||
|
key={item.Id}
|
||||||
|
ref={(el) => {
|
||||||
|
tickerRefs.current[index] = el;
|
||||||
|
}}
|
||||||
|
className="carousel-ticker-wrapper"
|
||||||
|
>
|
||||||
|
<CarouselTickers
|
||||||
|
imageUrl={
|
||||||
|
item.ImageTags?.Thumb
|
||||||
|
? getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
item.Id ?? "",
|
||||||
|
"Thumb",
|
||||||
|
{
|
||||||
|
quality: 90,
|
||||||
|
fillHeight: 360,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
isActive={index === currentSlide}
|
||||||
|
itemName={item.Name ?? "Unknown"}
|
||||||
|
itemYear={
|
||||||
|
item.Type === BaseItemKind.Series && item.EndDate
|
||||||
|
? `${item.ProductionYear ?? ""} - ${new Date(item.EndDate).getFullYear().toString()}`
|
||||||
|
: (item.ProductionYear?.toString() ?? "")
|
||||||
|
}
|
||||||
|
onTickerClick={handleTickerClick}
|
||||||
|
index={index}
|
||||||
|
itemType={item.Type as BaseItemKind}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="cinema-trending-rail">
|
|
||||||
{content.map((item, index) => {
|
|
||||||
const imageUrl = trendingImageUrl(api, item);
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={item.Id}
|
|
||||||
type="button"
|
|
||||||
className={`cinema-trending-card ${
|
|
||||||
index === currentSlide ? "active" : ""
|
|
||||||
}`}
|
|
||||||
onClick={() => goTo(index)}
|
|
||||||
aria-label={item.Name ?? "Рекомендуемое"}
|
|
||||||
>
|
|
||||||
{imageUrl ? (
|
|
||||||
<img
|
|
||||||
src={imageUrl}
|
|
||||||
alt=""
|
|
||||||
loading="lazy"
|
|
||||||
decoding="async"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div className="cinema-trending-placeholder">
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
{ item.Type === BaseItemKind.Series ? "tv" : "movie" }
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<span className="cinema-trending-chip">
|
|
||||||
{trendingLabel(item)}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import type { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { Typography } from "@mui/material";
|
||||||
|
import React from "react";
|
||||||
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
|
|
||||||
|
type CarouselTickersProps = {
|
||||||
|
imageUrl?: string | undefined | null;
|
||||||
|
itemName: string;
|
||||||
|
itemYear: string;
|
||||||
|
onTickerClick: (index: number) => void;
|
||||||
|
index: number;
|
||||||
|
isActive: boolean;
|
||||||
|
itemType: BaseItemKind;
|
||||||
|
};
|
||||||
|
|
||||||
|
const CarouselTickers = React.memo(
|
||||||
|
({
|
||||||
|
imageUrl,
|
||||||
|
itemName,
|
||||||
|
itemYear,
|
||||||
|
onTickerClick,
|
||||||
|
index,
|
||||||
|
isActive,
|
||||||
|
itemType,
|
||||||
|
}: CarouselTickersProps) => {
|
||||||
|
const handleClick = React.useCallback(() => {
|
||||||
|
onTickerClick(index);
|
||||||
|
}, [index, onTickerClick]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`carousel-ticker${isActive ? " active" : ""}`}
|
||||||
|
onClick={handleClick}
|
||||||
|
>
|
||||||
|
{imageUrl ? (
|
||||||
|
<img
|
||||||
|
src={imageUrl}
|
||||||
|
alt={itemName}
|
||||||
|
className="carousel-ticker-image"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="carousel-ticker-image placeholder material-symbols-rounded">
|
||||||
|
{" "}
|
||||||
|
{getTypeIcon(itemType)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div>
|
||||||
|
<Typography variant="subtitle1" className="carousel-ticker-title">
|
||||||
|
{itemName}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" className="carousel-ticker-year">
|
||||||
|
{itemYear}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
export default CarouselTickers;
|
||||||
@@ -8,16 +8,9 @@ import { green, red, yellow } from "@mui/material/colors";
|
|||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { motion, type Variants } from "motion/react";
|
import { motion, type Variants } from "motion/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||||
import {
|
|
||||||
getHeroPosterUrl,
|
|
||||||
getItemImagesQueryOptions,
|
|
||||||
resolveHeroArtwork,
|
|
||||||
} from "@/utils/methods/heroArtwork";
|
|
||||||
import BlurhashCanvas from "../blurhash-canvas";
|
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCarouselStore } from "@/utils/store/carousel";
|
import { useCarouselStore } from "@/utils/store/carousel";
|
||||||
@@ -32,11 +25,10 @@ const MotionTypography = motion.create(Typography);
|
|||||||
const MotionStack = motion.create(Stack);
|
const MotionStack = motion.create(Stack);
|
||||||
|
|
||||||
const textVariants: Variants = {
|
const textVariants: Variants = {
|
||||||
// No hidden start state: hero text must not blink on slide changes.
|
initial: (direction: string) => ({
|
||||||
initial: {
|
x: direction === "right" ? 40 : -40,
|
||||||
x: 0,
|
opacity: 0,
|
||||||
opacity: 1,
|
}),
|
||||||
},
|
|
||||||
animate: {
|
animate: {
|
||||||
x: 0,
|
x: 0,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
@@ -69,54 +61,37 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
|
|
||||||
const [animationDirection] = useCarouselStore((state) => [state.direction]);
|
const [animationDirection] = useCarouselStore((state) => [state.direction]);
|
||||||
|
|
||||||
// Jellyfin stores several images per item (poster, thumb, backdrops).
|
|
||||||
// Ask the server which ones exist and their real size, then pick the wide one.
|
|
||||||
const imageInfos = useQuery(getItemImagesQueryOptions(api, item.Id));
|
|
||||||
const heroArtwork = resolveHeroArtwork(api, item, imageInfos.data);
|
|
||||||
const heroPoster = heroArtwork?.isPortrait
|
|
||||||
? getHeroPosterUrl(api, item)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="hero-carousel-slide">
|
<div className="hero-carousel-slide">
|
||||||
<motion.div
|
<motion.div
|
||||||
className="hero-carousel-background-container"
|
className="hero-carousel-background-container"
|
||||||
initial={{ opacity: 1 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
exit={{ opacity: 0 }}
|
exit={{ opacity: 0 }}
|
||||||
transition={{ duration: 0.4, ease: "easeInOut" }}
|
transition={{ duration: 0.4, ease: "easeInOut" }}
|
||||||
>
|
>
|
||||||
{heroArtwork?.blurhash && (
|
{item.BackdropImageTags?.length ? (
|
||||||
<BlurhashCanvas
|
|
||||||
blurhashString={heroArtwork.blurhash}
|
|
||||||
width={48}
|
|
||||||
height={27}
|
|
||||||
canvasProps={{
|
|
||||||
className: "hero-carousel-background-blurhash",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{heroArtwork ? (
|
|
||||||
<img
|
<img
|
||||||
alt={item.Name ?? "item"}
|
alt={item.Name ?? "item"}
|
||||||
className={`hero-carousel-background-image${heroArtwork.isPortrait ? " is-poster" : ""}`}
|
className="hero-carousel-background-image"
|
||||||
src={heroArtwork.url}
|
src={
|
||||||
|
item.ParentBackdropItemId
|
||||||
|
? `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
|
||||||
|
: `${api?.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
|
||||||
|
}
|
||||||
|
style={{
|
||||||
|
opacity: 0,
|
||||||
|
}}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
loading="eager"
|
loading="eager"
|
||||||
decoding="async"
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="hero-carousel-background-icon-container">
|
<div className="hero-carousel-background-icon-container">
|
||||||
{getTypeIcon(item.Type ?? "Movie")}
|
{getTypeIcon(item.Type ?? "Movie")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{heroPoster && (
|
|
||||||
<img
|
|
||||||
alt={item.Name ?? "poster"}
|
|
||||||
className="hero-carousel-poster"
|
|
||||||
src={heroPoster}
|
|
||||||
loading="eager"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
<motion.div
|
<motion.div
|
||||||
className="hero-carousel-detail"
|
className="hero-carousel-detail"
|
||||||
@@ -138,20 +113,6 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MotionStack
|
|
||||||
custom={animationDirection}
|
|
||||||
variants={textVariants}
|
|
||||||
direction="row"
|
|
||||||
sx={{ alignItems: "center", gap: 1 }}
|
|
||||||
>
|
|
||||||
<span className="hero-carousel-label">
|
|
||||||
{item.UserData?.PlaybackPositionTicks
|
|
||||||
? "Продолжить просмотр"
|
|
||||||
: item.Type === BaseItemKind.Series
|
|
||||||
? "Новый сериал"
|
|
||||||
: "Новый фильм"}
|
|
||||||
</span>
|
|
||||||
</MotionStack>
|
|
||||||
<MotionTypography
|
<MotionTypography
|
||||||
custom={animationDirection}
|
custom={animationDirection}
|
||||||
variants={textVariants}
|
variants={textVariants}
|
||||||
@@ -161,9 +122,26 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
sx={{
|
sx={{
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
overflow: "visible",
|
overflow: "visible",
|
||||||
|
mb: "5px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.Name}
|
{!item.ImageTags?.Logo ? (
|
||||||
|
item.Name
|
||||||
|
) : (
|
||||||
|
<img
|
||||||
|
alt={item.Name ?? "Item"}
|
||||||
|
className="hero-carousel-text-logo"
|
||||||
|
src={`${api?.basePath}/Items/${item.Id}/Images/Logo?quality=90&tag=${item.ImageTags.Logo}`}
|
||||||
|
style={{
|
||||||
|
opacity: 0,
|
||||||
|
transition: "opacity 0.2s",
|
||||||
|
objectFit: "contain",
|
||||||
|
}}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</MotionTypography>
|
</MotionTypography>
|
||||||
<MotionStack
|
<MotionStack
|
||||||
custom={animationDirection}
|
custom={animationDirection}
|
||||||
@@ -315,7 +293,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
}
|
}
|
||||||
onClick={handleMoreInfo}
|
onClick={handleMoreInfo}
|
||||||
>
|
>
|
||||||
Подробнее
|
More info
|
||||||
</Button>
|
</Button>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
import { useNavigate } from "@tanstack/react-router";
|
|
||||||
import { getCurrent, onOpenUrl } from "@tauri-apps/plugin-deep-link";
|
|
||||||
import React, { useEffect } from "react";
|
|
||||||
import {
|
|
||||||
consumePendingDeepLink,
|
|
||||||
handleDeepLink,
|
|
||||||
} from "@/utils/methods/deepLinks";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
|
|
||||||
const DeepLinkHandler = () => {
|
|
||||||
const api = useApiInContext((state) => state.api);
|
|
||||||
const user = useCentralStore((state) => state.currentUser);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let disposed = false;
|
|
||||||
let unlisten: (() => void) | undefined;
|
|
||||||
|
|
||||||
const process = async (urls: string[] | null | undefined) => {
|
|
||||||
for (const url of urls ?? []) {
|
|
||||||
try {
|
|
||||||
await handleDeepLink(url, { api, user, navigate });
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Could not handle deep link", url, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
getCurrent()
|
|
||||||
.then((urls) => {
|
|
||||||
if (!disposed) void process(urls);
|
|
||||||
})
|
|
||||||
.catch((error) => console.warn("Could not read deep links", error));
|
|
||||||
|
|
||||||
onOpenUrl((urls) => {
|
|
||||||
if (!disposed) void process(urls);
|
|
||||||
})
|
|
||||||
.then((stop) => {
|
|
||||||
if (disposed) stop();
|
|
||||||
else unlisten = stop;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.warn("Deep-link listener is unavailable", error);
|
|
||||||
});
|
|
||||||
|
|
||||||
const pending = consumePendingDeepLink();
|
|
||||||
if (pending) void process([pending]);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
disposed = true;
|
|
||||||
unlisten?.();
|
|
||||||
};
|
|
||||||
}, [api, user?.Id, navigate]);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default React.memo(DeepLinkHandler);
|
|
||||||
@@ -27,15 +27,15 @@ import { useLibraryStateStore } from "@/utils/store/libraryState";
|
|||||||
const route = getRouteApi("/_api/library/$id");
|
const route = getRouteApi("/_api/library/$id");
|
||||||
|
|
||||||
const FILTER_LABELS: Record<FILTERS, string> = {
|
const FILTER_LABELS: Record<FILTERS, string> = {
|
||||||
isPlayed: "Просмотрено",
|
isPlayed: "Played",
|
||||||
isUnPlayed: "Не просмотрено",
|
isUnPlayed: "Unplayed",
|
||||||
isResumable: "Можно продолжить",
|
isResumable: "Resumable",
|
||||||
isFavorite: "Избранное",
|
isFavorite: "Favorite",
|
||||||
hasSubtitles: "Есть субтитры",
|
hasSubtitles: "Has Subtitles",
|
||||||
hasTrailer: "Есть трейлер",
|
hasTrailer: "Has Trailer",
|
||||||
hasSpecialFeature: "Дополнительные материалы",
|
hasSpecialFeature: "Special Feature",
|
||||||
hasThemeSong: "Тематическая песня",
|
hasThemeSong: "Theme Song",
|
||||||
hasThemeVideo: "Тематическое видео",
|
hasThemeVideo: "Theme Video",
|
||||||
isSD: "SD",
|
isSD: "SD",
|
||||||
isHD: "HD",
|
isHD: "HD",
|
||||||
is4K: "4K",
|
is4K: "4K",
|
||||||
@@ -173,7 +173,7 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
|||||||
paper: { className: "glass-dialog-paper" },
|
paper: { className: "glass-dialog-paper" },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DialogTitle>Фильтры</DialogTitle>
|
<DialogTitle>Filters</DialogTitle>
|
||||||
<DialogContent
|
<DialogContent
|
||||||
dividers
|
dividers
|
||||||
sx={{ borderColor: "rgba(255, 255, 255, 0.1)" }}
|
sx={{ borderColor: "rgba(255, 255, 255, 0.1)" }}
|
||||||
@@ -200,7 +200,7 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
|||||||
<span className="material-symbols-rounded">expand_more</span>
|
<span className="material-symbols-rounded">expand_more</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Typography variant="subtitle2">Общие</Typography>
|
<Typography variant="subtitle2">General</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
@@ -252,7 +252,7 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Typography variant="subtitle2">Видео</Typography>
|
<Typography variant="subtitle2">Video features</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
@@ -306,7 +306,7 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Typography variant="subtitle2">Разрешение</Typography>
|
<Typography variant="subtitle2">Resolution</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
@@ -354,7 +354,7 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Typography variant="subtitle2">Тип медиа</Typography>
|
<Typography variant="subtitle2">Media type</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
@@ -374,17 +374,7 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
|||||||
size="small"
|
size="small"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label={
|
label={k}
|
||||||
k === "VideoFile"
|
|
||||||
? "Видеофайл"
|
|
||||||
: k === "BluRay"
|
|
||||||
? "Blu-ray"
|
|
||||||
: k === "Dvd"
|
|
||||||
? "DVD"
|
|
||||||
: k === "Iso"
|
|
||||||
? "ISO"
|
|
||||||
: k
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
@@ -415,7 +405,7 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Typography variant="subtitle2">Жанры</Typography>
|
<Typography variant="subtitle2">Genres</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
@@ -450,7 +440,7 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
|||||||
color="inherit"
|
color="inherit"
|
||||||
disabled={Object.keys(localFilters).length === 0}
|
disabled={Object.keys(localFilters).length === 0}
|
||||||
>
|
>
|
||||||
Сбросить
|
Clear
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -461,11 +451,11 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
|||||||
color="inherit"
|
color="inherit"
|
||||||
disabled={!dirty}
|
disabled={!dirty}
|
||||||
>
|
>
|
||||||
Сбросить всё
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={onClose}>Отмена</Button>
|
<Button onClick={onClose}>Cancel</Button>
|
||||||
<Button onClick={apply} disabled={!dirty} variant="contained">
|
<Button onClick={apply} disabled={!dirty} variant="contained">
|
||||||
Применить
|
Apply
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
@@ -498,11 +488,11 @@ export const FiltersDialogTrigger: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={activeCount ? `${activeCount} активных фильтров` : "Фильтры"}
|
title={activeCount ? `${activeCount} active filters` : "Filters"}
|
||||||
>
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => setOpen(true)}
|
onClick={() => setOpen(true)}
|
||||||
aria-label="Открыть фильтры"
|
aria-label="Open filters dialog"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className="material-symbols-rounded"
|
className="material-symbols-rounded"
|
||||||
|
|||||||
@@ -1,277 +0,0 @@
|
|||||||
import {
|
|
||||||
type BaseItemDto,
|
|
||||||
BaseItemKind,
|
|
||||||
type SessionInfoDto,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
IconButton,
|
|
||||||
Paper,
|
|
||||||
Tooltip,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import React, { useCallback, useMemo, useState } from "react";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
import { transferSessionToLocal } from "@/utils/methods/transferPlayback";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
|
||||||
import useRealtimeStore from "@/utils/store/realtime";
|
|
||||||
|
|
||||||
const DISMISS_STORAGE_KEY = "blink:follow-me-dismissed";
|
|
||||||
const DISMISS_TTL_MS = 30 * 60 * 1000;
|
|
||||||
const MIN_POSITION_TICKS = 45 * 10_000_000;
|
|
||||||
|
|
||||||
type DismissedMap = Record<string, number>;
|
|
||||||
|
|
||||||
const readDismissed = (): DismissedMap => {
|
|
||||||
try {
|
|
||||||
const raw = sessionStorage.getItem(DISMISS_STORAGE_KEY);
|
|
||||||
const parsed = raw ? (JSON.parse(raw) as DismissedMap) : {};
|
|
||||||
const now = Date.now();
|
|
||||||
return Object.fromEntries(
|
|
||||||
Object.entries(parsed).filter(([, at]) => now - at < DISMISS_TTL_MS),
|
|
||||||
);
|
|
||||||
} catch {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const formatTime = (ticks: number) => {
|
|
||||||
const total = Math.max(0, Math.round(ticks / 10_000_000));
|
|
||||||
const hours = Math.floor(total / 3600);
|
|
||||||
const minutes = Math.floor((total % 3600) / 60);
|
|
||||||
const seconds = total % 60;
|
|
||||||
return hours > 0
|
|
||||||
? `${hours}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`
|
|
||||||
: `${minutes}:${String(seconds).padStart(2, "0")}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const deviceLabel = (session: SessionInfoDto) =>
|
|
||||||
session.DeviceName || session.Client || "другое устройство";
|
|
||||||
|
|
||||||
const posterId = (item: BaseItemDto) =>
|
|
||||||
item.ImageTags?.Primary ? item.Id : (item.SeriesId ?? item.Id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Spotify-Connect style hand-off prompt. When another session of the same
|
|
||||||
* user is already watching something and this client is idle, offer to
|
|
||||||
* continue the same item here at its current position.
|
|
||||||
*/
|
|
||||||
const FollowMe = () => {
|
|
||||||
const api = useApiInContext((state) => state.api);
|
|
||||||
const user = useCentralStore((state) => state.currentUser);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
|
|
||||||
const localVideoActive = usePlaybackStore((state) =>
|
|
||||||
Boolean(state.playbackStream && state.metadata.item?.Id),
|
|
||||||
);
|
|
||||||
const localAudioActive = useAudioPlayback((state) =>
|
|
||||||
Boolean(state.display && state.item?.Id),
|
|
||||||
);
|
|
||||||
const localActive = localVideoActive || localAudioActive;
|
|
||||||
|
|
||||||
const realtimeSessions = useRealtimeStore((state) => state.sessions);
|
|
||||||
const sessionsQuery = useQuery({
|
|
||||||
queryKey: ["remoteSessions"],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!api || !user?.Id) return [];
|
|
||||||
return (await getSessionApi(api).getSessions()).data;
|
|
||||||
},
|
|
||||||
enabled: Boolean(api && user?.Id) && !localActive,
|
|
||||||
refetchInterval: localActive ? false : 15_000,
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const [dismissed, setDismissed] = useState<DismissedMap>(readDismissed);
|
|
||||||
const [transferring, setTransferring] = useState(false);
|
|
||||||
|
|
||||||
const candidate = useMemo(() => {
|
|
||||||
if (!api || !user?.Id || localActive) return undefined;
|
|
||||||
const sessions =
|
|
||||||
realtimeSessions.length > 0
|
|
||||||
? realtimeSessions
|
|
||||||
: (sessionsQuery.data ?? []);
|
|
||||||
const options = sessions.filter((session) => {
|
|
||||||
const item = session.NowPlayingItem;
|
|
||||||
const lastCheckIn = session.LastPlaybackCheckIn
|
|
||||||
? Date.parse(session.LastPlaybackCheckIn)
|
|
||||||
: 0;
|
|
||||||
const stale =
|
|
||||||
lastCheckIn > 0 && Date.now() - lastCheckIn > 15 * 60 * 1000;
|
|
||||||
return (
|
|
||||||
Boolean(session.Id && item?.Id) &&
|
|
||||||
!stale &&
|
|
||||||
session.DeviceId !== api.deviceInfo.id &&
|
|
||||||
session.UserId === user.Id &&
|
|
||||||
item?.Type !== BaseItemKind.Photo &&
|
|
||||||
(item?.Type === BaseItemKind.Audio ||
|
|
||||||
item?.Type === BaseItemKind.AudioBook ||
|
|
||||||
item?.Type === BaseItemKind.Episode ||
|
|
||||||
item?.Type === BaseItemKind.Movie ||
|
|
||||||
item?.Type === BaseItemKind.Video ||
|
|
||||||
Boolean(item?.MediaType === "Video")) &&
|
|
||||||
(session.PlayState?.PositionTicks ?? 0) >= MIN_POSITION_TICKS
|
|
||||||
);
|
|
||||||
});
|
|
||||||
if (options.length === 0) return undefined;
|
|
||||||
options.sort((a, b) => {
|
|
||||||
const aAt = a.LastPlaybackCheckIn ? Date.parse(a.LastPlaybackCheckIn) : 0;
|
|
||||||
const bAt = b.LastPlaybackCheckIn ? Date.parse(b.LastPlaybackCheckIn) : 0;
|
|
||||||
if (aAt !== bAt) return bAt - aAt;
|
|
||||||
return (
|
|
||||||
(b.PlayState?.PositionTicks ?? 0) - (a.PlayState?.PositionTicks ?? 0)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
const session = options[0];
|
|
||||||
const item = session.NowPlayingItem;
|
|
||||||
if (!session.Id || !item?.Id) return undefined;
|
|
||||||
const position = session.PlayState?.PositionTicks ?? 0;
|
|
||||||
const key = `${session.Id}:${item.Id}`;
|
|
||||||
if (dismissed[key]) return undefined;
|
|
||||||
return { session, item, position, key };
|
|
||||||
}, [
|
|
||||||
api,
|
|
||||||
user?.Id,
|
|
||||||
localActive,
|
|
||||||
realtimeSessions,
|
|
||||||
sessionsQuery.data,
|
|
||||||
dismissed,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const dismiss = useCallback((key: string) => {
|
|
||||||
setDismissed((current) => {
|
|
||||||
const next = { ...current, [key]: Date.now() };
|
|
||||||
sessionStorage.setItem(DISMISS_STORAGE_KEY, JSON.stringify(next));
|
|
||||||
return next;
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleContinue = useCallback(async () => {
|
|
||||||
if (!api || !user?.Id || !candidate) return;
|
|
||||||
setTransferring(true);
|
|
||||||
try {
|
|
||||||
const kind = await transferSessionToLocal(
|
|
||||||
api,
|
|
||||||
user.Id,
|
|
||||||
candidate.session,
|
|
||||||
);
|
|
||||||
dismiss(candidate.key);
|
|
||||||
if (kind === "video") navigate({ to: "/player" });
|
|
||||||
if (kind === "audio") navigate({ to: "/player/audio" });
|
|
||||||
if (kind !== "none") {
|
|
||||||
enqueueSnackbar(`Продолжаем с ${deviceLabel(candidate.session)}`, {
|
|
||||||
variant: "success",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Follow-me transfer failed", error);
|
|
||||||
enqueueSnackbar("Не удалось продолжить воспроизведение здесь", {
|
|
||||||
variant: "error",
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setTransferring(false);
|
|
||||||
}
|
|
||||||
}, [api, user?.Id, candidate, dismiss, enqueueSnackbar, navigate]);
|
|
||||||
|
|
||||||
if (!candidate || !api) return null;
|
|
||||||
const { item, session, position } = candidate;
|
|
||||||
const paused = Boolean(session.PlayState?.IsPaused);
|
|
||||||
const imageUrl = getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
posterId(item) ?? item.Id ?? "",
|
|
||||||
"Primary",
|
|
||||||
{ fillHeight: 168, fillWidth: 112, quality: 85 },
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Paper
|
|
||||||
elevation={10}
|
|
||||||
sx={{
|
|
||||||
position: "fixed",
|
|
||||||
left: 24,
|
|
||||||
bottom: 24,
|
|
||||||
zIndex: 1300,
|
|
||||||
display: "flex",
|
|
||||||
gap: 1.5,
|
|
||||||
alignItems: "stretch",
|
|
||||||
width: "min(360px, calc(100vw - 48px))",
|
|
||||||
p: 1.25,
|
|
||||||
borderRadius: "18px",
|
|
||||||
background: "rgba(18, 16, 38, 0.94)",
|
|
||||||
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
||||||
backdropFilter: "blur(24px)",
|
|
||||||
boxShadow: "0 16px 48px rgba(0, 0, 0, 0.45)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
component="img"
|
|
||||||
src={imageUrl}
|
|
||||||
alt=""
|
|
||||||
sx={{
|
|
||||||
width: 56,
|
|
||||||
height: 84,
|
|
||||||
flex: "0 0 auto",
|
|
||||||
objectFit: "cover",
|
|
||||||
borderRadius: "10px",
|
|
||||||
background: "rgba(255,255,255,0.06)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Box
|
|
||||||
sx={{ minWidth: 0, flex: 1, display: "flex", flexDirection: "column" }}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="overline"
|
|
||||||
sx={{ lineHeight: 1.2, opacity: 0.65, letterSpacing: 0.8 }}
|
|
||||||
>
|
|
||||||
{paused ? "Пауза на" : "Идёт на"} {deviceLabel(session)}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="subtitle2" noWrap sx={{ fontWeight: 700 }}>
|
|
||||||
{item.SeriesName ?? item.Name ?? "Продолжить просмотр"}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="caption" noWrap sx={{ opacity: 0.65 }}>
|
|
||||||
{item.SeriesName && item.Name ? `${item.Name} · ` : ""}
|
|
||||||
{formatTime(position)}
|
|
||||||
</Typography>
|
|
||||||
<Box sx={{ display: "flex", gap: 0.5, mt: "auto", pt: 0.5 }}>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
variant="contained"
|
|
||||||
onClick={handleContinue}
|
|
||||||
disabled={transferring}
|
|
||||||
sx={{ textTransform: "none", borderRadius: "999px" }}
|
|
||||||
>
|
|
||||||
{transferring ? "Запуск…" : "Продолжить здесь"}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
onClick={() => dismiss(candidate.key)}
|
|
||||||
sx={{ textTransform: "none", borderRadius: "999px", opacity: 0.7 }}
|
|
||||||
>
|
|
||||||
Не сейчас
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Tooltip title="Скрыть">
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
aria-label="Скрыть предложение"
|
|
||||||
onClick={() => dismiss(candidate.key)}
|
|
||||||
sx={{ alignSelf: "flex-start", opacity: 0.55 }}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded" style={{ fontSize: 18 }}>
|
|
||||||
close
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
</Paper>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default React.memo(FollowMe);
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Link, Tooltip } from "@mui/material";
|
import { Link, Typography } 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,49 +12,54 @@ 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 = [
|
||||||
* Provider icons keyed by the start of the normalized link name, so variants like
|
"imdb",
|
||||||
* "TMDB"/"TheMovieDb", "TVDB"/"TheTVDB" or "MusicBrainz Artist" all match.
|
"themoviedb",
|
||||||
*/
|
"trakt",
|
||||||
const providerIcons: [prefixes: string[], icon: string][] = [
|
"musicbrainz",
|
||||||
[["imdb"], imdbIcon],
|
"thetvdb",
|
||||||
[["tmdb", "themoviedb"], tmdbIcon],
|
"anidb",
|
||||||
[["tvdb", "thetvdb"], tvDbIcon],
|
"anilist",
|
||||||
[["trakt"], traktIcon],
|
"tvmaze",
|
||||||
[["musicbrainz"], musicBrainzIcon],
|
"theaudiodb",
|
||||||
[["anidb"], anidbIcon],
|
"kitsu",
|
||||||
[["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 (
|
||||||
<Tooltip title={name}>
|
<Link target="_blank" href={url} className="item-detail-link">
|
||||||
<Link
|
{name.toLocaleLowerCase() === "imdb" && <img src={imdbIcon} alt="IMDb" />}
|
||||||
target="_blank"
|
{name.toLocaleLowerCase() === "themoviedb" && (
|
||||||
href={url}
|
<img src={tmdbIcon} alt="TheMovieDb" />
|
||||||
className="item-detail-link"
|
)}
|
||||||
aria-label={name}
|
{name.toLocaleLowerCase() === "trakt" && (
|
||||||
>
|
<img src={traktIcon} alt="Trakt" />
|
||||||
{icon ? (
|
)}
|
||||||
<img src={icon} alt={name} />
|
{name.toLocaleLowerCase() === "musicbrainz" && (
|
||||||
) : (
|
<img src={musicBrainzIcon} alt="MusicBrainz" />
|
||||||
<span className="material-symbols-rounded item-detail-link-generic">
|
)}
|
||||||
link
|
{name.toLocaleLowerCase() === "thetvdb" && (
|
||||||
</span>
|
<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>
|
</Link>
|
||||||
</Tooltip>
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,10 @@ interface ItemBackdropProps {
|
|||||||
const MotionImg = motion.img;
|
const MotionImg = motion.img;
|
||||||
|
|
||||||
const animationProps = {
|
const animationProps = {
|
||||||
// Do not fade in from black on every navigation: cached artwork should be
|
initial: { opacity: 0 },
|
||||||
// visible immediately (a fade here reads as a flash).
|
|
||||||
initial: { opacity: 1 },
|
|
||||||
animate: { opacity: 1 },
|
animate: { opacity: 1 },
|
||||||
exit: { opacity: 0 },
|
exit: { opacity: 0 },
|
||||||
transition: { duration: 0.3 },
|
transition: { duration: 0.5 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,9 +113,6 @@ export function ItemBackdrop({
|
|||||||
alt={alt}
|
alt={alt}
|
||||||
src={src}
|
src={src}
|
||||||
className={className ?? "item-hero-backdrop"}
|
className={className ?? "item-hero-backdrop"}
|
||||||
ref={(el) => {
|
|
||||||
if (el?.complete && el.naturalWidth > 0) el.style.opacity = "1";
|
|
||||||
}}
|
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.opacity = "1";
|
e.currentTarget.style.opacity = "1";
|
||||||
onLoad?.(e);
|
onLoad?.(e);
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import { getTypeIcon } from "@/components/utils/iconsCollection";
|
|||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
|
||||||
const groups = [
|
const groups = [
|
||||||
{ type: "Actor", title: "Актёры" },
|
{ type: "Actor", title: "Actors" },
|
||||||
{ type: "Writer", title: "Сценаристы" },
|
{ type: "Writer", title: "Writers" },
|
||||||
{ type: "Director", title: "Режиссёры" },
|
{ type: "Director", title: "Directors" },
|
||||||
{ type: "Producer", title: "Продюсеры" },
|
{ type: "Producer", title: "Producers" },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
type CastAndCrewProps = {
|
type CastAndCrewProps = {
|
||||||
@@ -33,7 +33,7 @@ const CastAndCrew = ({ people, api }: CastAndCrewProps) => {
|
|||||||
return (
|
return (
|
||||||
<div className="item-detail-cast">
|
<div className="item-detail-cast">
|
||||||
<Typography variant="h5" sx={{ mb: 2 }}>
|
<Typography variant="h5" sx={{ mb: 2 }}>
|
||||||
Актёры и команда
|
Cast & Crew
|
||||||
</Typography>
|
</Typography>
|
||||||
{grouped.map(
|
{grouped.map(
|
||||||
(group) =>
|
(group) =>
|
||||||
|
|||||||
@@ -101,6 +101,8 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -206,16 +208,6 @@
|
|||||||
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 {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { motion } from "motion/react";
|
import { motion } from "motion/react";
|
||||||
import React, { type ReactNode, useEffect, useRef } from "react";
|
import React, { type ReactNode, useEffect, useRef } from "react";
|
||||||
import CastButton from "@/components/buttons/castButton";
|
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||||
import TrailerButton from "@/components/buttons/trailerButton";
|
import TrailerButton from "@/components/buttons/trailerButton";
|
||||||
@@ -15,7 +14,6 @@ import ShowMoreText from "@/components/showMoreText";
|
|||||||
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";
|
||||||
import useHeaderStore from "@/utils/store/header";
|
|
||||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||||
|
|
||||||
import "./itemDetail.scss";
|
import "./itemDetail.scss";
|
||||||
@@ -76,34 +74,18 @@ const ItemDetailLayout = ({
|
|||||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||||
const queryKey = ["item", item.Id ?? ""];
|
const queryKey = ["item", item.Id ?? ""];
|
||||||
|
|
||||||
const canCast =
|
|
||||||
item.Type === BaseItemKind.Movie ||
|
|
||||||
item.Type === BaseItemKind.Episode ||
|
|
||||||
item.Type === BaseItemKind.Audio ||
|
|
||||||
item.Type === BaseItemKind.AudioBook ||
|
|
||||||
item.Type === BaseItemKind.MusicVideo ||
|
|
||||||
item.Type === BaseItemKind.Video ||
|
|
||||||
item.Type === BaseItemKind.Trailer;
|
|
||||||
|
|
||||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||||
const hash = backdropHash ?? getDefaultBackdropHash(item);
|
const hash = backdropHash ?? getDefaultBackdropHash(item);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setBackdrop(hash);
|
setBackdrop(hash);
|
||||||
}, [hash, setBackdrop]);
|
}, [hash, setBackdrop]);
|
||||||
|
|
||||||
// Show a human-readable location in the global app bar.
|
|
||||||
const setPageTitle = useHeaderStore((state) => state.setPageTitle);
|
|
||||||
useEffect(() => {
|
|
||||||
setPageTitle(item.Name ?? null);
|
|
||||||
return () => setPageTitle(null);
|
|
||||||
}, [item.Name, setPageTitle]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
initial={{ opacity: 1 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
transition={{ duration: 0.12, ease: "easeOut" }}
|
transition={{ duration: 0.3, ease: "easeInOut" }}
|
||||||
className={`scrollY padded-top flex flex-column item item-detail-page item-${variant}`}
|
className={`scrollY padded-top flex flex-column item item-detail-page item-${variant}`}
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
>
|
>
|
||||||
@@ -132,7 +114,6 @@ const ItemDetailLayout = ({
|
|||||||
isFavorite={item.UserData?.IsFavorite}
|
isFavorite={item.UserData?.IsFavorite}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
{canCast && <CastButton item={item} />}
|
|
||||||
{showMarkPlayed && (
|
{showMarkPlayed && (
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemName={item.Name}
|
itemName={item.Name}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export const TrackSelectors = ({
|
|||||||
<>
|
<>
|
||||||
{tracks.video.length > 0 && (
|
{tracks.video.length > 0 && (
|
||||||
<TextField
|
<TextField
|
||||||
label="Видео"
|
label="Video"
|
||||||
select
|
select
|
||||||
style={{ width: "100%", marginBottom: "1em" }}
|
style={{ width: "100%", marginBottom: "1em" }}
|
||||||
value={selection.video}
|
value={selection.video}
|
||||||
@@ -134,7 +134,7 @@ export const TrackSelectors = ({
|
|||||||
)}
|
)}
|
||||||
{tracks.audio.length > 0 && (
|
{tracks.audio.length > 0 && (
|
||||||
<TextField
|
<TextField
|
||||||
label="Аудио"
|
label="Audio"
|
||||||
select
|
select
|
||||||
style={{ width: "100%", marginBottom: "1em" }}
|
style={{ width: "100%", marginBottom: "1em" }}
|
||||||
value={selection.audio}
|
value={selection.audio}
|
||||||
@@ -150,7 +150,7 @@ export const TrackSelectors = ({
|
|||||||
)}
|
)}
|
||||||
{tracks.subtitle.length > 0 && (
|
{tracks.subtitle.length > 0 && (
|
||||||
<TextField
|
<TextField
|
||||||
label="Субтитры"
|
label="Subtitle"
|
||||||
select
|
select
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
value={selection.subtitle}
|
value={selection.subtitle}
|
||||||
@@ -159,7 +159,7 @@ export const TrackSelectors = ({
|
|||||||
onChange={(e) => setSelection({ subtitle: Number(e.target.value) })}
|
onChange={(e) => setSelection({ subtitle: Number(e.target.value) })}
|
||||||
>
|
>
|
||||||
<MenuItem key={-1} value={-1}>
|
<MenuItem key={-1} value={-1}>
|
||||||
Без субтитров
|
No Subtitle
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{tracks.subtitle.map((track) => (
|
{tracks.subtitle.map((track) => (
|
||||||
<MenuItem key={track.Index} value={track.Index}>
|
<MenuItem key={track.Index} value={track.Index}>
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ export const getItemCardCaption = (item: BaseItemDto) => {
|
|||||||
}
|
}
|
||||||
if (item.Type === BaseItemKind.Series) {
|
if (item.Type === BaseItemKind.Series) {
|
||||||
const end = item.EndDate
|
const end = item.EndDate
|
||||||
? new Date(item.EndDate).toLocaleString("ru-RU", { year: "numeric" })
|
? new Date(item.EndDate).toLocaleString([], { year: "numeric" })
|
||||||
: "н.в.";
|
: "Present";
|
||||||
return `${item.ProductionYear} - ${end}`;
|
return `${item.ProductionYear} - ${end}`;
|
||||||
}
|
}
|
||||||
return item.ProductionYear;
|
return item.ProductionYear;
|
||||||
@@ -38,7 +38,7 @@ const SimilarItems = ({ item }: { item: BaseItemDto }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<CardScroller
|
<CardScroller
|
||||||
title="Вам может понравиться"
|
title="You might also like"
|
||||||
displayCards={7}
|
displayCards={7}
|
||||||
disableDecoration
|
disableDecoration
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const UpcomingEpisodes = ({ episode }: { episode: BaseItemDto }) => {
|
|||||||
if (!upcomingEpisodes.data?.Items?.length) return null;
|
if (!upcomingEpisodes.data?.Items?.length) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardScroller title="Будущие серии" displayCards={4} disableDecoration>
|
<CardScroller title="Upcoming Episodes" displayCards={4} disableDecoration>
|
||||||
{upcomingEpisodes.data.Items.map((upcoming) => (
|
{upcomingEpisodes.data.Items.map((upcoming) => (
|
||||||
<Card
|
<Card
|
||||||
key={upcoming.Id}
|
key={upcoming.Id}
|
||||||
|
|||||||
@@ -53,19 +53,19 @@ const PersonView = ({ item }: { item: BaseItemDto }) => {
|
|||||||
<>
|
<>
|
||||||
{item.PremiereDate && (
|
{item.PremiereDate && (
|
||||||
<div>
|
<div>
|
||||||
<Typography variant="h6">Дата рождения</Typography>
|
<Typography variant="h6">Birth</Typography>
|
||||||
<Typography variant="subtitle1" sx={{ opacity: 0.8 }}>
|
<Typography variant="subtitle1" sx={{ opacity: 0.8 }}>
|
||||||
{new Date(item.PremiereDate).toLocaleDateString("ru-RU")}
|
{new Date(item.PremiereDate).toDateString()}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{item.EndDate && (
|
{item.EndDate && (
|
||||||
<div>
|
<div>
|
||||||
<Typography variant="h6" sx={{ mt: 2 }}>
|
<Typography variant="h6" sx={{ mt: 2 }}>
|
||||||
Дата смерти
|
Death
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="subtitle2" sx={{ opacity: 0.8 }}>
|
<Typography variant="subtitle2" sx={{ opacity: 0.8 }}>
|
||||||
{new Date(item.EndDate).toLocaleDateString("ru-RU")}
|
{new Date(item.EndDate).toDateString()}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import ItemDetailLayout, { ExternalLinks } from "../itemDetailLayout";
|
|||||||
import SimilarItems from "../similarItems";
|
import SimilarItems from "../similarItems";
|
||||||
|
|
||||||
const getEpisodeDateString = (date: Date) =>
|
const getEpisodeDateString = (date: Date) =>
|
||||||
new Intl.DateTimeFormat("ru-RU", {
|
new Intl.DateTimeFormat(navigator.language ?? "en-US", {
|
||||||
dateStyle: "full",
|
dateStyle: "full",
|
||||||
}).format(date);
|
}).format(date);
|
||||||
|
|
||||||
@@ -339,7 +339,7 @@ const SeriesView = ({ item }: { item: BaseItemDto }) => {
|
|||||||
<CastAndCrew people={item.People} api={api} />
|
<CastAndCrew people={item.People} api={api} />
|
||||||
{(specialFeatures.data?.length ?? 0) > 0 && (
|
{(specialFeatures.data?.length ?? 0) > 0 && (
|
||||||
<CardScroller
|
<CardScroller
|
||||||
title="Дополнительные материалы"
|
title="Special Features"
|
||||||
displayCards={7}
|
displayCards={7}
|
||||||
disableDecoration
|
disableDecoration
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ const ItemHeader = ({
|
|||||||
backdropSrc,
|
backdropSrc,
|
||||||
}: ItemHeaderProps) => {
|
}: ItemHeaderProps) => {
|
||||||
const isEpisode = item.Type === "Episode";
|
const isEpisode = item.Type === "Episode";
|
||||||
// A runtime / "ends at" is meaningless for people and artists (it sums their whole catalogue)
|
|
||||||
const showRuntime = item.Type !== "MusicArtist" && item.Type !== "Person";
|
|
||||||
const backdropTag =
|
const backdropTag =
|
||||||
isEpisode && item.ParentBackdropImageTags?.length
|
isEpisode && item.ParentBackdropImageTags?.length
|
||||||
? item.ParentBackdropImageTags[0]
|
? item.ParentBackdropImageTags[0]
|
||||||
@@ -77,6 +75,9 @@ const ItemHeader = ({
|
|||||||
tag: logoTag,
|
tag: logoTag,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
className="item-hero-logo"
|
className="item-hero-logo"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -140,6 +141,9 @@ const ItemHeader = ({
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
className="item-hero-image"
|
className="item-hero-image"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -290,12 +294,12 @@ const ItemHeader = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{showRuntime && item.RunTimeTicks && (
|
{item.RunTimeTicks && (
|
||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{getRuntime(item.RunTimeTicks)}
|
{getRuntime(item.RunTimeTicks)}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
{showRuntime && item.RunTimeTicks && (
|
{item.RunTimeTicks && (
|
||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{endsAt(
|
{endsAt(
|
||||||
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ $cardWidth: 18%;
|
|||||||
grid-template-columns: $cardWidth 1fr;
|
grid-template-columns: $cardWidth 1fr;
|
||||||
grid-template-rows: 1fr auto;
|
grid-template-rows: 1fr auto;
|
||||||
&-image {
|
&-image {
|
||||||
|
opacity: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
&-container {
|
&-container {
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
@@ -45,6 +47,8 @@ $cardWidth: 18%;
|
|||||||
&-logo {
|
&-logo {
|
||||||
max-width: 34rem;
|
max-width: 34rem;
|
||||||
max-height: 10rem;
|
max-height: 10rem;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
object-position: bottom;
|
object-position: bottom;
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
}
|
}
|
||||||
@@ -70,9 +74,11 @@ $cardWidth: 18%;
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
object-position: top;
|
object-position: top;
|
||||||
|
opacity: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
&-container {
|
&-container {
|
||||||
filter: brightness(0.8);
|
filter: brightness(0.8);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
|||||||
{!!album.ImageTags?.Primary && (
|
{!!album.ImageTags?.Primary && (
|
||||||
<div className="album-image">
|
<div className="album-image">
|
||||||
<img
|
<img
|
||||||
alt={album.Name ?? "Обложка альбома"}
|
alt={album.Name ?? "Album Image"}
|
||||||
src={`${api?.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
src={`${api?.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
@@ -150,8 +150,8 @@ export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
|||||||
<div>
|
<div>
|
||||||
<div className="item-info-track header">
|
<div className="item-info-track header">
|
||||||
<span className="material-symbols-rounded index">tag</span>
|
<span className="material-symbols-rounded index">tag</span>
|
||||||
<Typography variant="subtitle1">Название</Typography>
|
<Typography variant="subtitle1">Title</Typography>
|
||||||
<Typography variant="subtitle1">Длительность</Typography>
|
<Typography variant="subtitle1">Duration</Typography>
|
||||||
</div>
|
</div>
|
||||||
{albumTracks.data?.Items?.map((track, index) => (
|
{albumTracks.data?.Items?.map((track, index) => (
|
||||||
<AlbumMusicTrack
|
<AlbumMusicTrack
|
||||||
|
|||||||
@@ -45,14 +45,14 @@ export const LatestMediaSection = ({
|
|||||||
item.Type === BaseItemKind.Episode
|
item.Type === BaseItemKind.Episode
|
||||||
? `S${item.ParentIndexNumber ?? 0}:E${
|
? `S${item.ParentIndexNumber ?? 0}:E${
|
||||||
item.IndexNumber ?? 0
|
item.IndexNumber ?? 0
|
||||||
} - ${item.Name ?? "Неизвестно"}`
|
} - ${item.Name ?? "Unknown"}`
|
||||||
: item.Type === BaseItemKind.Series
|
: item.Type === BaseItemKind.Series
|
||||||
? `${item.ProductionYear} - ${
|
? `${item.ProductionYear} - ${
|
||||||
item.EndDate
|
item.EndDate
|
||||||
? new Date(item.EndDate).toLocaleString("ru-RU", {
|
? new Date(item.EndDate).toLocaleString([], {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
})
|
})
|
||||||
: "н.в."
|
: "Present"
|
||||||
}`
|
}`
|
||||||
: item.ProductionYear
|
: item.ProductionYear
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import { useLibraryStateStore } from "@/utils/store/libraryState";
|
|||||||
import useSearchStore from "@/utils/store/search";
|
import useSearchStore from "@/utils/store/search";
|
||||||
import { NavigationDrawer } from "../appBar/navigationDrawer";
|
import { NavigationDrawer } from "../appBar/navigationDrawer";
|
||||||
import BackButton from "../buttons/backButton";
|
import BackButton from "../buttons/backButton";
|
||||||
import CastButton from "../buttons/castButton";
|
|
||||||
import { FiltersDialogTrigger } from "../filtersDialog";
|
import { FiltersDialogTrigger } from "../filtersDialog";
|
||||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||||
import "./libraryHeader.scss";
|
import "./libraryHeader.scss";
|
||||||
@@ -259,7 +258,6 @@ export const LibraryHeader = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AppBar
|
<AppBar
|
||||||
data-tauri-drag-region
|
|
||||||
className={
|
className={
|
||||||
scrollTrigger
|
scrollTrigger
|
||||||
? "library-header scrolling flex flex-row"
|
? "library-header scrolling flex flex-row"
|
||||||
@@ -269,20 +267,12 @@ export const LibraryHeader = () => {
|
|||||||
elevation={0}
|
elevation={0}
|
||||||
color="transparent"
|
color="transparent"
|
||||||
>
|
>
|
||||||
<div className="flex flex-row" data-tauri-drag-region style={{ gap: "0.6em" }}>
|
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||||
<IconButton
|
<IconButton onClick={handleDrawerOpen}>
|
||||||
onClick={handleDrawerOpen}
|
|
||||||
aria-label="Открыть меню"
|
|
||||||
title="Открыть меню"
|
|
||||||
>
|
|
||||||
<div className="material-symbols-rounded">menu</div>
|
<div className="material-symbols-rounded">menu</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<MemoizeBackButton />
|
<MemoizeBackButton />
|
||||||
<IconButton
|
<IconButton onClick={handleNavigateToHome}>
|
||||||
onClick={handleNavigateToHome}
|
|
||||||
aria-label="Главная"
|
|
||||||
title="Главная"
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
location.pathname === "/home"
|
location.pathname === "/home"
|
||||||
@@ -300,7 +290,7 @@ export const LibraryHeader = () => {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="library-title-count flex flex-row flex-align-center"
|
className="library-title-count flex flex-row flex-align-center"
|
||||||
title={`${libraryName}${typeof totalCount === "number" ? ` · ${totalCount.toLocaleString()} элементов` : ""}`}
|
title={`${libraryName}${typeof totalCount === "number" ? ` · ${totalCount.toLocaleString()} items` : ""}`}
|
||||||
>
|
>
|
||||||
<Typography variant="subtitle1" noWrap align="center">
|
<Typography variant="subtitle1" noWrap align="center">
|
||||||
{libraryName}
|
{libraryName}
|
||||||
@@ -324,7 +314,7 @@ export const LibraryHeader = () => {
|
|||||||
>
|
>
|
||||||
<MenuItem disabled value="">
|
<MenuItem disabled value="">
|
||||||
<Typography variant="overline" color="textSecondary">
|
<Typography variant="overline" color="textSecondary">
|
||||||
Вид
|
View
|
||||||
</Typography>
|
</Typography>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{compatibleViews.map((v) => (
|
{compatibleViews.map((v) => (
|
||||||
@@ -335,7 +325,7 @@ export const LibraryHeader = () => {
|
|||||||
</TextField>
|
</TextField>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={handleSortAscendingToggle}
|
onClick={handleSortAscendingToggle}
|
||||||
aria-label="Изменить порядок сортировки"
|
aria-label="Toggle sort order"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="material-symbols-rounded"
|
className="material-symbols-rounded"
|
||||||
@@ -362,7 +352,7 @@ export const LibraryHeader = () => {
|
|||||||
>
|
>
|
||||||
<MenuItem disabled value="">
|
<MenuItem disabled value="">
|
||||||
<Typography variant="overline" color="textSecondary">
|
<Typography variant="overline" color="textSecondary">
|
||||||
Сортировка
|
Sort By
|
||||||
</Typography>
|
</Typography>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{SORT_BY_OPTIONS.map((option) => {
|
{SORT_BY_OPTIONS.map((option) => {
|
||||||
@@ -394,26 +384,11 @@ export const LibraryHeader = () => {
|
|||||||
</TextField>
|
</TextField>
|
||||||
<FiltersDialogTrigger />
|
<FiltersDialogTrigger />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||||
className="library-header-actions flex flex-row"
|
<IconButton onClick={toggleSearchDialog}>
|
||||||
style={{ gap: "0.6em" }}
|
|
||||||
>
|
|
||||||
<span className="library-header-cast">
|
|
||||||
<CastButton />
|
|
||||||
</span>
|
|
||||||
<IconButton
|
|
||||||
onClick={toggleSearchDialog}
|
|
||||||
aria-label="Поиск"
|
|
||||||
title="Поиск"
|
|
||||||
>
|
|
||||||
<div className="material-symbols-rounded">search</div>
|
<div className="material-symbols-rounded">search</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton
|
<IconButton onClick={handleNavigateToFavorite}>
|
||||||
className="library-header-favorite"
|
|
||||||
onClick={handleNavigateToFavorite}
|
|
||||||
aria-label="Избранное"
|
|
||||||
title="Избранное"
|
|
||||||
>
|
|
||||||
<div className="material-symbols-rounded">favorite</div>
|
<div className="material-symbols-rounded">favorite</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<UserAvatarMenu />
|
<UserAvatarMenu />
|
||||||
|
|||||||
@@ -1,34 +1,16 @@
|
|||||||
@media (max-width: 980px) {
|
|
||||||
.library-header-cast,
|
|
||||||
.library-header-favorite {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.library-header {
|
.library-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
// Fixed at the very top so the row of controls sits on the same level as
|
|
||||||
// the home page header instead of floating further down the page.
|
|
||||||
inset: 1em 2em auto 2em !important;
|
inset: 1em 2em auto 2em !important;
|
||||||
border-radius: 9999px;
|
border-radius: 9999px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
position: fixed;
|
width: fit-content;
|
||||||
|
position: sticky;
|
||||||
width: calc(100vw - 4em) !important;
|
width: calc(100vw - 4em) !important;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
// Keep the scrolled pill surface behind the controls but above the page.
|
|
||||||
isolation: isolate;
|
|
||||||
padding: 0.25em !important;
|
padding: 0.25em !important;
|
||||||
transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out;
|
transition: all 0.2s ease-in-out;
|
||||||
|
|
||||||
html.is-macos & {
|
|
||||||
// The window has an overlay titlebar: shift the whole pill clear of the
|
|
||||||
// traffic lights, matching the home header's left edge for the controls.
|
|
||||||
width: calc(100vw - 4em - 64px) !important;
|
|
||||||
left: calc(2em + 64px) !important;
|
|
||||||
right: 2em !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
content: "";
|
content: "";
|
||||||
@@ -36,13 +18,10 @@
|
|||||||
inset: -0.35em;
|
inset: -0.35em;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
// Solid titlebar surface: no glass/blur.
|
@include glass-effect;
|
||||||
background-color: $clr-background-default;
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.08);
|
|
||||||
box-shadow: 0 4px 20px rgb(0 0 0 / 0.4);
|
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
transition: opacity 150ms;
|
transition: all 150ms;
|
||||||
}
|
}
|
||||||
&.scrolling {
|
&.scrolling {
|
||||||
&::after {
|
&::after {
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import React, {
|
|||||||
import "./libraryItemsGrid.scss";
|
import "./libraryItemsGrid.scss";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||||
import { AVAILABLE_VIEWS } from "@/utils/constants/library";
|
|
||||||
import { getLibraryItemsQueryOptions } from "@/utils/queries/libraryItems";
|
import { getLibraryItemsQueryOptions } from "@/utils/queries/libraryItems";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
@@ -67,74 +66,31 @@ const LibraryItemsGrid = () => {
|
|||||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||||
);
|
);
|
||||||
|
|
||||||
const collectionType = currentLibrary.data.CollectionType;
|
|
||||||
const defaultViewType: BaseItemKind =
|
|
||||||
collectionType === "music"
|
|
||||||
? BaseItemKind.MusicAlbum
|
|
||||||
: collectionType === "movies"
|
|
||||||
? BaseItemKind.Movie
|
|
||||||
: collectionType === "tvshows"
|
|
||||||
? BaseItemKind.Series
|
|
||||||
: collectionType === "boxsets"
|
|
||||||
? BaseItemKind.BoxSet
|
|
||||||
: collectionType === "books"
|
|
||||||
? BaseItemKind.Book
|
|
||||||
: collectionType === "playlists"
|
|
||||||
? BaseItemKind.Playlist
|
|
||||||
: BaseItemKind.Movie;
|
|
||||||
|
|
||||||
// Persisted slices may hold no view type or a view from another collection
|
|
||||||
// type (e.g. CollectionFolder left by an older build). Reset those.
|
|
||||||
const compatibleViews = AVAILABLE_VIEWS.filter((view) =>
|
|
||||||
view.compatibleCollectionTypes.includes(collectionType as any),
|
|
||||||
).map((view) => view.value);
|
|
||||||
const isViewValid =
|
|
||||||
!!currentViewType &&
|
|
||||||
(compatibleViews.includes(currentViewType) || currentViewType === "Artist");
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentLibraryId && !isViewValid) {
|
if (currentLibraryId && !currentViewType && currentLibrary.data?.Type) {
|
||||||
updateLibrary(currentLibraryId, {
|
updateLibrary(currentLibraryId, {
|
||||||
currentViewType: defaultViewType,
|
currentViewType: currentLibrary.data.Type as BaseItemKind,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [currentLibraryId, isViewValid, defaultViewType, updateLibrary]);
|
}, [
|
||||||
|
currentLibrary.data?.Type,
|
||||||
const effectiveViewType: BaseItemKind | "Artist" = isViewValid
|
currentLibraryId,
|
||||||
? (currentViewType as BaseItemKind | "Artist")
|
currentViewType,
|
||||||
: defaultViewType;
|
updateLibrary,
|
||||||
|
]);
|
||||||
|
|
||||||
const items = useSuspenseQuery(
|
const items = useSuspenseQuery(
|
||||||
getLibraryItemsQueryOptions(api, user?.Id, currentLibraryId, {
|
getLibraryItemsQueryOptions(api, user?.Id, currentLibraryId, {
|
||||||
currentViewType: effectiveViewType,
|
currentViewType,
|
||||||
sortAscending,
|
sortAscending,
|
||||||
sortBy,
|
sortBy,
|
||||||
filters,
|
filters,
|
||||||
videoTypesState,
|
videoTypesState,
|
||||||
nameStartsWith,
|
nameStartsWith,
|
||||||
genreIds,
|
genreIds,
|
||||||
collectionType: collectionType as any,
|
collectionType: currentLibrary.data.CollectionType as any,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// A music library with no album grouping (flat audio files) opens on an
|
|
||||||
// empty "Albums" view. Fall back to Songs so the tracks are visible.
|
|
||||||
useEffect(() => {
|
|
||||||
if (collectionType !== "music") return;
|
|
||||||
if (effectiveViewType !== BaseItemKind.MusicAlbum) return;
|
|
||||||
if (!items.isSuccess) return;
|
|
||||||
if ((items.data?.TotalRecordCount ?? 0) > 0) return;
|
|
||||||
updateLibrary(currentLibraryId, {
|
|
||||||
currentViewType: BaseItemKind.Audio,
|
|
||||||
});
|
|
||||||
}, [
|
|
||||||
collectionType,
|
|
||||||
effectiveViewType,
|
|
||||||
items.isSuccess,
|
|
||||||
items.data?.TotalRecordCount,
|
|
||||||
currentLibraryId,
|
|
||||||
updateLibrary,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// --- Backdrop ---
|
// --- Backdrop ---
|
||||||
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
|
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
|
||||||
const backdropItems = useMemo<BaseItemDto[]>(() => {
|
const backdropItems = useMemo<BaseItemDto[]>(() => {
|
||||||
@@ -171,50 +127,27 @@ const LibraryItemsGrid = () => {
|
|||||||
// --- Virtualization setup ---
|
// --- Virtualization setup ---
|
||||||
const parentRef = useRef<HTMLDivElement | null>(null);
|
const parentRef = useRef<HTMLDivElement | null>(null);
|
||||||
const [containerWidth, setContainerWidth] = useState<number>(0);
|
const [containerWidth, setContainerWidth] = useState<number>(0);
|
||||||
const [scrollMargin, setScrollMargin] = useState<number>(0);
|
|
||||||
|
|
||||||
// Determine column count based on container width (simple heuristic).
|
// Determine column count based on container width (simple heuristic)
|
||||||
// Only width changes matter: observing height caused re-layout feedback while
|
|
||||||
// the window was resized, and a transitioned header made rows jump.
|
|
||||||
const [columns, setColumns] = useState(1);
|
const [columns, setColumns] = useState(1);
|
||||||
useEffect(() => {
|
const measureColumns = useCallback(() => {
|
||||||
const element = parentRef.current;
|
if (!parentRef.current) return;
|
||||||
if (!element) return;
|
const width = parentRef.current.clientWidth;
|
||||||
let frame = 0;
|
|
||||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
||||||
let lastWidth = -1;
|
|
||||||
|
|
||||||
const apply = () => {
|
|
||||||
timer = undefined;
|
|
||||||
const width = element.clientWidth;
|
|
||||||
if (Math.abs(width - lastWidth) < 1) return;
|
|
||||||
lastWidth = width;
|
|
||||||
setContainerWidth(width);
|
setContainerWidth(width);
|
||||||
setColumns(Math.max(1, Math.floor(width / 180)));
|
// Base desired approximate card width (including gap) 180px
|
||||||
// Read offsetTop after the browser has applied the new columns.
|
const ideal = Math.max(1, Math.floor(width / 180));
|
||||||
frame = requestAnimationFrame(() => {
|
setColumns(ideal);
|
||||||
frame = 0;
|
|
||||||
setScrollMargin(element.offsetTop);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const schedule = () => {
|
|
||||||
// While the user drags the window edge, don't reflow the whole grid
|
|
||||||
// on every pixel; repack once the width has been stable briefly.
|
|
||||||
if (timer) clearTimeout(timer);
|
|
||||||
timer = setTimeout(apply, 120);
|
|
||||||
};
|
|
||||||
|
|
||||||
apply();
|
|
||||||
const observer = new ResizeObserver(schedule);
|
|
||||||
observer.observe(element);
|
|
||||||
return () => {
|
|
||||||
observer.disconnect();
|
|
||||||
if (timer) clearTimeout(timer);
|
|
||||||
if (frame) cancelAnimationFrame(frame);
|
|
||||||
};
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
measureColumns();
|
||||||
|
if (!parentRef.current) return;
|
||||||
|
|
||||||
|
const ro = new ResizeObserver(() => measureColumns());
|
||||||
|
ro.observe(parentRef.current);
|
||||||
|
return () => ro.disconnect();
|
||||||
|
}, [measureColumns]);
|
||||||
|
|
||||||
const itemCount = items.data?.Items?.length ?? 0;
|
const itemCount = items.data?.Items?.length ?? 0;
|
||||||
// Compute number of virtual rows
|
// Compute number of virtual rows
|
||||||
const rowCount = Math.ceil(itemCount / columns);
|
const rowCount = Math.ceil(itemCount / columns);
|
||||||
@@ -228,30 +161,23 @@ const LibraryItemsGrid = () => {
|
|||||||
return Math.floor((containerWidth - totalGap) / columns);
|
return Math.floor((containerWidth - totalGap) / columns);
|
||||||
}, [columns, containerWidth]);
|
}, [columns, containerWidth]);
|
||||||
|
|
||||||
// Approximate card height: width / aspect ratio + text block (title + caption).
|
// Approximate tallest card height (portrait ratio ~ 2:3 => height ≈ width / 0.666) + text/footer area
|
||||||
// Square artwork (music, genres) is shorter than portrait posters.
|
// We add a small buffer (20px) for hover overlays and progress bars
|
||||||
const cardAspect = useMemo(() => {
|
const estimatedTallCardHeight = useMemo(
|
||||||
const first = items.data?.Items?.[0];
|
() => Math.round(cardWidth / 0.666666 + 90),
|
||||||
const square =
|
[cardWidth],
|
||||||
first?.Type === BaseItemKind.MusicAlbum ||
|
);
|
||||||
first?.Type === BaseItemKind.Audio ||
|
|
||||||
first?.Type === BaseItemKind.Genre ||
|
|
||||||
first?.Type === BaseItemKind.MusicGenre ||
|
|
||||||
first?.Type === BaseItemKind.Studio ||
|
|
||||||
first?.Type === BaseItemKind.Playlist;
|
|
||||||
return square ? 1 : 0.666666;
|
|
||||||
}, [items.data?.Items]);
|
|
||||||
|
|
||||||
const estimateRowHeight = useCallback(
|
const estimateRowHeight = useCallback(
|
||||||
() => Math.round(cardWidth / cardAspect + 60),
|
() => estimatedTallCardHeight,
|
||||||
[cardWidth, cardAspect],
|
[estimatedTallCardHeight],
|
||||||
);
|
);
|
||||||
|
|
||||||
const virtualizer = useWindowVirtualizer({
|
const virtualizer = useWindowVirtualizer({
|
||||||
count: rowCount,
|
count: rowCount,
|
||||||
estimateSize: estimateRowHeight,
|
estimateSize: estimateRowHeight,
|
||||||
overscan: 4,
|
overscan: 6,
|
||||||
scrollMargin,
|
scrollMargin: parentRef.current?.offsetTop ?? 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const virtualItems = virtualizer.getVirtualItems();
|
const virtualItems = virtualizer.getVirtualItems();
|
||||||
@@ -288,9 +214,9 @@ const LibraryItemsGrid = () => {
|
|||||||
>
|
>
|
||||||
sentiment_dissatisfied
|
sentiment_dissatisfied
|
||||||
</div>
|
</div>
|
||||||
<div style={{ fontSize: 16 }}>Нет элементов для отображения</div>
|
<div style={{ fontSize: 16 }}>No items to show</div>
|
||||||
<div style={{ fontSize: 13, marginTop: 6 }}>
|
<div style={{ fontSize: 13, marginTop: 6 }}>
|
||||||
Попробуйте изменить фильтры, сортировку или выбор по алфавиту.
|
Try adjusting filters, sort, or the A–Z selector.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -319,9 +245,13 @@ const LibraryItemsGrid = () => {
|
|||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "flex-start",
|
alignItems: "flex-start",
|
||||||
gap: `${cardGap}px`,
|
gap: `${cardGap}px`,
|
||||||
|
// Allow natural height; virtualizer will update size after measurement.
|
||||||
|
paddingBottom: "0.6em",
|
||||||
}}
|
}}
|
||||||
data-index={row.index}
|
data-index={row.index}
|
||||||
ref={virtualizer.measureElement}
|
ref={(el) => {
|
||||||
|
if (el) virtualizer.measureElement(el);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{items.data?.Items?.slice(startIndex, endIndex).map(
|
{items.data?.Items?.slice(startIndex, endIndex).map(
|
||||||
(item: BaseItemDto, localIndex: number) => {
|
(item: BaseItemDto, localIndex: number) => {
|
||||||
@@ -357,7 +287,7 @@ const LibraryItemsGrid = () => {
|
|||||||
year: "numeric",
|
year: "numeric",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: "н.в."
|
: "Present"
|
||||||
}`
|
}`
|
||||||
: item?.ProductionYear
|
: item?.ProductionYear
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
type ListItemProps,
|
type ListItemProps,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { createLink } from "@tanstack/react-router";
|
import { createLink, Link } from "@tanstack/react-router";
|
||||||
import React, { forwardRef, type ReactNode } from "react";
|
import React, { forwardRef, type ReactNode } from "react";
|
||||||
|
|
||||||
interface MUIListItemLinkProps extends ListItemProps<"a"> {
|
interface MUIListItemLinkProps extends ListItemProps<"a"> {
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
|
||||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { Link } from "@tanstack/react-router";
|
|
||||||
import React, { type ReactNode, useEffect } from "react";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
|
||||||
|
|
||||||
import "./loginShell.scss";
|
|
||||||
|
|
||||||
type LoginShellProps = {
|
|
||||||
title: ReactNode;
|
|
||||||
subtitle?: ReactNode;
|
|
||||||
/** Max width of the content column. */
|
|
||||||
width?: "narrow" | "wide";
|
|
||||||
children: ReactNode;
|
|
||||||
footer?: ReactNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Shared full-screen layout for the sign-in pages. */
|
|
||||||
const LoginShell = ({
|
|
||||||
title,
|
|
||||||
subtitle,
|
|
||||||
width = "narrow",
|
|
||||||
children,
|
|
||||||
footer,
|
|
||||||
}: LoginShellProps) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
|
|
||||||
const serverInfo = useQuery({
|
|
||||||
queryKey: ["login", "serverInfo"],
|
|
||||||
queryFn: async () =>
|
|
||||||
api ? (await getSystemApi(api).getPublicSystemInfo()).data : null,
|
|
||||||
enabled: Boolean(api),
|
|
||||||
staleTime: 5 * 60_000,
|
|
||||||
});
|
|
||||||
const branding = useQuery({
|
|
||||||
queryKey: ["login", "branding"],
|
|
||||||
queryFn: async () =>
|
|
||||||
api ? (await getBrandingApi(api).getBrandingOptions()).data : null,
|
|
||||||
enabled: Boolean(api),
|
|
||||||
staleTime: 5 * 60_000,
|
|
||||||
});
|
|
||||||
|
|
||||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
|
||||||
useEffect(() => {
|
|
||||||
setBackdrop("");
|
|
||||||
}, [setBackdrop]);
|
|
||||||
|
|
||||||
const serverName = serverInfo.data?.ServerName;
|
|
||||||
const serverHost = api?.basePath.replace(/^https?:\/\//, "");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="login-shell scrollY" data-tauri-drag-region>
|
|
||||||
<div className={`login-shell-content login-shell-${width}`}>
|
|
||||||
{serverHost && (
|
|
||||||
<div className="login-shell-server">
|
|
||||||
<span className="material-symbols-rounded">dns</span>
|
|
||||||
<span className="login-shell-server-name" title={serverHost}>
|
|
||||||
{serverName ?? serverHost}
|
|
||||||
</span>
|
|
||||||
<Link to="/setup/server/list" className="login-shell-server-change">
|
|
||||||
Сменить
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<header className="login-shell-header">
|
|
||||||
<h1 className="login-shell-title">{title}</h1>
|
|
||||||
{subtitle && <p className="login-shell-subtitle">{subtitle}</p>}
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main className="login-shell-body">{children}</main>
|
|
||||||
|
|
||||||
{footer && <footer className="login-shell-footer">{footer}</footer>}
|
|
||||||
|
|
||||||
{branding.data?.LoginDisclaimer && (
|
|
||||||
<aside className="login-shell-disclaimer">
|
|
||||||
<span className="material-symbols-rounded">info</span>
|
|
||||||
<p>{branding.data.LoginDisclaimer}</p>
|
|
||||||
</aside>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default LoginShell;
|
|
||||||
@@ -1,278 +0,0 @@
|
|||||||
.login-shell {
|
|
||||||
// In normal flow (not fixed) so the app bar above stays clickable
|
|
||||||
position: relative;
|
|
||||||
min-height: 100vh;
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 5rem 1.5rem 3rem;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: white;
|
|
||||||
// Soft accent glow instead of a boxed card
|
|
||||||
background:
|
|
||||||
radial-gradient(ellipse 60% 45% at 50% 0%, rgb(255 41 128 / 0.14), transparent 70%),
|
|
||||||
radial-gradient(ellipse 50% 40% at 50% 100%, rgb(110 0 184 / 0.18), transparent 70%);
|
|
||||||
|
|
||||||
&-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
margin: auto 0;
|
|
||||||
gap: 1.5rem;
|
|
||||||
}
|
|
||||||
&-narrow {
|
|
||||||
max-width: 380px;
|
|
||||||
}
|
|
||||||
&-wide {
|
|
||||||
max-width: 880px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-server {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
max-width: 100%;
|
|
||||||
padding: 0.35rem 0.5rem 0.35rem 0.75rem;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: rgb(255 255 255 / 0.06);
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.08);
|
|
||||||
font-size: 0.85rem;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.1rem;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
&-name {
|
|
||||||
opacity: 0.85;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
&-change {
|
|
||||||
flex-shrink: 0;
|
|
||||||
padding: 0.15rem 0.6rem;
|
|
||||||
border-radius: 999px;
|
|
||||||
color: white;
|
|
||||||
font-weight: 600;
|
|
||||||
text-decoration: none;
|
|
||||||
background: rgb(255 255 255 / 0.08);
|
|
||||||
transition: background 0.15s ease;
|
|
||||||
|
|
||||||
&:hover,
|
|
||||||
&:focus-visible {
|
|
||||||
background: rgb(255 255 255 / 0.16);
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-header {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 0.5rem;
|
|
||||||
}
|
|
||||||
&-title {
|
|
||||||
margin: 0;
|
|
||||||
font-size: clamp(1.75rem, 4vw, 2.5rem);
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: -0.02em;
|
|
||||||
line-height: 1.15;
|
|
||||||
}
|
|
||||||
&-subtitle {
|
|
||||||
margin: 0.5rem 0 0;
|
|
||||||
opacity: 0.65;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-body {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-footer {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 0.5rem 1rem;
|
|
||||||
opacity: 0.85;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-disclaimer {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.6rem;
|
|
||||||
max-width: 480px;
|
|
||||||
padding: 0.9rem 1rem;
|
|
||||||
border-radius: 0.75rem;
|
|
||||||
background: rgb(255 255 255 / 0.04);
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.08);
|
|
||||||
font-size: 0.85rem;
|
|
||||||
line-height: 1.5;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.2rem;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 0;
|
|
||||||
opacity: 0.75;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Text-style secondary action used in login footers
|
|
||||||
.login-link {
|
|
||||||
all: unset;
|
|
||||||
cursor: pointer;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.35rem;
|
|
||||||
padding: 0.4rem 0.75rem;
|
|
||||||
border-radius: 999px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
color: rgb(255 255 255 / 0.75);
|
|
||||||
text-decoration: none;
|
|
||||||
transition: background 0.15s ease, color 0.15s ease;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.15rem;
|
|
||||||
}
|
|
||||||
&:hover,
|
|
||||||
&:focus-visible {
|
|
||||||
color: white;
|
|
||||||
background: rgb(255 255 255 / 0.08);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Profile picker
|
|
||||||
.profile-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(128px, 148px));
|
|
||||||
justify-content: center;
|
|
||||||
gap: 1.5rem 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile {
|
|
||||||
all: unset;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.75rem;
|
|
||||||
padding: 0.75rem 0.5rem;
|
|
||||||
border-radius: 1rem;
|
|
||||||
cursor: pointer;
|
|
||||||
color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
&-avatar {
|
|
||||||
position: relative;
|
|
||||||
width: 112px;
|
|
||||||
height: 112px;
|
|
||||||
border-radius: 50%;
|
|
||||||
// Ring that lights up on hover / focus
|
|
||||||
box-shadow: 0 0 0 3px transparent, 0 10px 24px rgb(0 0 0 / 0.4);
|
|
||||||
transition: box-shadow 0.2s ease, transform 0.2s ease;
|
|
||||||
|
|
||||||
img,
|
|
||||||
.profile-avatar-fallback {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 50%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
&-fallback {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 2.75rem;
|
|
||||||
font-weight: 700;
|
|
||||||
background: linear-gradient(135deg, $clr-accent-default, $clr-secondary-default);
|
|
||||||
}
|
|
||||||
&-add {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: rgb(255 255 255 / 0.06);
|
|
||||||
border: 2px dashed rgb(255 255 255 / 0.25);
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 2.5rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-lock {
|
|
||||||
position: absolute;
|
|
||||||
right: 2px;
|
|
||||||
bottom: 2px;
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: rgb(18 18 24);
|
|
||||||
border: 2px solid rgb(18 18 24);
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1rem;
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-name {
|
|
||||||
max-width: 100%;
|
|
||||||
font-weight: 600;
|
|
||||||
opacity: 0.8;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
transition: opacity 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover,
|
|
||||||
&:focus-visible {
|
|
||||||
.profile-avatar {
|
|
||||||
transform: translateY(-3px);
|
|
||||||
box-shadow: 0 0 0 3px $clr-accent-default, 0 14px 30px rgb(0 0 0 / 0.5);
|
|
||||||
}
|
|
||||||
.profile-name {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Password / manual sign-in form
|
|
||||||
.login-form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&-avatar {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
margin-bottom: 0.25rem;
|
|
||||||
|
|
||||||
.profile-avatar {
|
|
||||||
width: 96px;
|
|
||||||
height: 96px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-options {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin: -0.25rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-submit.MuiButton-root {
|
|
||||||
height: 48px;
|
|
||||||
border-radius: 12px;
|
|
||||||
font-weight: 700;
|
|
||||||
text-transform: none;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
import type { Api } from "@jellyfin/sdk";
|
|
||||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { queryOptions } from "@tanstack/react-query";
|
|
||||||
import React, { useState } from "react";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
|
|
||||||
/** Public (listed) users of the current server; shared by the login pages. */
|
|
||||||
export const getPublicUsersQueryOptions = (api: Api | null | undefined) =>
|
|
||||||
queryOptions({
|
|
||||||
queryKey: ["login", "public-users"],
|
|
||||||
queryFn: async () =>
|
|
||||||
api ? (await getUserApi(api).getPublicUsers()).data : [],
|
|
||||||
enabled: Boolean(api),
|
|
||||||
});
|
|
||||||
|
|
||||||
type ProfileAvatarProps = {
|
|
||||||
userId: string;
|
|
||||||
name: string;
|
|
||||||
imageTag?: string | null;
|
|
||||||
/** Shows a lock badge for password-protected profiles. */
|
|
||||||
locked?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Round profile picture, falling back to the user's initial. */
|
|
||||||
export const ProfileAvatar = ({
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
imageTag,
|
|
||||||
locked,
|
|
||||||
}: ProfileAvatarProps) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const [failed, setFailed] = useState(false);
|
|
||||||
const showImage = api && imageTag && !failed;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<span className="profile-avatar">
|
|
||||||
{showImage ? (
|
|
||||||
<img
|
|
||||||
alt=""
|
|
||||||
src={`${api.basePath}/Users/${userId}/Images/Primary?quality=85&fillWidth=224&fillHeight=224&tag=${imageTag}`}
|
|
||||||
onError={() => setFailed(true)}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<span className="profile-avatar-fallback" aria-hidden>
|
|
||||||
{name.trim().charAt(0).toUpperCase() || "?"}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{locked && (
|
|
||||||
<span className="profile-lock" title="Защищено паролем">
|
|
||||||
<span className="material-symbols-rounded">lock</span>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isPasswordProtected = (user: UserDto | undefined) =>
|
|
||||||
user?.HasPassword !== false;
|
|
||||||
@@ -46,7 +46,7 @@ const MusicTrack = ({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<img
|
<img
|
||||||
alt={item.Name ?? "Трек"}
|
alt={item.Name ?? "Music Track"}
|
||||||
src={
|
src={
|
||||||
api &&
|
api &&
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
@@ -105,7 +105,7 @@ const MusicTrack = ({
|
|||||||
{item.HasLyrics && (
|
{item.HasLyrics && (
|
||||||
<img
|
<img
|
||||||
src={lyrics_icon}
|
src={lyrics_icon}
|
||||||
alt="Текст песни"
|
alt="Lyrics"
|
||||||
className="music-track-info-lyrics"
|
className="music-track-info-lyrics"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useNProgress } from "@tanem/react-nprogress";
|
|||||||
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
||||||
import { useRouterState } from "@tanstack/react-router";
|
import { useRouterState } from "@tanstack/react-router";
|
||||||
import React, { useMemo } from "react";
|
import React, { useMemo } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
|
||||||
export default function NProgress() {
|
export default function NProgress() {
|
||||||
const isQueryFetching = useIsFetching();
|
const isQueryFetching = useIsFetching();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const EmptyNotice = ({ extraMsg }: { extraMsg?: string }) => {
|
|||||||
fontWeight: 300,
|
fontWeight: 300,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Ничего не найдено
|
No results found
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="subtitle1"
|
variant="subtitle1"
|
||||||
|
|||||||
@@ -3,14 +3,8 @@ import Typography from "@mui/material/Typography";
|
|||||||
import { red } from "@mui/material/colors";
|
import { red } from "@mui/material/colors";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const ErrorNotice = ({ error }: { error?: unknown }) => {
|
export const ErrorNotice = ({ error }: { error?: Error }) => {
|
||||||
const normalizedError =
|
console.error(error);
|
||||||
error instanceof Error
|
|
||||||
? error
|
|
||||||
: error
|
|
||||||
? new Error(String(error))
|
|
||||||
: undefined;
|
|
||||||
console.error(normalizedError ?? error);
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -37,16 +31,15 @@ export const ErrorNotice = ({ error }: { error?: unknown }) => {
|
|||||||
</div>
|
</div>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h3"
|
variant="h3"
|
||||||
|
color="white"
|
||||||
sx={{
|
sx={{
|
||||||
color: "white",
|
|
||||||
fontWeight: 300,
|
fontWeight: 300,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Что-то пошло не так.
|
Something went wrong.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="body2"
|
variant="h5"
|
||||||
component="pre"
|
|
||||||
style={{
|
style={{
|
||||||
padding: "0.5em",
|
padding: "0.5em",
|
||||||
background: "rgb(0 0 0 / 1)",
|
background: "rgb(0 0 0 / 1)",
|
||||||
@@ -56,17 +49,15 @@ export const ErrorNotice = ({ error }: { error?: unknown }) => {
|
|||||||
maxHeight: "20em",
|
maxHeight: "20em",
|
||||||
overflow: "auto",
|
overflow: "auto",
|
||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
whiteSpace: "pre-wrap",
|
// opacity: 0.6,
|
||||||
}}
|
}}
|
||||||
|
color="gray"
|
||||||
sx={{
|
sx={{
|
||||||
color: "grey.400",
|
|
||||||
fontFamily: "JetBrains Mono Variable",
|
fontFamily: "JetBrains Mono Variable",
|
||||||
|
fontWeight: 100,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{normalizedError
|
{JSON.stringify(error?.stack)}
|
||||||
? normalizedError.stack ||
|
|
||||||
`${normalizedError.name}: ${normalizedError.message}`
|
|
||||||
: "Неизвестная ошибка"}
|
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
if (!item || !item.Type) return null;
|
if (!item || !item.Type) return null;
|
||||||
return (
|
return (
|
||||||
<div className="outro-card">
|
<div className="outro-card">
|
||||||
<Typography variant="h4">Далее</Typography>
|
<Typography variant="h4">Up Next</Typography>
|
||||||
<div className="outro-card-content">
|
<div className="outro-card-content">
|
||||||
{item?.ImageTags?.Primary ? (
|
{item?.ImageTags?.Primary ? (
|
||||||
<img
|
<img
|
||||||
@@ -73,7 +73,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Смотреть
|
Play Now
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={props.handleShowCredits}
|
onClick={props.handleShowCredits}
|
||||||
@@ -81,7 +81,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
color="white"
|
color="white"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
>
|
>
|
||||||
Смотреть титры
|
Watch Credits
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,258 +0,0 @@
|
|||||||
import React, { useEffect, useRef } from "react";
|
|
||||||
|
|
||||||
import "./overlayScrollbar.scss";
|
|
||||||
|
|
||||||
const MIN_THUMB_HEIGHT = 28;
|
|
||||||
const HIDE_DELAY = 1100;
|
|
||||||
const EDGE_ZONE = 28;
|
|
||||||
const SHOW_THROTTLE = 120;
|
|
||||||
|
|
||||||
type Metrics = {
|
|
||||||
maxScroll: number;
|
|
||||||
maxTop: number;
|
|
||||||
scrollable: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getPageScroller = (): HTMLElement =>
|
|
||||||
(document.scrollingElement as HTMLElement | null) ?? document.documentElement;
|
|
||||||
|
|
||||||
const clamp = (value: number, min: number, max: number) =>
|
|
||||||
Math.min(Math.max(value, min), max);
|
|
||||||
|
|
||||||
// Where supported the thumb is driven by a CSS scroll timeline, so it moves
|
|
||||||
// with the compositor and never trails the page. Older engines fall back to
|
|
||||||
// the scroll listener below.
|
|
||||||
const supportsScrollTimeline =
|
|
||||||
typeof CSS !== "undefined" &&
|
|
||||||
CSS.supports("animation-timeline", "scroll(root block)");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overlay scrollbar for the page scroller. It sits on top of the content
|
|
||||||
* instead of taking layout space, so pages no longer shift when the native
|
|
||||||
* scrollbar appears or disappears.
|
|
||||||
*
|
|
||||||
* Measuring (track size, thumb size) happens only when the page or window
|
|
||||||
* size changes. Scrolling just paints the cached thumb position, which keeps
|
|
||||||
* the thumb moving with the page instead of lagging behind it.
|
|
||||||
*/
|
|
||||||
const OverlayScrollbar = () => {
|
|
||||||
const trackRef = useRef<HTMLDivElement>(null);
|
|
||||||
const thumbRef = useRef<HTMLDivElement>(null);
|
|
||||||
const metrics = useRef<Metrics>({ maxScroll: 0, maxTop: 0, scrollable: false });
|
|
||||||
const dragging = useRef(false);
|
|
||||||
const hideTimer = useRef<number | undefined>(undefined);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const track = trackRef.current;
|
|
||||||
const thumb = thumbRef.current;
|
|
||||||
if (!track || !thumb) return;
|
|
||||||
|
|
||||||
const scroller = getPageScroller();
|
|
||||||
document.documentElement.classList.add("has-overlay-scrollbar");
|
|
||||||
document.body.classList.add("has-overlay-scrollbar");
|
|
||||||
|
|
||||||
let frame = 0;
|
|
||||||
let measureTimer = 0;
|
|
||||||
let lastShow = 0;
|
|
||||||
|
|
||||||
const setVisible = (visible: boolean) => {
|
|
||||||
const next = visible ? "true" : "false";
|
|
||||||
if (track.dataset.visible !== next) track.dataset.visible = next;
|
|
||||||
};
|
|
||||||
|
|
||||||
const scheduleHide = () => {
|
|
||||||
if (dragging.current) return;
|
|
||||||
window.clearTimeout(hideTimer.current);
|
|
||||||
hideTimer.current = window.setTimeout(() => {
|
|
||||||
if (!dragging.current) setVisible(false);
|
|
||||||
}, HIDE_DELAY);
|
|
||||||
};
|
|
||||||
|
|
||||||
const show = () => {
|
|
||||||
if (!metrics.current.scrollable) return;
|
|
||||||
setVisible(true);
|
|
||||||
const now = Date.now();
|
|
||||||
if (now - lastShow > SHOW_THROTTLE) {
|
|
||||||
lastShow = now;
|
|
||||||
scheduleHide();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cheap path: only reads scrollTop and writes a compositor-friendly
|
|
||||||
// transform. No layout reads, no track/thumb size writes.
|
|
||||||
const paint = () => {
|
|
||||||
if (supportsScrollTimeline) return;
|
|
||||||
const { scrollable, maxScroll, maxTop } = metrics.current;
|
|
||||||
if (!scrollable || maxScroll <= 0) return;
|
|
||||||
const top = clamp(scroller.scrollTop, 0, maxScroll);
|
|
||||||
const offset = (top / maxScroll) * maxTop;
|
|
||||||
thumb.style.transform = `translate3d(0, ${offset}px, 0)`;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Expensive path: runs on mount and when page/window geometry changes.
|
|
||||||
const measure = () => {
|
|
||||||
// Use the header height rather than its viewport position: the
|
|
||||||
// header scrolls with the page, but the track must stay put.
|
|
||||||
const header = document.querySelector("header");
|
|
||||||
const insetTop = Math.max(
|
|
||||||
0,
|
|
||||||
Math.round(header?.getBoundingClientRect().height ?? 0) + 6,
|
|
||||||
);
|
|
||||||
const trackHeight = Math.max(0, window.innerHeight - insetTop - 6);
|
|
||||||
const topStyle = `${insetTop}px`;
|
|
||||||
const heightStyle = `${trackHeight}px`;
|
|
||||||
if (track.style.top !== topStyle) track.style.top = topStyle;
|
|
||||||
if (track.style.height !== heightStyle) track.style.height = heightStyle;
|
|
||||||
|
|
||||||
const viewport = scroller.clientHeight;
|
|
||||||
const total = scroller.scrollHeight;
|
|
||||||
const scrollable = total - viewport > 1 && trackHeight > 0;
|
|
||||||
|
|
||||||
if (!scrollable) {
|
|
||||||
metrics.current = { maxScroll: 0, maxTop: 0, scrollable: false };
|
|
||||||
track.dataset.scrollable = "false";
|
|
||||||
setVisible(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const thumbHeight = Math.min(
|
|
||||||
trackHeight,
|
|
||||||
Math.max(
|
|
||||||
MIN_THUMB_HEIGHT,
|
|
||||||
Math.round((viewport / total) * trackHeight),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const thumbHeightStyle = `${thumbHeight}px`;
|
|
||||||
if (thumb.style.height !== thumbHeightStyle) {
|
|
||||||
thumb.style.height = thumbHeightStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
const maxTop = trackHeight - thumbHeight;
|
|
||||||
metrics.current = {
|
|
||||||
maxScroll: total - viewport,
|
|
||||||
maxTop,
|
|
||||||
scrollable: true,
|
|
||||||
};
|
|
||||||
track.style.setProperty("--overlay-thumb-travel", `${maxTop}px`);
|
|
||||||
track.dataset.scrollable = "true";
|
|
||||||
paint();
|
|
||||||
};
|
|
||||||
|
|
||||||
const requestMeasure = () => {
|
|
||||||
if (frame) return;
|
|
||||||
frame = window.requestAnimationFrame(() => {
|
|
||||||
frame = 0;
|
|
||||||
window.clearTimeout(measureTimer);
|
|
||||||
measure();
|
|
||||||
});
|
|
||||||
// Animation frames stop in an occluded window, but the page can
|
|
||||||
// still grow (route/data changes). Refresh geometry on a timer too.
|
|
||||||
window.clearTimeout(measureTimer);
|
|
||||||
measureTimer = window.setTimeout(() => {
|
|
||||||
if (frame) {
|
|
||||||
window.cancelAnimationFrame(frame);
|
|
||||||
frame = 0;
|
|
||||||
}
|
|
||||||
measure();
|
|
||||||
}, 250);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onScroll = () => {
|
|
||||||
paint();
|
|
||||||
show();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onResize = () => {
|
|
||||||
requestMeasure();
|
|
||||||
show();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onPointerMove = (event: PointerEvent) => {
|
|
||||||
if (event.clientX >= window.innerWidth - EDGE_ZONE) show();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onVisibilityChange = () => {
|
|
||||||
if (document.hidden) return;
|
|
||||||
measure();
|
|
||||||
show();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onThumbPointerDown = (event: PointerEvent) => {
|
|
||||||
if (event.pointerType === "mouse" && event.button !== 0) return;
|
|
||||||
const { maxScroll, maxTop } = metrics.current;
|
|
||||||
if (maxScroll <= 0 || maxTop <= 0) return;
|
|
||||||
|
|
||||||
event.preventDefault();
|
|
||||||
dragging.current = true;
|
|
||||||
window.clearTimeout(hideTimer.current);
|
|
||||||
setVisible(true);
|
|
||||||
|
|
||||||
const startY = event.clientY;
|
|
||||||
const startScroll = scroller.scrollTop;
|
|
||||||
const ratio = maxScroll / maxTop;
|
|
||||||
|
|
||||||
const onMove = (moveEvent: PointerEvent) => {
|
|
||||||
scroller.scrollTop = startScroll + (moveEvent.clientY - startY) * ratio;
|
|
||||||
paint();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onUp = () => {
|
|
||||||
dragging.current = false;
|
|
||||||
window.removeEventListener("pointermove", onMove);
|
|
||||||
window.removeEventListener("pointerup", onUp);
|
|
||||||
window.removeEventListener("pointercancel", onUp);
|
|
||||||
scheduleHide();
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener("pointermove", onMove);
|
|
||||||
window.addEventListener("pointerup", onUp);
|
|
||||||
window.addEventListener("pointercancel", onUp);
|
|
||||||
};
|
|
||||||
|
|
||||||
measure();
|
|
||||||
show();
|
|
||||||
scheduleHide();
|
|
||||||
|
|
||||||
scroller.addEventListener("scroll", onScroll, { passive: true });
|
|
||||||
window.addEventListener("resize", onResize);
|
|
||||||
window.addEventListener("pointermove", onPointerMove, { passive: true });
|
|
||||||
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
||||||
thumb.addEventListener("pointerdown", onThumbPointerDown);
|
|
||||||
|
|
||||||
const content = document.getElementById("root");
|
|
||||||
const resizeObserver = content ? new ResizeObserver(requestMeasure) : null;
|
|
||||||
if (content && resizeObserver) resizeObserver.observe(content);
|
|
||||||
|
|
||||||
const mutationObserver = new MutationObserver(requestMeasure);
|
|
||||||
mutationObserver.observe(document.body, { childList: true, subtree: true });
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
window.clearTimeout(hideTimer.current);
|
|
||||||
window.clearTimeout(measureTimer);
|
|
||||||
if (frame) window.cancelAnimationFrame(frame);
|
|
||||||
scroller.removeEventListener("scroll", onScroll);
|
|
||||||
window.removeEventListener("resize", onResize);
|
|
||||||
window.removeEventListener("pointermove", onPointerMove);
|
|
||||||
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
||||||
thumb.removeEventListener("pointerdown", onThumbPointerDown);
|
|
||||||
resizeObserver?.disconnect();
|
|
||||||
mutationObserver.disconnect();
|
|
||||||
document.documentElement.classList.remove("has-overlay-scrollbar");
|
|
||||||
document.body.classList.remove("has-overlay-scrollbar");
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
ref={trackRef}
|
|
||||||
className="overlay-scrollbar"
|
|
||||||
data-visible="false"
|
|
||||||
data-scrollable="false"
|
|
||||||
aria-hidden="true"
|
|
||||||
>
|
|
||||||
<div ref={thumbRef} className="overlay-scrollbar__thumb" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default OverlayScrollbar;
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
// Hide the native page scrollbar only. Nested panels keep their own styling.
|
|
||||||
html.has-overlay-scrollbar,
|
|
||||||
body.has-overlay-scrollbar {
|
|
||||||
scrollbar-width: none;
|
|
||||||
-ms-overflow-style: none;
|
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
|
||||||
display: none;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.overlay-scrollbar {
|
|
||||||
--overlay-thumb-travel: 0px;
|
|
||||||
|
|
||||||
position: fixed;
|
|
||||||
top: 70px;
|
|
||||||
right: 2px;
|
|
||||||
z-index: 95;
|
|
||||||
width: 12px;
|
|
||||||
height: calc(100vh - 76px);
|
|
||||||
pointer-events: none;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.2s ease;
|
|
||||||
|
|
||||||
&[data-scrollable="true"] {
|
|
||||||
opacity: 0.45;
|
|
||||||
}
|
|
||||||
|
|
||||||
&[data-visible="true"] {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__thumb {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 3px;
|
|
||||||
width: 6px;
|
|
||||||
min-height: 28px;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: rgb(255 255 255 / 0.28);
|
|
||||||
box-shadow: 0 0 0 1px rgb(0 0 0 / 0.18);
|
|
||||||
pointer-events: auto;
|
|
||||||
cursor: grab;
|
|
||||||
will-change: transform;
|
|
||||||
transition:
|
|
||||||
width 0.15s ease,
|
|
||||||
right 0.15s ease,
|
|
||||||
background-color 0.15s ease;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
right: 2px;
|
|
||||||
width: 8px;
|
|
||||||
background: rgb(255 255 255 / 0.46);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
cursor: grabbing;
|
|
||||||
background: rgb(255 255 255 / 0.58);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scroll-driven thumb for engines that support it: the compositor moves it in
|
|
||||||
// lockstep with the page, so scrolling stays smooth. The JS listener is the
|
|
||||||
// fallback for older engines.
|
|
||||||
@supports (animation-timeline: scroll(root block)) {
|
|
||||||
.overlay-scrollbar__thumb {
|
|
||||||
animation: overlay-scrollbar-thumb linear both;
|
|
||||||
animation-timeline: scroll(root block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes overlay-scrollbar-thumb {
|
|
||||||
from {
|
|
||||||
transform: translate3d(0, 0, 0);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
transform: translate3d(0, var(--overlay-thumb-travel), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
import {
|
|
||||||
PlaystateCommand,
|
|
||||||
type SessionInfoDto,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
|
||||||
import { useEffect, useRef } from "react";
|
|
||||||
import { secToTicks } from "@/utils/date/time";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
|
||||||
import useSyncPlayback from "@/utils/store/syncPlayback";
|
|
||||||
|
|
||||||
const TICKS_PER_SECOND = 10_000_000;
|
|
||||||
/** How far a device may drift before we send a correcting seek. */
|
|
||||||
const DRIFT_TOLERANCE = 2 * TICKS_PER_SECOND;
|
|
||||||
/** Do not hammer a device that is still catching up. */
|
|
||||||
const SEEK_COOLDOWN_MS = 5000;
|
|
||||||
const TICK_MS = 2000;
|
|
||||||
|
|
||||||
/** Session reports are a few seconds old; extrapolate the live position. */
|
|
||||||
const estimateSessionPosition = (session: SessionInfoDto) => {
|
|
||||||
const paused = Boolean(session.PlayState?.IsPaused);
|
|
||||||
const base = session.PlayState?.PositionTicks ?? 0;
|
|
||||||
const lastCheckIn = session.LastPlaybackCheckIn
|
|
||||||
? Date.parse(session.LastPlaybackCheckIn)
|
|
||||||
: Number.NaN;
|
|
||||||
const elapsed = !paused && Number.isFinite(lastCheckIn)
|
|
||||||
? Math.max(0, Date.now() - lastCheckIn)
|
|
||||||
: 0;
|
|
||||||
// 1 ms = 10 000 Jellyfin ticks.
|
|
||||||
return { position: base + elapsed * 10_000, paused };
|
|
||||||
};
|
|
||||||
|
|
||||||
const getLocalState = () => {
|
|
||||||
const video = usePlaybackStore.getState();
|
|
||||||
if (video.metadata.item?.Id && video.playerState.isPlayerReady) {
|
|
||||||
return {
|
|
||||||
active: true,
|
|
||||||
itemId: video.metadata.item.Id,
|
|
||||||
position: secToTicks(video.getCurrentTime()),
|
|
||||||
paused: !video.playerState.isPlayerPlaying,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const audio = useAudioPlayback.getState();
|
|
||||||
if (audio.display && audio.item?.Id) {
|
|
||||||
const element = audio.player.ref?.current;
|
|
||||||
return {
|
|
||||||
active: true,
|
|
||||||
itemId: audio.item.Id,
|
|
||||||
position: element
|
|
||||||
? secToTicks(element.currentTime)
|
|
||||||
: audio.player.currentTick,
|
|
||||||
paused: !audio.player.playing,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return { active: false, itemId: null as string | null, position: 0, paused: false };
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Keeps other Jellyfin sessions aligned with the sync master. This is a
|
|
||||||
* pragmatic seek-based sync (works with any client that accepts remote
|
|
||||||
* commands), not Jellyfin SyncPlay: expect sub-second to ~2 s accuracy plus
|
|
||||||
* the target clients' own buffering.
|
|
||||||
*/
|
|
||||||
const PlaybackSync = () => {
|
|
||||||
const enabled = useSyncPlayback((state) => state.enabled);
|
|
||||||
const master = useSyncPlayback((state) => state.master);
|
|
||||||
const stop = useSyncPlayback((state) => state.stop);
|
|
||||||
const api = useApiInContext((state) => state.api);
|
|
||||||
const user = useCentralStore((state) => state.currentUser);
|
|
||||||
const lastSeek = useRef<Record<string, number>>({});
|
|
||||||
const lastPauseCommand = useRef<Record<string, number>>({});
|
|
||||||
const misses = useRef(0);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!enabled || !master || !api || !user?.Id) return;
|
|
||||||
const userId = user.Id;
|
|
||||||
const sessionApi = getSessionApi(api);
|
|
||||||
let cancelled = false;
|
|
||||||
let busy = false;
|
|
||||||
|
|
||||||
const tick = async () => {
|
|
||||||
if (busy || cancelled) return;
|
|
||||||
if (document.visibilityState !== "visible") return;
|
|
||||||
busy = true;
|
|
||||||
try {
|
|
||||||
const sessions = (await sessionApi.getSessions()).data;
|
|
||||||
let position = 0;
|
|
||||||
let paused = false;
|
|
||||||
let masterFound = false;
|
|
||||||
// The master may move on to the next queue item; follow it.
|
|
||||||
let itemId = master.itemId;
|
|
||||||
|
|
||||||
if (master.sessionId) {
|
|
||||||
const session = sessions.find(
|
|
||||||
(entry) => entry.Id === master.sessionId,
|
|
||||||
);
|
|
||||||
if (session?.NowPlayingItem?.Id) {
|
|
||||||
itemId = session.NowPlayingItem.Id;
|
|
||||||
const estimated = estimateSessionPosition(session);
|
|
||||||
position = estimated.position;
|
|
||||||
paused = estimated.paused;
|
|
||||||
masterFound = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const local = getLocalState();
|
|
||||||
if (local.active && local.itemId) {
|
|
||||||
itemId = local.itemId;
|
|
||||||
position = local.position;
|
|
||||||
paused = local.paused;
|
|
||||||
masterFound = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!masterFound) {
|
|
||||||
misses.current += 1;
|
|
||||||
if (misses.current >= 3) stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
misses.current = 0;
|
|
||||||
|
|
||||||
const followers = sessions.filter(
|
|
||||||
(session) =>
|
|
||||||
session.Id &&
|
|
||||||
session.Id !== master.sessionId &&
|
|
||||||
session.UserId === userId &&
|
|
||||||
session.DeviceId !== api.deviceInfo.id &&
|
|
||||||
session.NowPlayingItem?.Id === itemId,
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const follower of followers) {
|
|
||||||
if (!follower.Id) continue;
|
|
||||||
const playState = follower.PlayState;
|
|
||||||
const followerPaused = Boolean(playState?.IsPaused);
|
|
||||||
|
|
||||||
if (followerPaused !== paused) {
|
|
||||||
const now = Date.now();
|
|
||||||
if (
|
|
||||||
!lastPauseCommand.current[follower.Id] ||
|
|
||||||
now - lastPauseCommand.current[follower.Id] > SEEK_COOLDOWN_MS
|
|
||||||
) {
|
|
||||||
lastPauseCommand.current[follower.Id] = now;
|
|
||||||
try {
|
|
||||||
await sessionApi.sendPlaystateCommand({
|
|
||||||
sessionId: follower.Id,
|
|
||||||
command: paused
|
|
||||||
? PlaystateCommand.Pause
|
|
||||||
: PlaystateCommand.Unpause,
|
|
||||||
controllingUserId: userId,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Sync pause command failed", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playState?.CanSeek === false) continue;
|
|
||||||
const estimated = estimateSessionPosition(follower);
|
|
||||||
if (Math.abs(estimated.position - position) <= DRIFT_TOLERANCE) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const now = Date.now();
|
|
||||||
if (
|
|
||||||
lastSeek.current[follower.Id] &&
|
|
||||||
now - lastSeek.current[follower.Id] < SEEK_COOLDOWN_MS
|
|
||||||
) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
lastSeek.current[follower.Id] = now;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await sessionApi.sendPlaystateCommand({
|
|
||||||
sessionId: follower.Id,
|
|
||||||
command: PlaystateCommand.Seek,
|
|
||||||
seekPositionTicks: Math.max(
|
|
||||||
0,
|
|
||||||
Math.round(
|
|
||||||
position +
|
|
||||||
(paused ? 0 : 0.3 * TICKS_PER_SECOND),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
controllingUserId: userId,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Sync seek failed", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Playback sync tick failed", error);
|
|
||||||
} finally {
|
|
||||||
busy = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tick();
|
|
||||||
const timer = window.setInterval(tick, TICK_MS);
|
|
||||||
return () => {
|
|
||||||
cancelled = true;
|
|
||||||
window.clearInterval(timer);
|
|
||||||
};
|
|
||||||
}, [enabled, master, api, user?.Id, stop]);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default PlaybackSync;
|
|
||||||
@@ -1,426 +1,140 @@
|
|||||||
$art-size: 48px;
|
$image-size: 4em;
|
||||||
|
|
||||||
.audio-player {
|
.audio-player {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0.75rem;
|
bottom: 1rem;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
width: min(1100px, calc(100% - 1.5rem));
|
width: 95%;
|
||||||
height: 80px;
|
max-width: 1200px;
|
||||||
box-sizing: border-box;
|
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
// Equal side columns keep the transport truly centred
|
padding: 0.75em 1.5em;
|
||||||
grid-template-columns: minmax(0, 1fr) minmax(0, 540px) minmax(0, 1fr);
|
gap: 1.5em;
|
||||||
|
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
|
||||||
|
grid-template-columns: 25% 1fr 25%;
|
||||||
|
@include glass-effect($blur: 12px, $bg-color: rgba(18, 18, 18, 0.85));
|
||||||
|
// background: rgba(18, 18, 18, 0.85) !important;
|
||||||
|
// backdrop-filter: blur(12px);
|
||||||
|
// -webkit-backdrop-filter: blur(12px);
|
||||||
|
// border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
border-radius: 1rem;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1.5rem;
|
|
||||||
padding: 0 0.75rem 0 1rem;
|
|
||||||
|
|
||||||
color: white;
|
@media (max-width: 900px) {
|
||||||
// Opaque bar: backdrop-filter over the virtualized grid caused constant
|
grid-template-columns: 1fr auto;
|
||||||
// compositing/shifting on WebKit.
|
padding: 0.5em 1em;
|
||||||
background: rgb(18 18 24 / 0.98);
|
bottom: 0;
|
||||||
border: 1px solid rgb(255 255 255 / 0.08);
|
width: 100%;
|
||||||
border-radius: 14px;
|
border-radius: 0;
|
||||||
box-shadow: 0 12px 40px rgb(0 0 0 / 0.45);
|
border-bottom: none;
|
||||||
|
border-left: none;
|
||||||
|
border-right: none;
|
||||||
|
|
||||||
&-info {
|
.audio-player-controls {
|
||||||
|
display: none; // Hide controls on mobile for now or adjust
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#waveform {
|
||||||
|
width: 100%;
|
||||||
|
transform: scaleY(0);
|
||||||
|
transition: transform $transition-time-default;
|
||||||
|
&[data-show="true"] {
|
||||||
|
transform: scaleY(1) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.75rem;
|
justify-content: center;
|
||||||
min-width: 0;
|
gap: 0.5em;
|
||||||
|
padding: 0.5em 0;
|
||||||
> .MuiIconButton-root {
|
flex-flow: column;
|
||||||
flex-shrink: 0;
|
|
||||||
color: rgb(255 255 255 / 0.75);
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
&-info {
|
||||||
|
display: grid;
|
||||||
|
gap: 1em;
|
||||||
|
grid-template-columns: minmax(0, $image-size) minmax(0, 1fr);
|
||||||
|
width: fit-content;
|
||||||
|
align-items: center;
|
||||||
|
flex-grow: 1;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
&-text {
|
&-text {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
min-width: 0;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-image {
|
&-image {
|
||||||
position: absolute;
|
width: $image-size;
|
||||||
inset: 0;
|
aspect-ratio: 1;
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
||||||
&-container {
|
|
||||||
all: unset;
|
|
||||||
position: relative;
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: $art-size;
|
flex-grow: 1;
|
||||||
height: $art-size;
|
|
||||||
border-radius: 8px;
|
position: relative;
|
||||||
|
&-container {
|
||||||
|
border-radius: $border-radius_04;
|
||||||
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
cursor: pointer;
|
height: fit-content;
|
||||||
background: rgb(255 255 255 / 0.08);
|
aspect-ratio: 1;
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
&:hover .audio-player-image-expand,
|
|
||||||
&:focus-visible .audio-player-image-expand {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
}
|
||||||
}
|
&-icon {
|
||||||
|
|
||||||
&-icon,
|
|
||||||
&-expand {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
}
|
font-size: 2em !important;
|
||||||
|
z-index: 0;
|
||||||
&-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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&-track {
|
||||||
// Transport on top, compact seek row underneath
|
grid-template-columns: $image-size 60% 0.5fr 0.5fr !important;
|
||||||
&-center {
|
}
|
||||||
|
&-playlist{
|
||||||
|
background: $clr-background-dark !important;
|
||||||
|
border: 1.2px solid rgb(255 255 255 / 0.2);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
gap: 1em;
|
||||||
gap: 2px;
|
// Magic scrollbar
|
||||||
min-width: 0;
|
&::-webkit-scrollbar {
|
||||||
|
&-thumb {
|
||||||
.player-controls {
|
height: 150px;
|
||||||
gap: 0.5rem !important;
|
max-height: 33%;
|
||||||
|
|
||||||
.MuiFab-root {
|
|
||||||
width: 36px;
|
|
||||||
height: 36px;
|
|
||||||
min-height: 36px;
|
|
||||||
box-shadow: none;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.6rem !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
&-track {
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
background: transparent !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-progress {
|
&-track{
|
||||||
gap: 0.6rem !important;
|
display: grid;
|
||||||
|
gap: 1em;
|
||||||
.MuiTypography-root {
|
grid-template-columns: 4em 1fr 4em;
|
||||||
min-width: 2.75em !important;
|
|
||||||
font-size: 0.7rem;
|
|
||||||
opacity: 0.6 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.MuiSlider-root {
|
|
||||||
padding: 8px 0;
|
|
||||||
}
|
|
||||||
.MuiSlider-thumb {
|
|
||||||
width: 10px;
|
|
||||||
height: 10px;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.15s ease;
|
|
||||||
}
|
|
||||||
&:hover .MuiSlider-thumb,
|
|
||||||
.MuiSlider-root.Mui-active .MuiSlider-thumb {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-actions {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 0.25rem;
|
|
||||||
min-width: 0;
|
|
||||||
|
|
||||||
.MuiIconButton-root {
|
|
||||||
color: rgb(255 255 255 / 0.75);
|
|
||||||
&:hover {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-volume {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
min-width: 0;
|
|
||||||
|
|
||||||
// Secondary control: neutral and compact
|
|
||||||
.MuiSlider-root {
|
|
||||||
width: 5.5rem !important;
|
|
||||||
color: rgb(255 255 255 / 0.85);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 900px) {
|
|
||||||
.audio-player-volume,
|
|
||||||
.audio-player-progress .MuiTypography-root {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unified, minimal media bar (local playback + remote device control). */
|
|
||||||
.audio-player {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
width: min(1440px, calc(100% - 1.5rem));
|
|
||||||
height: 84px;
|
|
||||||
gap: 1.25rem;
|
|
||||||
padding: 0 0.9rem;
|
|
||||||
background: #0b0c12;
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.08);
|
|
||||||
border-radius: 16px;
|
|
||||||
|
|
||||||
.media-bar {
|
|
||||||
&-left {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.75rem;
|
|
||||||
width: 30%;
|
|
||||||
min-width: 220px;
|
|
||||||
max-width: 360px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-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;
|
cursor: pointer;
|
||||||
|
|
||||||
img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-info {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-width: 0;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-title {
|
|
||||||
font-weight: 600 !important;
|
|
||||||
line-height: 1.2 !important;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
cursor: pointer;
|
|
||||||
&:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-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{
|
&.active{
|
||||||
color: #7cc7ff;
|
color: $clr-accent-default;
|
||||||
}
|
}
|
||||||
.material-symbols-rounded {
|
&-image{
|
||||||
font-size: 1.25rem;
|
background: rgb(255 255 255 / 0.1);
|
||||||
}
|
border: 1.2px solid rgb(255 255 255 / 0.1);
|
||||||
}
|
overflow: hidden;
|
||||||
}
|
border-radius:5px;
|
||||||
|
width: 100%;
|
||||||
&-play {
|
aspect-ratio: 1;
|
||||||
width: 42px !important;
|
height: 4em;
|
||||||
height: 42px !important;
|
|
||||||
margin: 0 0.35rem;
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.35);
|
|
||||||
color: #fff !important;
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.6rem !important;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-progress {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 140px;
|
|
||||||
|
|
||||||
.MuiSlider-root {
|
|
||||||
padding: 10px 0;
|
|
||||||
color: #7cc7ff;
|
|
||||||
}
|
|
||||||
.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: #7cc7ff !important;
|
|
||||||
|
|
||||||
.MuiSlider-rail {
|
|
||||||
background: rgb(255 255 255 / 0.16);
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
.MuiSlider-thumb {
|
|
||||||
width: 10px;
|
|
||||||
height: 10px;
|
|
||||||
background: #fff;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 900px) {
|
|
||||||
.audio-player {
|
|
||||||
.media-bar-left {
|
|
||||||
min-width: 160px;
|
|
||||||
}
|
|
||||||
.media-bar-volume,
|
|
||||||
.media-bar-right .MuiSlider-root {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import type { SessionInfoDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import {
|
|
||||||
Divider,
|
|
||||||
IconButton,
|
|
||||||
ListItemIcon,
|
|
||||||
ListItemText,
|
|
||||||
Menu,
|
|
||||||
MenuItem,
|
|
||||||
Switch,
|
|
||||||
Tooltip,
|
|
||||||
} from "@mui/material";
|
|
||||||
import React, { useState } from "react";
|
|
||||||
|
|
||||||
type DeviceMenuProps = {
|
|
||||||
sessions: SessionInfoDto[];
|
|
||||||
activeRemoteId: string | null;
|
|
||||||
localActive: boolean;
|
|
||||||
localItem?: BaseItemDto | null;
|
|
||||||
onSelectLocal: () => void;
|
|
||||||
onSelectRemote: (session: SessionInfoDto) => void;
|
|
||||||
onOpenRemoteControl: () => void;
|
|
||||||
syncEnabled?: boolean;
|
|
||||||
canSync?: boolean;
|
|
||||||
onToggleSync?: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
const DeviceMenu = ({
|
|
||||||
sessions,
|
|
||||||
activeRemoteId,
|
|
||||||
localActive,
|
|
||||||
localItem,
|
|
||||||
onSelectLocal,
|
|
||||||
onSelectRemote,
|
|
||||||
onOpenRemoteControl,
|
|
||||||
syncEnabled = false,
|
|
||||||
canSync = false,
|
|
||||||
onToggleSync,
|
|
||||||
}: DeviceMenuProps) => {
|
|
||||||
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
|
|
||||||
|
|
||||||
const handleClose = () => setAnchor(null);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Tooltip title="Устройства">
|
|
||||||
<IconButton
|
|
||||||
aria-label="Устройства"
|
|
||||||
onClick={(event) => setAnchor(event.currentTarget)}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">devices</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<Menu
|
|
||||||
anchorEl={anchor}
|
|
||||||
open={Boolean(anchor)}
|
|
||||||
onClose={handleClose}
|
|
||||||
slotProps={{ paper: { className: "glass-menu-paper" } }}
|
|
||||||
>
|
|
||||||
<MenuItem
|
|
||||||
selected={!activeRemoteId}
|
|
||||||
onClick={() => {
|
|
||||||
handleClose();
|
|
||||||
onSelectLocal();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">computer</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText
|
|
||||||
primary="Это устройство"
|
|
||||||
secondary={
|
|
||||||
localActive ? (localItem?.Name ?? "Играет") : "Свободно"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</MenuItem>
|
|
||||||
<Divider />
|
|
||||||
{sessions.length === 0 ? (
|
|
||||||
<MenuItem disabled>
|
|
||||||
<ListItemText primary="Другие устройства не в сети" />
|
|
||||||
</MenuItem>
|
|
||||||
) : (
|
|
||||||
sessions.map((session) => (
|
|
||||||
<MenuItem
|
|
||||||
key={session.Id}
|
|
||||||
selected={session.Id === activeRemoteId}
|
|
||||||
onClick={() => {
|
|
||||||
handleClose();
|
|
||||||
onSelectRemote(session);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
{session.NowPlayingItem ? "tv" : "devices_other"}
|
|
||||||
</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText
|
|
||||||
primary={session.DeviceName || session.Client || "Устройство"}
|
|
||||||
secondary={
|
|
||||||
session.NowPlayingItem?.Name ??
|
|
||||||
session.Client ??
|
|
||||||
"Ничего не играет"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</MenuItem>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
<Divider />
|
|
||||||
<MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
handleClose();
|
|
||||||
onOpenRemoteControl();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">settings_remote</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText primary="Удалённое управление…" />
|
|
||||||
</MenuItem>
|
|
||||||
<Divider />
|
|
||||||
<MenuItem
|
|
||||||
disabled={!canSync}
|
|
||||||
onClick={(event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
onToggleSync?.();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">sync</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText
|
|
||||||
primary="Синхронизация воспроизведения"
|
|
||||||
secondary={
|
|
||||||
syncEnabled
|
|
||||||
? "Устройства следуют за этим сеансом"
|
|
||||||
: "Синхронизировать устройства"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Switch
|
|
||||||
edge="end"
|
|
||||||
checked={syncEnabled}
|
|
||||||
disabled={!canSync}
|
|
||||||
onClick={(event) => event.stopPropagation()}
|
|
||||||
onChange={() => onToggleSync?.()}
|
|
||||||
/>
|
|
||||||
</MenuItem>
|
|
||||||
</Menu>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DeviceMenu;
|
|
||||||
@@ -2,15 +2,20 @@ import type { Api } from "@jellyfin/sdk";
|
|||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getLyricApi } from "@jellyfin/sdk/lib/utils/api/lyric-api";
|
import { getLyricApi } from "@jellyfin/sdk/lib/utils/api/lyric-api";
|
||||||
import { Typography } from "@mui/material";
|
import { Typography } from "@mui/material";
|
||||||
import { queryOptions, useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import React, { useEffect, useRef } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import { secToTicks } from "@/utils/date/time";
|
import { secToTicks } from "@/utils/date/time";
|
||||||
|
|
||||||
export const getLyricsQueryOptions = (
|
interface LyricsPanelProps {
|
||||||
item: BaseItemDto | undefined | null,
|
item: BaseItemDto | undefined | null;
|
||||||
api: Api | undefined,
|
api: Api | undefined;
|
||||||
) =>
|
currentTime: number;
|
||||||
queryOptions({
|
}
|
||||||
|
|
||||||
|
const LyricsPanel = ({ item, api, currentTime }: LyricsPanelProps) => {
|
||||||
|
const lyricsContainer = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
const lyrics = useQuery({
|
||||||
queryKey: ["player", "audio", item?.Id, "lyrics"],
|
queryKey: ["player", "audio", item?.Id, "lyrics"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!item?.Id || !api) {
|
if (!item?.Id || !api) {
|
||||||
@@ -18,30 +23,17 @@ export const getLyricsQueryOptions = (
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const response = await getLyricApi(api).getLyrics({
|
const response = await getLyricApi(api).getLyrics({
|
||||||
itemId: item.Id,
|
itemId: item?.Id,
|
||||||
});
|
});
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch {
|
} catch (e) {
|
||||||
// Items without lyrics return 404
|
console.error("Failed to fetch lyrics", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enabled: Boolean(item?.Id) && Boolean(api),
|
enabled: Boolean(item?.Id) && Boolean(api),
|
||||||
});
|
});
|
||||||
|
|
||||||
interface LyricsPanelProps {
|
|
||||||
item: BaseItemDto | undefined | null;
|
|
||||||
api: Api | undefined;
|
|
||||||
currentTime: number;
|
|
||||||
/** Seeks playback to a position in ticks; enables clicking synced lines. */
|
|
||||||
onSeek?: (ticks: number) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const LyricsPanel = ({ item, api, currentTime, onSeek }: LyricsPanelProps) => {
|
|
||||||
const lyricsContainer = useRef<HTMLDivElement | null>(null);
|
|
||||||
|
|
||||||
const lyrics = useQuery(getLyricsQueryOptions(item, api));
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (lyrics.data && lyricsContainer.current) {
|
if (lyrics.data && lyricsContainer.current) {
|
||||||
const currentLyric = lyricsContainer.current.querySelector(
|
const currentLyric = lyricsContainer.current.querySelector(
|
||||||
@@ -60,7 +52,7 @@ const LyricsPanel = ({ item, api, currentTime, onSeek }: LyricsPanelProps) => {
|
|||||||
if (lyrics.isLoading) {
|
if (lyrics.isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="audio-lyrics-status">
|
<div className="audio-lyrics-status">
|
||||||
<Typography>Загрузка текста...</Typography>
|
<Typography>Loading lyrics...</Typography>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -68,7 +60,7 @@ const LyricsPanel = ({ item, api, currentTime, onSeek }: LyricsPanelProps) => {
|
|||||||
if (lyrics.isError || !lyrics.data || !lyrics.data.Lyrics?.length) {
|
if (lyrics.isError || !lyrics.data || !lyrics.data.Lyrics?.length) {
|
||||||
return (
|
return (
|
||||||
<div className="audio-lyrics-status">
|
<div className="audio-lyrics-status">
|
||||||
<Typography>Текст недоступен</Typography>
|
<Typography>No lyrics available</Typography>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -86,11 +78,6 @@ const LyricsPanel = ({ item, api, currentTime, onSeek }: LyricsPanelProps) => {
|
|||||||
(lyrics.data?.Lyrics?.[index + 1]?.Start ??
|
(lyrics.data?.Lyrics?.[index + 1]?.Start ??
|
||||||
Number.POSITIVE_INFINITY);
|
Number.POSITIVE_INFINITY);
|
||||||
|
|
||||||
const canSeek = hasSyncedLyrics && onSeek && lyric.Start != null;
|
|
||||||
const seek = () => {
|
|
||||||
if (canSeek) onSeek(lyric.Start ?? 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Typography
|
<Typography
|
||||||
variant="body1"
|
variant="body1"
|
||||||
@@ -98,18 +85,6 @@ const LyricsPanel = ({ item, api, currentTime, onSeek }: LyricsPanelProps) => {
|
|||||||
className={`audio-lyrics-line ${isActive ? "active" : ""}`}
|
className={`audio-lyrics-line ${isActive ? "active" : ""}`}
|
||||||
key={`${lyric.Text}-${index}`}
|
key={`${lyric.Text}-${index}`}
|
||||||
data-active-lyric={isActive}
|
data-active-lyric={isActive}
|
||||||
{...(canSeek && {
|
|
||||||
role: "button",
|
|
||||||
tabIndex: 0,
|
|
||||||
"data-seekable": true,
|
|
||||||
onClick: seek,
|
|
||||||
onKeyDown: (e: React.KeyboardEvent) => {
|
|
||||||
if (e.key === "Enter" || e.key === " ") {
|
|
||||||
e.preventDefault();
|
|
||||||
seek();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
{lyric.Text}
|
{lyric.Text}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -119,7 +94,7 @@ const LyricsPanel = ({ item, api, currentTime, onSeek }: LyricsPanelProps) => {
|
|||||||
{!hasSyncedLyrics && (
|
{!hasSyncedLyrics && (
|
||||||
<div className="audio-lyrics-unsynced-notice">
|
<div className="audio-lyrics-unsynced-notice">
|
||||||
<span className="material-symbols-rounded">info</span>
|
<span className="material-symbols-rounded">info</span>
|
||||||
<Typography variant="caption">Синхронизированный текст недоступен</Typography>
|
<Typography variant="caption">Synced lyrics not available</Typography>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,57 +1,35 @@
|
|||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
import type { ReactNode } from "react";
|
||||||
import React, { type ReactNode } from "react";
|
import React from "react";
|
||||||
import CastButton from "@/components/buttons/castButton";
|
|
||||||
import InstantMixButton from "@/components/buttons/instantMixButton";
|
|
||||||
import QueueButton from "@/components/buttons/queueButton";
|
import QueueButton from "@/components/buttons/queueButton";
|
||||||
|
|
||||||
interface PlayerActionsProps {
|
interface PlayerActionsProps {
|
||||||
/** Opens the full-screen player. */
|
onNavigate: () => void;
|
||||||
onExpand: () => void;
|
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
/** The track currently playing (for cast / instant mix). */
|
|
||||||
item?: BaseItemDto | null;
|
|
||||||
positionTicks?: number;
|
|
||||||
queue?: BaseItemDto[];
|
|
||||||
startIndex?: number;
|
|
||||||
/** Volume control, rendered between the queue and expand buttons. */
|
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PlayerActions = ({
|
const PlayerActions = ({
|
||||||
onExpand,
|
onNavigate,
|
||||||
onClose,
|
onClose,
|
||||||
item,
|
|
||||||
positionTicks = 0,
|
|
||||||
queue = [],
|
|
||||||
startIndex = 0,
|
|
||||||
children,
|
children,
|
||||||
}: PlayerActionsProps) => {
|
}: PlayerActionsProps) => {
|
||||||
return (
|
return (
|
||||||
<div className="audio-player-actions">
|
<div
|
||||||
{item && <InstantMixButton item={item} />}
|
style={{
|
||||||
{item && <CastButton
|
display: "flex",
|
||||||
item={item}
|
alignItems: "center",
|
||||||
transfer={{
|
justifyContent: "flex-end",
|
||||||
kind: "audio",
|
|
||||||
positionTicks,
|
|
||||||
queue,
|
|
||||||
startIndex,
|
|
||||||
}}
|
}}
|
||||||
/>}
|
>
|
||||||
|
<IconButton onClick={onNavigate}>
|
||||||
|
<span className="material-symbols-rounded">info</span>
|
||||||
|
</IconButton>
|
||||||
<QueueButton />
|
<QueueButton />
|
||||||
<div className="audio-player-volume">{children}</div>
|
{children}
|
||||||
<Tooltip title="Открыть плеер">
|
<IconButton onClick={onClose}>
|
||||||
<IconButton onClick={onExpand} aria-label="Открыть плеер">
|
<div className="material-symbols-rounded">close</div>
|
||||||
<span className="material-symbols-rounded">open_in_full</span>
|
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Остановить и закрыть">
|
|
||||||
<IconButton onClick={onClose} aria-label="Остановить и закрыть">
|
|
||||||
<span className="material-symbols-rounded">close</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,10 +20,7 @@ const PlayerControls = ({
|
|||||||
onForward,
|
onForward,
|
||||||
}: PlayerControlsProps) => {
|
}: PlayerControlsProps) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div style={{ display: "flex", gap: "1em", alignItems: "center" }}>
|
||||||
className="player-controls"
|
|
||||||
style={{ display: "flex", gap: "1em", alignItems: "center" }}
|
|
||||||
>
|
|
||||||
<PlayPreviousButton />
|
<PlayPreviousButton />
|
||||||
{onRewind && (
|
{onRewind && (
|
||||||
<IconButton onClick={onRewind}>
|
<IconButton onClick={onRewind}>
|
||||||
|
|||||||
@@ -1,97 +1,58 @@
|
|||||||
import type { Api } from "@jellyfin/sdk";
|
import type { Api } from "@jellyfin/sdk";
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { Link } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { getItemQueryOptions } from "@/utils/queries/items";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
|
|
||||||
interface PlayerInfoProps {
|
interface PlayerInfoProps {
|
||||||
item: BaseItemDto | undefined | null;
|
item: BaseItemDto | undefined | null;
|
||||||
api: Api | undefined;
|
api: Api | undefined;
|
||||||
/** Opens the full-screen player. */
|
trackName?: string;
|
||||||
onOpen: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const PlayerInfo = ({ item, api, onOpen }: PlayerInfoProps) => {
|
const PlayerInfo = ({ item, api, trackName }: PlayerInfoProps) => {
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
|
||||||
// Fresh user data so the like button reflects changes immediately.
|
|
||||||
const itemDetails = useQuery({
|
|
||||||
...getItemQueryOptions(item?.Id ?? "", api, user?.Id),
|
|
||||||
enabled: Boolean(item?.Id && api && user?.Id),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!api || !item) return null;
|
if (!api || !item) return null;
|
||||||
|
|
||||||
const artists = item.ArtistItems?.length
|
|
||||||
? item.ArtistItems
|
|
||||||
: (item.AlbumArtists ?? []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="audio-player-info">
|
<div className="audio-player-info">
|
||||||
<button
|
<div className="audio-player-image-container">
|
||||||
type="button"
|
<img
|
||||||
className="audio-player-image-container"
|
alt={trackName ?? "track"}
|
||||||
onClick={onOpen}
|
className="audio-player-image"
|
||||||
aria-label="Открыть плеер"
|
src={getImageUrlsApi(api).getItemImageUrlById(
|
||||||
>
|
(!item?.ImageTags?.Primary ? item?.AlbumId : item.Id) ?? "",
|
||||||
|
"Primary",
|
||||||
|
{
|
||||||
|
quality: 85,
|
||||||
|
fillHeight: 462,
|
||||||
|
fillWidth: 462,
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<span className="material-symbols-rounded audio-player-image-icon">
|
<span className="material-symbols-rounded audio-player-image-icon">
|
||||||
music_note
|
music_note
|
||||||
</span>
|
</span>
|
||||||
<img
|
</div>
|
||||||
alt=""
|
|
||||||
className="audio-player-image"
|
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
(!item.ImageTags?.Primary ? item.AlbumId : item.Id) ?? "",
|
|
||||||
"Primary",
|
|
||||||
{ quality: 85, fillHeight: 120, fillWidth: 120 },
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<span className="material-symbols-rounded audio-player-image-expand">
|
|
||||||
expand_less
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
<div className="audio-player-info-text">
|
<div className="audio-player-info-text">
|
||||||
<Typography
|
<Typography
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
component="button"
|
style={{
|
||||||
className="audio-player-info-title"
|
width: "100%",
|
||||||
title={item.Name ?? undefined}
|
}}
|
||||||
onClick={onOpen}
|
noWrap
|
||||||
>
|
>
|
||||||
{item.Name}
|
{item?.Name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="caption"
|
variant="caption"
|
||||||
|
style={{
|
||||||
|
opacity: 0.5,
|
||||||
|
}}
|
||||||
noWrap
|
noWrap
|
||||||
className="audio-player-info-artist"
|
|
||||||
>
|
>
|
||||||
{artists.map((artist, index) => (
|
by {item?.Artists?.map((artist) => artist).join(",")}
|
||||||
<React.Fragment key={artist.Id ?? artist.Name}>
|
|
||||||
{index > 0 && ", "}
|
|
||||||
{artist.Id ? (
|
|
||||||
<Link to="/music/artist/$id" params={{ id: artist.Id }}>
|
|
||||||
{artist.Name}
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
artist.Name
|
|
||||||
)}
|
|
||||||
</React.Fragment>
|
|
||||||
))}
|
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
<LikeButton
|
|
||||||
itemId={item.Id ?? undefined}
|
|
||||||
itemName={item.Name}
|
|
||||||
isFavorite={
|
|
||||||
itemDetails.data?.UserData?.IsFavorite ?? item.UserData?.IsFavorite
|
|
||||||
}
|
|
||||||
queryKey={["item", item.Id ?? ""]}
|
|
||||||
userId={user?.Id}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,12 +8,6 @@ interface PlayerProgressProps {
|
|||||||
duration: number;
|
duration: number;
|
||||||
onSeek?: (value: number) => void;
|
onSeek?: (value: number) => void;
|
||||||
onSeekCommit: (value: number) => void;
|
onSeekCommit: (value: number) => void;
|
||||||
/**
|
|
||||||
* "inline" puts the times beside the bar, "stacked" puts them underneath,
|
|
||||||
* "bare" renders only the slider.
|
|
||||||
*/
|
|
||||||
layout?: "inline" | "stacked" | "bare";
|
|
||||||
className?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const PlayerProgress = ({
|
const PlayerProgress = ({
|
||||||
@@ -21,8 +15,6 @@ const PlayerProgress = ({
|
|||||||
duration,
|
duration,
|
||||||
onSeek,
|
onSeek,
|
||||||
onSeekCommit,
|
onSeekCommit,
|
||||||
layout = "inline",
|
|
||||||
className,
|
|
||||||
}: PlayerProgressProps) => {
|
}: PlayerProgressProps) => {
|
||||||
const [isScrubbing, setIsScrubbing] = useState(false);
|
const [isScrubbing, setIsScrubbing] = useState(false);
|
||||||
const [sliderValue, setSliderValue] = useState(progress);
|
const [sliderValue, setSliderValue] = useState(progress);
|
||||||
@@ -46,44 +38,8 @@ const PlayerProgress = ({
|
|||||||
onSeekCommit(newValue);
|
onSeekCommit(newValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (layout === "bare") {
|
|
||||||
return (
|
|
||||||
<Slider
|
|
||||||
className={className}
|
|
||||||
value={sliderValue}
|
|
||||||
step={1}
|
|
||||||
size="small"
|
|
||||||
max={duration}
|
|
||||||
onChange={handleChange}
|
|
||||||
onChangeCommitted={handleChangeCommitted}
|
|
||||||
aria-label="Перемотка"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (layout === "stacked") {
|
|
||||||
return (
|
|
||||||
<div className="player-progress-stacked">
|
|
||||||
<Slider
|
|
||||||
value={sliderValue}
|
|
||||||
step={1}
|
|
||||||
size="small"
|
|
||||||
max={duration}
|
|
||||||
onChange={handleChange}
|
|
||||||
onChangeCommitted={handleChangeCommitted}
|
|
||||||
aria-label="Перемотка"
|
|
||||||
/>
|
|
||||||
<div className="player-progress-stacked-times">
|
|
||||||
<span>{getRuntimeMusic(sliderValue)}</span>
|
|
||||||
<span>-{getRuntimeMusic(Math.max(duration - sliderValue, 0))}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={className}
|
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
|||||||
@@ -45,25 +45,20 @@ const PlayerVolume = ({
|
|||||||
ml: 1,
|
ml: 1,
|
||||||
width: "10em",
|
width: "10em",
|
||||||
"& .MuiSlider-valueLabel": {
|
"& .MuiSlider-valueLabel": {
|
||||||
// Compact pill hugging the thumb; above the play FAB (zIndex.fab)
|
|
||||||
zIndex: (theme) => theme.zIndex.tooltip,
|
|
||||||
lineHeight: 1.2,
|
lineHeight: 1.2,
|
||||||
fontSize: "0.75rem",
|
fontSize: 24,
|
||||||
fontWeight: 600,
|
background: "rgb(0 0 0 / 0.5)",
|
||||||
fontVariantNumeric: "tabular-nums",
|
backdropFilter: "blur(5px)",
|
||||||
minWidth: "2.25em",
|
padding: 1,
|
||||||
background: "rgb(0 0 0 / 0.75)",
|
borderRadius: "10px",
|
||||||
padding: "2px 6px",
|
|
||||||
borderRadius: "6px",
|
|
||||||
border: "1px solid rgb(255 255 255 / 0.15)",
|
border: "1px solid rgb(255 255 255 / 0.15)",
|
||||||
boxShadow: "0 2px 8px rgb(0 0 0 / 0.4)",
|
boxShadow: "0 0 10px rgb(0 0 0 / 0.4) ",
|
||||||
top: -6,
|
transform: "translatey(-120%) scale(0)",
|
||||||
transform: "translatey(-100%) scale(0)",
|
|
||||||
"&:before": {
|
"&:before": {
|
||||||
display: "none",
|
display: "none",
|
||||||
},
|
},
|
||||||
"&.MuiSlider-valueLabelOpen": {
|
"&.MuiSlider-valueLabelOpen": {
|
||||||
transform: "translateY(-100%) scale(1)",
|
transform: "translateY(-120%) scale(1)",
|
||||||
},
|
},
|
||||||
"& > *": {
|
"& > *": {
|
||||||
transform: "rotate(0deg)",
|
transform: "rotate(0deg)",
|
||||||
|
|||||||
@@ -0,0 +1,302 @@
|
|||||||
|
import {
|
||||||
|
closestCenter,
|
||||||
|
DndContext,
|
||||||
|
type DragEndEvent,
|
||||||
|
DragOverlay,
|
||||||
|
type DragStartEvent,
|
||||||
|
type DropAnimation,
|
||||||
|
defaultDropAnimationSideEffects,
|
||||||
|
KeyboardSensor,
|
||||||
|
PointerSensor,
|
||||||
|
useSensor,
|
||||||
|
useSensors,
|
||||||
|
} from "@dnd-kit/core";
|
||||||
|
import {
|
||||||
|
restrictToVerticalAxis,
|
||||||
|
restrictToWindowEdges,
|
||||||
|
} from "@dnd-kit/modifiers";
|
||||||
|
import {
|
||||||
|
arrayMove,
|
||||||
|
SortableContext,
|
||||||
|
sortableKeyboardCoordinates,
|
||||||
|
useSortable,
|
||||||
|
verticalListSortingStrategy,
|
||||||
|
} from "@dnd-kit/sortable";
|
||||||
|
import { CSS } from "@dnd-kit/utilities";
|
||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
IconButton,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
|
import React, { useMemo, useState } from "react";
|
||||||
|
import QueueListItem from "@/components/queueListItem";
|
||||||
|
import { stopPlayback } from "@/utils/store/audioPlayback";
|
||||||
|
import useQueue, {
|
||||||
|
clearQueue,
|
||||||
|
removeFromQueue,
|
||||||
|
setQueue,
|
||||||
|
shuffleUpcoming,
|
||||||
|
} from "@/utils/store/queue";
|
||||||
|
|
||||||
|
interface QueuePanelProps {
|
||||||
|
queue: BaseItemDto[];
|
||||||
|
currentTrackIndex: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dropAnimation: DropAnimation = {
|
||||||
|
sideEffects: defaultDropAnimationSideEffects({
|
||||||
|
styles: {
|
||||||
|
active: {
|
||||||
|
opacity: "0.5",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
function SortableQueueItem({
|
||||||
|
item,
|
||||||
|
onDelete,
|
||||||
|
index,
|
||||||
|
isActive,
|
||||||
|
}: {
|
||||||
|
item: BaseItemDto;
|
||||||
|
onDelete: () => void;
|
||||||
|
index: number;
|
||||||
|
isActive: boolean;
|
||||||
|
}) {
|
||||||
|
const {
|
||||||
|
attributes,
|
||||||
|
listeners,
|
||||||
|
setNodeRef,
|
||||||
|
transform,
|
||||||
|
transition,
|
||||||
|
isDragging,
|
||||||
|
} = useSortable({ id: item.Id || "" });
|
||||||
|
|
||||||
|
const style = {
|
||||||
|
transform: CSS.Translate.toString(transform),
|
||||||
|
transition,
|
||||||
|
opacity: isDragging ? 0.3 : 1,
|
||||||
|
position: "relative" as const,
|
||||||
|
zIndex: isDragging ? 999 : "auto",
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={setNodeRef} style={style} className="sortable-queue-item">
|
||||||
|
<QueueListItem
|
||||||
|
queueItem={item}
|
||||||
|
onDelete={onDelete}
|
||||||
|
dragHandleProps={{ ...attributes, ...listeners }}
|
||||||
|
isEpisode={item.Type === "Episode"}
|
||||||
|
index={index}
|
||||||
|
className={isActive ? "active" : ""}
|
||||||
|
sx={{
|
||||||
|
bgcolor: isActive
|
||||||
|
? "rgba(255, 255, 255, 0.1) !important"
|
||||||
|
: "transparent",
|
||||||
|
borderRadius: 2,
|
||||||
|
mb: 1,
|
||||||
|
transition: "background-color 0.2s",
|
||||||
|
"&:hover": {
|
||||||
|
bgcolor: "rgba(255, 255, 255, 0.05)",
|
||||||
|
},
|
||||||
|
".MuiListItemText-primary": {
|
||||||
|
color: isActive ? "var(--primary-color, #90caf9)" : "inherit",
|
||||||
|
fontWeight: isActive ? 600 : 500,
|
||||||
|
fontSize: "1rem",
|
||||||
|
},
|
||||||
|
".MuiListItemText-secondary": {
|
||||||
|
fontSize: "0.85rem",
|
||||||
|
opacity: 0.7,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QueuePanel = ({ queue, currentTrackIndex }: QueuePanelProps) => {
|
||||||
|
const [activeId, setActiveId] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const sensors = useSensors(
|
||||||
|
useSensor(PointerSensor, {
|
||||||
|
activationConstraint: {
|
||||||
|
distance: 8,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
useSensor(KeyboardSensor, {
|
||||||
|
coordinateGetter: sortableKeyboardCoordinates,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const activeItem = useMemo(
|
||||||
|
() => queue.find((item) => item.Id === activeId),
|
||||||
|
[queue, activeId],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleDragStart = (event: DragStartEvent) => {
|
||||||
|
setActiveId(String(event.active.id));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDragEnd = (event: DragEndEvent) => {
|
||||||
|
const { active, over } = event;
|
||||||
|
setActiveId(null);
|
||||||
|
|
||||||
|
if (active.id !== over?.id) {
|
||||||
|
const oldIndex = queue.map((item) => item.Id).indexOf(String(active.id));
|
||||||
|
const newIndex = queue.map((item) => item.Id).indexOf(String(over?.id));
|
||||||
|
|
||||||
|
if (oldIndex !== -1 && newIndex !== -1) {
|
||||||
|
const newQueue = arrayMove(queue, oldIndex, newIndex);
|
||||||
|
const currentTrackId = queue[currentTrackIndex]?.Id;
|
||||||
|
const newCurrentTrackIndex = newQueue.findIndex(
|
||||||
|
(item) => item.Id === currentTrackId,
|
||||||
|
);
|
||||||
|
|
||||||
|
setQueue(
|
||||||
|
newQueue,
|
||||||
|
newCurrentTrackIndex !== -1 ? newCurrentTrackIndex : 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
||||||
|
const open = Boolean(anchorEl);
|
||||||
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
|
setAnchorEl(event.currentTarget);
|
||||||
|
};
|
||||||
|
const handleClose = () => {
|
||||||
|
setAnchorEl(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClearQueue = () => {
|
||||||
|
stopPlayback();
|
||||||
|
clearQueue();
|
||||||
|
handleClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DndContext
|
||||||
|
sensors={sensors}
|
||||||
|
collisionDetection={closestCenter}
|
||||||
|
onDragStart={handleDragStart}
|
||||||
|
onDragEnd={handleDragEnd}
|
||||||
|
modifiers={[restrictToVerticalAxis, restrictToWindowEdges]}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="audio-queue-container"
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignItems: "center",
|
||||||
|
mb: 2,
|
||||||
|
px: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
sx={{
|
||||||
|
fontWeight: 700,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Queue
|
||||||
|
</Typography>
|
||||||
|
<Box sx={{ display: "flex", gap: 1 }}>
|
||||||
|
<Tooltip title="Shuffle Upcoming">
|
||||||
|
<IconButton onClick={() => shuffleUpcoming()} size="small">
|
||||||
|
<span className="material-symbols-rounded">shuffle</span>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<IconButton onClick={handleClick} size="small">
|
||||||
|
<span className="material-symbols-rounded">more_vert</span>
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
<Menu
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
open={open}
|
||||||
|
onClose={handleClose}
|
||||||
|
transformOrigin={{ horizontal: "right", vertical: "top" }}
|
||||||
|
anchorOrigin={{ horizontal: "right", vertical: "bottom" }}
|
||||||
|
>
|
||||||
|
<MenuItem onClick={handleClearQueue}>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{ marginRight: "0.5em", fontSize: "1.2em" }}
|
||||||
|
>
|
||||||
|
clear_all
|
||||||
|
</span>
|
||||||
|
Clear Queue
|
||||||
|
</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<SortableContext
|
||||||
|
items={queue.map((track) => track.Id ?? "")}
|
||||||
|
strategy={verticalListSortingStrategy}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="audio-queue"
|
||||||
|
style={{ display: "flex", flexDirection: "column", gap: "0px" }}
|
||||||
|
>
|
||||||
|
{queue.map((track, index) => (
|
||||||
|
<SortableQueueItem
|
||||||
|
key={track.Id}
|
||||||
|
item={track}
|
||||||
|
index={index}
|
||||||
|
onDelete={() => removeFromQueue(index)}
|
||||||
|
isActive={currentTrackIndex === index}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</SortableContext>
|
||||||
|
|
||||||
|
<DragOverlay
|
||||||
|
dropAnimation={dropAnimation}
|
||||||
|
style={{
|
||||||
|
left: "1.5rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{activeItem ? (
|
||||||
|
<QueueListItem
|
||||||
|
queueItem={activeItem}
|
||||||
|
isEpisode={activeItem.Type === "Episode"}
|
||||||
|
dragHandleProps={{}} // Pass empty object to render handle
|
||||||
|
onDelete={() => {}} // Pass empty function to render delete button space
|
||||||
|
sx={{
|
||||||
|
bgcolor: "rgba(40, 40, 40, 0.9)",
|
||||||
|
backdropFilter: "blur(10px)",
|
||||||
|
borderRadius: 2,
|
||||||
|
boxShadow: "0 8px 32px rgba(0,0,0,0.5)",
|
||||||
|
outline: "1px solid rgba(255, 255, 255, 0.1)",
|
||||||
|
mb: 1,
|
||||||
|
".MuiListItemText-primary": {
|
||||||
|
fontWeight: 500,
|
||||||
|
fontSize: "1rem",
|
||||||
|
},
|
||||||
|
".MuiListItemText-secondary": {
|
||||||
|
fontSize: "0.85rem",
|
||||||
|
opacity: 0.7,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</DragOverlay>
|
||||||
|
</div>
|
||||||
|
</DndContext>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default React.memo(QueuePanel);
|
||||||
@@ -4,7 +4,7 @@ import React, { useEffect, useState } from "react";
|
|||||||
|
|
||||||
interface StatsPanelProps {
|
interface StatsPanelProps {
|
||||||
item: BaseItemDto | undefined | null;
|
item: BaseItemDto | undefined | null;
|
||||||
audioRef: React.RefObject<HTMLAudioElement | null> | null;
|
audioRef: React.RefObject<HTMLAudioElement> | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StatRow = ({
|
const StatRow = ({
|
||||||
@@ -64,7 +64,7 @@ const StatsPanel: React.FC<StatsPanelProps> = ({ item, audioRef }) => {
|
|||||||
return (
|
return (
|
||||||
<Box sx={{ p: 2 }}>
|
<Box sx={{ p: 2 }}>
|
||||||
<Typography variant="h6" sx={{ mb: 2 }}>
|
<Typography variant="h6" sx={{ mb: 2 }}>
|
||||||
Статистика
|
Stats for Nerds
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Paper
|
<Paper
|
||||||
@@ -78,11 +78,11 @@ const StatsPanel: React.FC<StatsPanelProps> = ({ item, audioRef }) => {
|
|||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
||||||
>
|
>
|
||||||
Источник медиа
|
Media Source
|
||||||
</Typography>
|
</Typography>
|
||||||
<StatRow label="Контейнер" value={mediaSource?.Container} />
|
<StatRow label="Container" value={mediaSource?.Container} />
|
||||||
<StatRow
|
<StatRow
|
||||||
label="Битрейт"
|
label="Bitrate"
|
||||||
value={
|
value={
|
||||||
mediaSource?.Bitrate
|
mediaSource?.Bitrate
|
||||||
? `${Math.round(mediaSource.Bitrate / 1000)} kbps`
|
? `${Math.round(mediaSource.Bitrate / 1000)} kbps`
|
||||||
@@ -90,34 +90,34 @@ const StatsPanel: React.FC<StatsPanelProps> = ({ item, audioRef }) => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<StatRow
|
<StatRow
|
||||||
label="Размер"
|
label="Size"
|
||||||
value={
|
value={
|
||||||
mediaSource?.Size
|
mediaSource?.Size
|
||||||
? `${(mediaSource.Size / 1024 / 1024).toFixed(2)} MB`
|
? `${(mediaSource.Size / 1024 / 1024).toFixed(2)} MB`
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<StatRow label="Путь" value={mediaSource?.Path} />
|
<StatRow label="Path" value={mediaSource?.Path} />
|
||||||
|
|
||||||
<Box sx={{ mt: 3 }}>
|
<Box sx={{ mt: 3 }}>
|
||||||
<Typography
|
<Typography
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
||||||
>
|
>
|
||||||
Аудиопоток
|
Audio Stream
|
||||||
</Typography>
|
</Typography>
|
||||||
<StatRow label="Кодек" value={mediaStream?.Codec} />
|
<StatRow label="Codec" value={mediaStream?.Codec} />
|
||||||
<StatRow label="Каналы" value={mediaStream?.Channels} />
|
<StatRow label="Channels" value={mediaStream?.Channels} />
|
||||||
<StatRow
|
<StatRow
|
||||||
label="Частота дискретизации"
|
label="Sample Rate"
|
||||||
value={
|
value={
|
||||||
mediaStream?.SampleRate
|
mediaStream?.SampleRate
|
||||||
? `${mediaStream.SampleRate} Hz`
|
? `${mediaStream.SampleRate} Hz`
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<StatRow label="Глубина" value={mediaStream?.BitDepth} />
|
<StatRow label="Bit Depth" value={mediaStream?.BitDepth} />
|
||||||
<StatRow label="Язык" value={mediaStream?.Language} />
|
<StatRow label="Language" value={mediaStream?.Language} />
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box sx={{ mt: 3 }}>
|
<Box sx={{ mt: 3 }}>
|
||||||
@@ -125,11 +125,11 @@ const StatsPanel: React.FC<StatsPanelProps> = ({ item, audioRef }) => {
|
|||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
||||||
>
|
>
|
||||||
Плеер
|
Player
|
||||||
</Typography>
|
</Typography>
|
||||||
<StatRow label="Буфер" value={buffered} />
|
<StatRow label="Buffered" value={buffered} />
|
||||||
<StatRow
|
<StatRow
|
||||||
label="Громкость"
|
label="Volume"
|
||||||
value={
|
value={
|
||||||
audioRef?.current
|
audioRef?.current
|
||||||
? `${Math.round(audioRef.current.volume * 100)}%`
|
? `${Math.round(audioRef.current.volume * 100)}%`
|
||||||
@@ -137,7 +137,7 @@ const StatsPanel: React.FC<StatsPanelProps> = ({ item, audioRef }) => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<StatRow
|
<StatRow
|
||||||
label="Скорость воспроизведения"
|
label="Playback Rate"
|
||||||
value={audioRef?.current?.playbackRate}
|
value={audioRef?.current?.playbackRate}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1,54 +1,23 @@
|
|||||||
import type {
|
|
||||||
BaseItemDto,
|
|
||||||
SessionInfoDto,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import {
|
|
||||||
GeneralCommandType,
|
|
||||||
PlaystateCommand,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
|
||||||
import Divider from "@mui/material/Divider";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import ListItemIcon from "@mui/material/ListItemIcon";
|
|
||||||
import ListItemText from "@mui/material/ListItemText";
|
|
||||||
import Menu from "@mui/material/Menu";
|
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
|
||||||
import Slider from "@mui/material/Slider";
|
|
||||||
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 { useLocation, useNavigate } from "@tanstack/react-router";
|
||||||
import { AnimatePresence, motion } from "motion/react";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import React, { type SyntheticEvent, useEffect, useRef, useState } from "react";
|
import React, { type SyntheticEvent, useEffect, useRef, useState } from "react";
|
||||||
import QueueButton from "@/components/buttons/queueButton";
|
|
||||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { startInstantMix } from "@/utils/methods/instantMix";
|
|
||||||
import {
|
|
||||||
playOnSession,
|
|
||||||
queueStartingWith,
|
|
||||||
transferSessionToLocal,
|
|
||||||
} from "@/utils/methods/transferPlayback";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import {
|
import {
|
||||||
setAudioRef,
|
setAudioRef,
|
||||||
setIsMuted,
|
setIsMuted,
|
||||||
setVolume,
|
setVolume,
|
||||||
stopPlayback,
|
|
||||||
useAudioPlayback,
|
useAudioPlayback,
|
||||||
} from "@/utils/store/audioPlayback";
|
} from "@/utils/store/audioPlayback";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { playItemFromQueue } from "@/utils/store/playback";
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
import useQueue, {
|
import useQueue from "@/utils/store/queue";
|
||||||
cycleRepeatMode,
|
import PlayerActions from "./components/PlayerActions";
|
||||||
getNextTrackIndex,
|
import PlayerControls from "./components/PlayerControls";
|
||||||
shuffleUpcoming,
|
import PlayerInfo from "./components/PlayerInfo";
|
||||||
} from "@/utils/store/queue";
|
|
||||||
import useRemoteControlStore from "@/utils/store/remoteControl";
|
|
||||||
import useSyncPlayback from "@/utils/store/syncPlayback";
|
|
||||||
import DeviceMenu from "./components/DeviceMenu";
|
|
||||||
import PlayerProgress from "./components/PlayerProgress";
|
import PlayerProgress from "./components/PlayerProgress";
|
||||||
|
import PlayerVolume from "./components/PlayerVolume";
|
||||||
|
|
||||||
import "./audioPlayer.scss";
|
import "./audioPlayer.scss";
|
||||||
|
|
||||||
@@ -57,171 +26,43 @@ const AudioPlayer = () => {
|
|||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
const openRemoteDialog = useRemoteControlStore((s) => s.openDialog);
|
|
||||||
|
|
||||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||||
const [url, display, item, volume, isMuted, startTimeTicks] =
|
const [url, display, item, volume, isMuted] = useAudioPlayback((state) => [
|
||||||
useAudioPlayback((state) => [
|
|
||||||
state.url,
|
state.url,
|
||||||
state.display,
|
state.display,
|
||||||
state.item,
|
state.item,
|
||||||
state.player.volume,
|
state.player.volume,
|
||||||
state.player.isMuted,
|
state.player.isMuted,
|
||||||
state.startTimeTicks,
|
|
||||||
]);
|
]);
|
||||||
const seekAppliedRef = useRef(false);
|
|
||||||
useEffect(() => {
|
|
||||||
seekAppliedRef.current = false;
|
|
||||||
}, [item?.Id]);
|
|
||||||
|
|
||||||
const [tracks, currentTrack, repeatMode] = useQueue((state) => [
|
const [tracks, currentTrack] = useQueue((state) => [
|
||||||
state.tracks,
|
state.tracks,
|
||||||
state.currentItemIndex,
|
state.currentItemIndex,
|
||||||
state.repeatMode,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const [playing, setPlaying] = useState(false);
|
const [playing, setPlaying] = useState(false);
|
||||||
const [progress, setProgress] = useState(0);
|
const [progress, setProgress] = useState(0);
|
||||||
const [selectedRemoteId, setSelectedRemoteId] = useState<string | null>(null);
|
|
||||||
const remoteActiveRef = useRef(false);
|
|
||||||
const [moreAnchor, setMoreAnchor] = useState<HTMLElement | null>(null);
|
|
||||||
const [remoteVolumeDraft, setRemoteVolumeDraft] = useState<number | null>(
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
useEffect(() => setRemoteVolumeDraft(null), [selectedRemoteId]);
|
|
||||||
|
|
||||||
const sessions = useQuery({
|
// Sync volume and ref
|
||||||
queryKey: ["remoteSessions"],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!api || !user?.Id) return [];
|
|
||||||
const result = await getSessionApi(api).getSessions();
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: !!api && !!user?.Id,
|
|
||||||
// Poll quickly only while something is actually playing; idle devices
|
|
||||||
// are checked less often, and never while the window is hidden.
|
|
||||||
refetchInterval: () => {
|
|
||||||
if (document.visibilityState !== "visible") return false;
|
|
||||||
return display || remoteActiveRef.current ? 3000 : 8000;
|
|
||||||
},
|
|
||||||
refetchIntervalInBackground: false,
|
|
||||||
staleTime: 1500,
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const remoteSessions = (sessions.data ?? []).filter(
|
|
||||||
(session: SessionInfoDto) =>
|
|
||||||
session.Id &&
|
|
||||||
session.DeviceId !== api?.deviceInfo.id &&
|
|
||||||
session.UserId === user?.Id,
|
|
||||||
);
|
|
||||||
const playingRemote = remoteSessions.find(
|
|
||||||
(session: SessionInfoDto) => session.NowPlayingItem,
|
|
||||||
);
|
|
||||||
const selectedRemote = selectedRemoteId
|
|
||||||
? remoteSessions.find(
|
|
||||||
(session: SessionInfoDto) => session.Id === selectedRemoteId,
|
|
||||||
)
|
|
||||||
: undefined;
|
|
||||||
// Local playback takes precedence unless a remote device was selected.
|
|
||||||
const remote = selectedRemote?.NowPlayingItem
|
|
||||||
? selectedRemote
|
|
||||||
: !display
|
|
||||||
? playingRemote
|
|
||||||
: undefined;
|
|
||||||
remoteActiveRef.current = Boolean(remote);
|
|
||||||
|
|
||||||
const activeItem: BaseItemDto | undefined | null =
|
|
||||||
remote?.NowPlayingItem ?? item;
|
|
||||||
const artists = activeItem?.ArtistItems?.length
|
|
||||||
? activeItem.ArtistItems
|
|
||||||
: (activeItem?.AlbumArtists ?? []);
|
|
||||||
const artistNames = artists.map((artist) => artist.Name).filter(Boolean);
|
|
||||||
const remoteDevice = remote
|
|
||||||
? remote.DeviceName || remote.Client || "другое устройство"
|
|
||||||
: undefined;
|
|
||||||
const subtitle = remote
|
|
||||||
? artistNames.length > 0
|
|
||||||
? `${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 isPlaying = remote
|
|
||||||
? !remote.PlayState?.IsPaused
|
|
||||||
: playing;
|
|
||||||
const remoteRepeat = remote?.PlayState?.RepeatMode ?? "RepeatNone";
|
|
||||||
const remoteShuffled = remote?.PlayState?.PlaybackOrder === "Shuffle";
|
|
||||||
const remoteVolume =
|
|
||||||
remoteVolumeDraft ??
|
|
||||||
(remote?.PlayState?.VolumeLevel != null
|
|
||||||
? remote.PlayState.VolumeLevel / 100
|
|
||||||
: 1);
|
|
||||||
const remoteMuted = remote?.PlayState?.IsMuted ?? false;
|
|
||||||
const displayProgress = remote
|
|
||||||
? (remote.PlayState?.PositionTicks ?? 0)
|
|
||||||
: progress;
|
|
||||||
const displayDuration = activeItem?.RunTimeTicks ?? 1;
|
|
||||||
const barVisible = (display && item) || Boolean(remote);
|
|
||||||
|
|
||||||
const syncEnabled = useSyncPlayback((state) => state.enabled);
|
|
||||||
const syncMaster = useSyncPlayback((state) => state.master);
|
|
||||||
const startSync = useSyncPlayback((state) => state.start);
|
|
||||||
const stopSync = useSyncPlayback((state) => state.stop);
|
|
||||||
const canSync = Boolean(activeItem?.Id) && (display || Boolean(remote));
|
|
||||||
const syncForThisSession =
|
|
||||||
syncEnabled &&
|
|
||||||
(remote?.Id
|
|
||||||
? syncMaster?.sessionId === remote.Id
|
|
||||||
: display && syncMaster?.sessionId === null);
|
|
||||||
const toggleSync = () => {
|
|
||||||
if (syncForThisSession) {
|
|
||||||
stopSync();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!activeItem?.Id) return;
|
|
||||||
startSync({ itemId: activeItem.Id, sessionId: remote?.Id ?? null });
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (display) setSelectedRemoteId(null);
|
|
||||||
}, [display, item?.Id]);
|
|
||||||
|
|
||||||
// Layout hooks (home hero rail) reserve space for the bar. Use explicit
|
|
||||||
// visibility rather than the DOM: during the exit animation the element is
|
|
||||||
// still mounted but already off-screen.
|
|
||||||
const isFullPlayer =
|
|
||||||
location.pathname === "/player" || location.pathname === "/player/audio";
|
|
||||||
useEffect(() => {
|
|
||||||
const visible = barVisible && !isFullPlayer;
|
|
||||||
document.body.classList.toggle("has-player-bar", visible);
|
|
||||||
return () => document.body.classList.remove("has-player-bar");
|
|
||||||
}, [barVisible, isFullPlayer]);
|
|
||||||
|
|
||||||
// Sync local audio element.
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (display) {
|
if (display) {
|
||||||
setAudioRef(audioRef);
|
setAudioRef(audioRef);
|
||||||
|
|
||||||
if (audioRef.current) {
|
if (audioRef.current) {
|
||||||
audioRef.current.volume = isMuted ? 0 : volume;
|
audioRef.current.volume = isMuted ? 0 : volume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [display, url, tracks?.[currentTrack]?.Id, isMuted, volume]);
|
}, [display, url, tracks?.[currentTrack]?.Id]);
|
||||||
|
|
||||||
|
// Update volume when state changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (audioRef.current) {
|
if (audioRef.current) {
|
||||||
audioRef.current.volume = isMuted ? 0 : volume;
|
audioRef.current.volume = isMuted ? 0 : volume;
|
||||||
}
|
}
|
||||||
}, [volume, isMuted]);
|
}, [volume, isMuted]);
|
||||||
|
|
||||||
// Media Session metadata/actions for local playback.
|
// Media Session Metadata
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ("mediaSession" in navigator && item) {
|
if ("mediaSession" in navigator && item) {
|
||||||
const imageUrl = item.ImageTags?.Primary
|
const imageUrl = item.ImageTags?.Primary
|
||||||
@@ -230,19 +71,27 @@ const AudioPlayer = () => {
|
|||||||
tag: item.ImageTags.Primary,
|
tag: item.ImageTags.Primary,
|
||||||
})
|
})
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
navigator.mediaSession.metadata = new MediaMetadata({
|
navigator.mediaSession.metadata = new MediaMetadata({
|
||||||
title: item.Name ?? "Неизвестное название",
|
title: item.Name ?? "Unknown Title",
|
||||||
artist: item.Artists?.join(", ") ?? "Неизвестный исполнитель",
|
artist: item.Artists?.join(", ") ?? "Unknown Artist",
|
||||||
album: item.Album ?? "Неизвестный альбом",
|
album: item.Album ?? "Unknown Album",
|
||||||
artwork: imageUrl
|
artwork: imageUrl
|
||||||
? [{ src: imageUrl, sizes: "512x512", type: "image/jpeg" }]
|
? [
|
||||||
|
{
|
||||||
|
src: imageUrl,
|
||||||
|
sizes: "512x512",
|
||||||
|
type: "image/jpeg",
|
||||||
|
},
|
||||||
|
]
|
||||||
: [],
|
: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [item, api]);
|
}, [item, api]);
|
||||||
|
|
||||||
|
// Media Session Action Handlers
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!("mediaSession" in navigator)) return;
|
if ("mediaSession" in navigator) {
|
||||||
navigator.mediaSession.setActionHandler("play", () => {
|
navigator.mediaSession.setActionHandler("play", () => {
|
||||||
audioRef.current?.play();
|
audioRef.current?.play();
|
||||||
});
|
});
|
||||||
@@ -250,12 +99,13 @@ const AudioPlayer = () => {
|
|||||||
audioRef.current?.pause();
|
audioRef.current?.pause();
|
||||||
});
|
});
|
||||||
navigator.mediaSession.setActionHandler("previoustrack", () => {
|
navigator.mediaSession.setActionHandler("previoustrack", () => {
|
||||||
if (user?.Id && api) playItemFromQueue("previous", user.Id, api);
|
if (user?.Id && api) {
|
||||||
|
playItemFromQueue("previous", user.Id, api);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
navigator.mediaSession.setActionHandler("nexttrack", () => {
|
navigator.mediaSession.setActionHandler("nexttrack", () => {
|
||||||
const nextIndex = getNextTrackIndex();
|
if (user?.Id && api) {
|
||||||
if (nextIndex !== undefined && user?.Id && api) {
|
playItemFromQueue("next", user.Id, api);
|
||||||
playItemFromQueue(nextIndex, user.Id, api);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
navigator.mediaSession.setActionHandler("seekto", (details) => {
|
navigator.mediaSession.setActionHandler("seekto", (details) => {
|
||||||
@@ -263,6 +113,7 @@ const AudioPlayer = () => {
|
|||||||
audioRef.current.currentTime = details.seekTime;
|
audioRef.current.currentTime = details.seekTime;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, [api, user?.Id]);
|
}, [api, user?.Id]);
|
||||||
|
|
||||||
const updatePositionState = () => {
|
const updatePositionState = () => {
|
||||||
@@ -300,15 +151,9 @@ const AudioPlayer = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleEnded = () => {
|
const handleEnded = () => {
|
||||||
if (useQueue.getState().repeatMode === "one" && audioRef.current) {
|
|
||||||
audioRef.current.currentTime = 0;
|
|
||||||
audioRef.current.play();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setPlaying(false);
|
setPlaying(false);
|
||||||
const nextIndex = getNextTrackIndex();
|
if (tracks?.[currentTrack + 1]?.Id && api && user?.Id) {
|
||||||
if (nextIndex !== undefined && api && user?.Id) {
|
playItemFromQueue("next", user.Id, api);
|
||||||
playItemFromQueue(nextIndex, user.Id, api);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -332,13 +177,11 @@ const AudioPlayer = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleNavigate = () => {
|
const handleNavigate = () => {
|
||||||
if (remote) {
|
|
||||||
openRemoteDialog(remote.NowPlayingItem);
|
|
||||||
} else {
|
|
||||||
navigate({ to: "/player/audio" });
|
navigate({ to: "/player/audio" });
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Listen to play/pause events directly from audio element to keep state in sync
|
||||||
|
// (e.g. if paused by media keys)
|
||||||
const onPlay = () => {
|
const onPlay = () => {
|
||||||
setPlaying(true);
|
setPlaying(true);
|
||||||
updatePositionState();
|
updatePositionState();
|
||||||
@@ -354,187 +197,27 @@ const AudioPlayer = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const remoteCommand = async (
|
return (
|
||||||
command: PlaystateCommand,
|
<AnimatePresence mode="sync">
|
||||||
seekPositionTicks?: number,
|
{display && (
|
||||||
) => {
|
<motion.div
|
||||||
if (!api || !remote?.Id) return;
|
initial={{ transform: "translate(-50%, 150%)" }}
|
||||||
try {
|
animate={{
|
||||||
await getSessionApi(api).sendPlaystateCommand({
|
transform:
|
||||||
sessionId: remote.Id,
|
location.pathname === "/player/audio"
|
||||||
command,
|
? "translate(-50%, 150%)"
|
||||||
seekPositionTicks,
|
: "translate(-50%, 0%)",
|
||||||
controllingUserId: user?.Id,
|
}}
|
||||||
});
|
exit={{ transform: "translate(-50%, 150%)" }}
|
||||||
await sessions.refetch();
|
transition={{ duration: 0.3, ease: "circOut" }}
|
||||||
} catch (error) {
|
className="audio-player glass"
|
||||||
console.error("Команда не выполнена", error);
|
>
|
||||||
enqueueSnackbar("Команда не выполнена", { variant: "error" });
|
<PlayerInfo
|
||||||
}
|
item={item}
|
||||||
};
|
api={api}
|
||||||
|
trackName={tracks?.[currentTrack]?.Name ?? "Unknown Track"}
|
||||||
|
/>
|
||||||
|
|
||||||
const transferToLocal = async () => {
|
|
||||||
if (!api || !user?.Id || !remote) {
|
|
||||||
setSelectedRemoteId(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const kind = await transferSessionToLocal(api, user.Id, remote);
|
|
||||||
setSelectedRemoteId(null);
|
|
||||||
await sessions.refetch();
|
|
||||||
if (kind === "video") navigate({ to: "/player" });
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Transfer failed", error);
|
|
||||||
enqueueSnackbar("Не удалось перенести воспроизведение", { variant: "error" });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectRemote = async (session: SessionInfoDto) => {
|
|
||||||
if (!session.Id) return;
|
|
||||||
try {
|
|
||||||
// Moving local playback: send the queue/position to the target first.
|
|
||||||
if (display && item?.Id && api && user?.Id) {
|
|
||||||
const queue = useQueue.getState();
|
|
||||||
const ids = queueStartingWith(queue.tracks ?? [], item.Id);
|
|
||||||
await playOnSession(api, user.Id, session.Id, {
|
|
||||||
itemIds: ids.length > 0 ? ids : [item.Id],
|
|
||||||
startIndex: 0,
|
|
||||||
startPositionTicks: progress,
|
|
||||||
mediaSourceId: item.MediaSources?.[0]?.Id ?? undefined,
|
|
||||||
});
|
|
||||||
stopPlayback();
|
|
||||||
} else if (
|
|
||||||
remote?.Id &&
|
|
||||||
remote.Id !== session.Id &&
|
|
||||||
remote.NowPlayingItem?.Id &&
|
|
||||||
api &&
|
|
||||||
user?.Id
|
|
||||||
) {
|
|
||||||
// Moving playback from one remote device to another: hand over the
|
|
||||||
// queue and current position, then stop the old device.
|
|
||||||
const remoteItem = remote.NowPlayingItem;
|
|
||||||
const queueIds = queueStartingWith(
|
|
||||||
remote.NowPlayingQueue ?? [],
|
|
||||||
remoteItem.Id ?? undefined,
|
|
||||||
);
|
|
||||||
await playOnSession(api, user.Id, session.Id, {
|
|
||||||
itemIds: queueIds.length > 0 ? queueIds : [remoteItem.Id as string],
|
|
||||||
startIndex: 0,
|
|
||||||
startPositionTicks: remote.PlayState?.PositionTicks ?? 0,
|
|
||||||
mediaSourceId: remoteItem.MediaSources?.[0]?.Id ?? undefined,
|
|
||||||
});
|
|
||||||
await getSessionApi(api).sendPlaystateCommand({
|
|
||||||
sessionId: remote.Id,
|
|
||||||
command: "Stop",
|
|
||||||
controllingUserId: user.Id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
setSelectedRemoteId(session.Id);
|
|
||||||
await sessions.refetch();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Не удалось переключить устройство", error);
|
|
||||||
enqueueSnackbar("Не удалось переключить устройство", { variant: "error" });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleNext = () => {
|
|
||||||
if (remote) remoteCommand(PlaystateCommand.NextTrack);
|
|
||||||
else if (api && user?.Id) playItemFromQueue("next", user.Id, api);
|
|
||||||
};
|
|
||||||
const handlePrevious = () => {
|
|
||||||
if (remote) remoteCommand(PlaystateCommand.PreviousTrack);
|
|
||||||
else if (api && user?.Id) playItemFromQueue("previous", user.Id, api);
|
|
||||||
};
|
|
||||||
const sendGeneral = async (
|
|
||||||
name: GeneralCommandType,
|
|
||||||
args?: Record<string, string>,
|
|
||||||
) => {
|
|
||||||
if (!api || !remote?.Id) return;
|
|
||||||
try {
|
|
||||||
await getSessionApi(api).sendFullGeneralCommand({
|
|
||||||
sessionId: remote.Id,
|
|
||||||
generalCommand: {
|
|
||||||
Name: name,
|
|
||||||
Arguments: args,
|
|
||||||
ControllingUserId: user?.Id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
await sessions.refetch();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Remote general command failed", error);
|
|
||||||
enqueueSnackbar("Команда не выполнена", { variant: "error" });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleShuffle = () => {
|
|
||||||
if (remote) {
|
|
||||||
sendGeneral(GeneralCommandType.SetShuffleQueue, {
|
|
||||||
ShuffleMode: remoteShuffled ? "Sorted" : "Shuffle",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
shuffleUpcoming();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const handleRepeat = () => {
|
|
||||||
if (remote) {
|
|
||||||
const next =
|
|
||||||
remoteRepeat === "RepeatNone"
|
|
||||||
? "RepeatAll"
|
|
||||||
: remoteRepeat === "RepeatAll"
|
|
||||||
? "RepeatOne"
|
|
||||||
: "RepeatNone";
|
|
||||||
sendGeneral(GeneralCommandType.SetRepeatMode, { RepeatMode: next });
|
|
||||||
} else {
|
|
||||||
cycleRepeatMode();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const handleMute = () => {
|
|
||||||
if (remote) {
|
|
||||||
sendGeneral(
|
|
||||||
remoteMuted
|
|
||||||
? GeneralCommandType.Unmute
|
|
||||||
: GeneralCommandType.Mute,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
handleMuteToggle();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const handleRemoteSeek = (ticks: number) => {
|
|
||||||
remoteCommand(PlaystateCommand.Seek, Math.round(ticks));
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleMoreOpen = (event: React.MouseEvent<HTMLElement>) =>
|
|
||||||
setMoreAnchor(event.currentTarget);
|
|
||||||
|
|
||||||
const instantMix = async () => {
|
|
||||||
setMoreAnchor(null);
|
|
||||||
if (!api || !user?.Id || !activeItem) return;
|
|
||||||
try {
|
|
||||||
const { count } = await startInstantMix(api, user.Id, activeItem);
|
|
||||||
if (count === 0) {
|
|
||||||
enqueueSnackbar("Нет треков для микса", {
|
|
||||||
variant: "warning",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
enqueueSnackbar("Не удалось запустить микс", { variant: "error" });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const openCastForLocal = () => {
|
|
||||||
setMoreAnchor(null);
|
|
||||||
if (!item) return;
|
|
||||||
openRemoteDialog({
|
|
||||||
item,
|
|
||||||
kind: "audio",
|
|
||||||
positionTicks: progress,
|
|
||||||
queue: tracks ?? [],
|
|
||||||
startIndex: currentTrack,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const audioElement = display ? (
|
|
||||||
<audio
|
<audio
|
||||||
autoPlay
|
autoPlay
|
||||||
src={url}
|
src={url}
|
||||||
@@ -545,295 +228,31 @@ const AudioPlayer = () => {
|
|||||||
onPlay={onPlay}
|
onPlay={onPlay}
|
||||||
onPause={onPause}
|
onPause={onPause}
|
||||||
onSeeked={updatePositionState}
|
onSeeked={updatePositionState}
|
||||||
onLoadedMetadata={(event) => {
|
onLoadedMetadata={updatePositionState}
|
||||||
const player = event.currentTarget;
|
|
||||||
if (!seekAppliedRef.current && startTimeTicks > 0) {
|
|
||||||
seekAppliedRef.current = true;
|
|
||||||
player.currentTime = ticksToSec(startTimeTicks);
|
|
||||||
}
|
|
||||||
updatePositionState();
|
|
||||||
}}
|
|
||||||
id="audio-player"
|
id="audio-player"
|
||||||
/>
|
/>
|
||||||
) : null;
|
|
||||||
|
|
||||||
if (!barVisible && !display) {
|
<div className="audio-player-controls">
|
||||||
return null;
|
<PlayerControls playing={playing} onPlayPause={handlePlayPause} />
|
||||||
}
|
|
||||||
|
|
||||||
const bar = (
|
|
||||||
<AnimatePresence mode="sync">
|
|
||||||
<motion.div
|
|
||||||
initial={{ transform: "translate(-50%, 150%)" }}
|
|
||||||
animate={{ transform: "translate(-50%, 0%)" }}
|
|
||||||
exit={{ transform: "translate(-50%, 150%)" }}
|
|
||||||
transition={{ duration: 0.25, ease: "circOut" }}
|
|
||||||
className="audio-player"
|
|
||||||
>
|
|
||||||
<div className="media-bar-left">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="media-bar-cover"
|
|
||||||
onClick={handleNavigate}
|
|
||||||
aria-label="Открыть плеер"
|
|
||||||
>
|
|
||||||
{coverUrl ? (
|
|
||||||
<img src={coverUrl} alt="" />
|
|
||||||
) : (
|
|
||||||
<span className="material-symbols-rounded">music_note</span>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
<div className="media-bar-info">
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
className="media-bar-title"
|
|
||||||
title={activeItem?.Name ?? undefined}
|
|
||||||
onClick={handleNavigate}
|
|
||||||
>
|
|
||||||
{activeItem?.Name ?? "Неизвестно"}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="caption" noWrap className="media-bar-subtitle">
|
|
||||||
{subtitle || "Blink"}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
aria-label="Ещё"
|
|
||||||
className="media-bar-more"
|
|
||||||
onClick={handleMoreOpen}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">more_horiz</span>
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="media-bar-center">
|
|
||||||
<div className="media-bar-controls">
|
|
||||||
<Tooltip title="Перемешать">
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
onClick={handleShuffle}
|
|
||||||
className={(remote ? remoteShuffled : false) ? "active" : ""}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">shuffle</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Предыдущий">
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
onClick={handlePrevious}
|
|
||||||
aria-label="Предыдущий"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
skip_previous
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title={isPlaying ? "Пауза" : "Слушать"}>
|
|
||||||
<IconButton
|
|
||||||
className="media-bar-play"
|
|
||||||
aria-label={isPlaying ? "Пауза" : "Слушать"}
|
|
||||||
onClick={() =>
|
|
||||||
remote
|
|
||||||
? remoteCommand(PlaystateCommand.PlayPause)
|
|
||||||
: handlePlayPause()
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
{isPlaying ? "pause" : "play_arrow"}
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Следующий">
|
|
||||||
<IconButton size="small" onClick={handleNext} aria-label="Следующий">
|
|
||||||
<span className="material-symbols-rounded">skip_next</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip
|
|
||||||
title={
|
|
||||||
remote
|
|
||||||
? remoteRepeat === "RepeatNone"
|
|
||||||
? "Повтор выкл."
|
|
||||||
: remoteRepeat === "RepeatAll"
|
|
||||||
? "Повтор всех"
|
|
||||||
: "Повтор одного"
|
|
||||||
: repeatMode === "off"
|
|
||||||
? "Повтор выкл."
|
|
||||||
: repeatMode === "all"
|
|
||||||
? "Повтор всех"
|
|
||||||
: "Повтор одного"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
onClick={handleRepeat}
|
|
||||||
className={
|
|
||||||
(remote ? remoteRepeat !== "RepeatNone" : repeatMode !== "off")
|
|
||||||
? "active"
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
{(remote ? remoteRepeat === "RepeatOne" : repeatMode === "one")
|
|
||||||
? "repeat_one"
|
|
||||||
: "repeat"}
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
<PlayerProgress
|
<PlayerProgress
|
||||||
className="media-bar-progress"
|
progress={progress}
|
||||||
progress={displayProgress}
|
duration={item?.RunTimeTicks ?? 1}
|
||||||
duration={displayDuration}
|
onSeekCommit={handleSeekCommit}
|
||||||
onSeekCommit={remote ? handleRemoteSeek : handleSeekCommit}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="media-bar-right">
|
<PlayerActions onNavigate={handleNavigate} onClose={handleClose}>
|
||||||
{remote && (
|
<PlayerVolume
|
||||||
<Tooltip title="Перенести на это устройство">
|
volume={volume}
|
||||||
<IconButton
|
isMuted={isMuted}
|
||||||
size="small"
|
onVolumeChange={handleVolumeChange}
|
||||||
aria-label="Перенести на это устройство"
|
onMuteToggle={handleMuteToggle}
|
||||||
onClick={transferToLocal}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
system_update_alt
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
{!remote && <QueueButton />}
|
|
||||||
<Tooltip title={remote ? (remoteMuted ? "Включить звук" : "Выключить звук") : (isMuted ? "Включить звук" : "Выключить звук")}>
|
|
||||||
<IconButton size="small" onClick={handleMute}>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
{remote
|
|
||||||
? remoteMuted || remoteVolume === 0
|
|
||||||
? "volume_off"
|
|
||||||
: "volume_up"
|
|
||||||
: isMuted || volume === 0
|
|
||||||
? "volume_off"
|
|
||||||
: "volume_up"}
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<Slider
|
|
||||||
size="small"
|
|
||||||
className="media-bar-volume"
|
|
||||||
value={remote ? (remoteMuted ? 0 : remoteVolume) : isMuted ? 0 : volume}
|
|
||||||
min={0}
|
|
||||||
max={1}
|
|
||||||
step={0.01}
|
|
||||||
aria-label="Громкость"
|
|
||||||
onChange={(_, value) => {
|
|
||||||
const next = Array.isArray(value) ? value[0] : value;
|
|
||||||
if (remote) {
|
|
||||||
setRemoteVolumeDraft(next);
|
|
||||||
} else {
|
|
||||||
handleVolumeChange(next);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onChangeCommitted={(_, value) => {
|
|
||||||
if (!remote) return;
|
|
||||||
const next = Array.isArray(value) ? value[0] : value;
|
|
||||||
setRemoteVolumeDraft(null);
|
|
||||||
sendGeneral(GeneralCommandType.SetVolume, {
|
|
||||||
Volume: String(Math.round(next * 100)),
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<DeviceMenu
|
</PlayerActions>
|
||||||
sessions={remoteSessions}
|
|
||||||
activeRemoteId={remote?.Id ?? null}
|
|
||||||
localActive={display && Boolean(item)}
|
|
||||||
localItem={item}
|
|
||||||
onSelectLocal={transferToLocal}
|
|
||||||
onSelectRemote={selectRemote}
|
|
||||||
onOpenRemoteControl={() => openRemoteDialog()}
|
|
||||||
syncEnabled={syncForThisSession}
|
|
||||||
canSync={canSync}
|
|
||||||
onToggleSync={toggleSync}
|
|
||||||
/>
|
|
||||||
<Tooltip title="Открыть плеер">
|
|
||||||
<IconButton size="small" onClick={handleNavigate}>
|
|
||||||
<span className="material-symbols-rounded">open_in_full</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Menu
|
|
||||||
anchorEl={moreAnchor}
|
|
||||||
open={Boolean(moreAnchor)}
|
|
||||||
onClose={() => setMoreAnchor(null)}
|
|
||||||
slotProps={{ paper: { className: "glass-menu-paper" } }}
|
|
||||||
>
|
|
||||||
<MenuItem onClick={instantMix} disabled={!activeItem}>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">radio</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText primary="Микс" />
|
|
||||||
</MenuItem>
|
|
||||||
{remote ? (
|
|
||||||
<MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
setMoreAnchor(null);
|
|
||||||
transferToLocal();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
system_update_alt
|
|
||||||
</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText primary="Перенести на это устройство" />
|
|
||||||
</MenuItem>
|
|
||||||
) : (
|
|
||||||
<MenuItem onClick={openCastForLocal}>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">cast</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText primary="Воспроизвести на другом устройстве…" />
|
|
||||||
</MenuItem>
|
|
||||||
)}
|
|
||||||
<MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
setMoreAnchor(null);
|
|
||||||
openRemoteDialog();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">settings_remote</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText primary="Удалённое управление…" />
|
|
||||||
</MenuItem>
|
|
||||||
<Divider />
|
|
||||||
<MenuItem
|
|
||||||
onClick={() => {
|
|
||||||
setMoreAnchor(null);
|
|
||||||
if (remote) {
|
|
||||||
remoteCommand(PlaystateCommand.Stop);
|
|
||||||
setSelectedRemoteId(null);
|
|
||||||
} else {
|
|
||||||
handleClose();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">stop</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText primary="Остановить" />
|
|
||||||
</MenuItem>
|
|
||||||
</Menu>
|
|
||||||
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
)}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{audioElement}
|
|
||||||
{barVisible && !isFullPlayer && bar}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AudioPlayer;
|
export default AudioPlayer;
|
||||||
@@ -29,20 +29,20 @@ const ErrorDisplay = ({ error, onRetry, onExit }: ErrorDisplayProps) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h5" color="error">
|
<Typography variant="h5" color="error">
|
||||||
Ошибка воспроизведения
|
Playback Error
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
{error.message || "Во время воспроизведения произошла неизвестная ошибка."}
|
{error.message || "An unknown error occurred during playback."}
|
||||||
</Typography>
|
</Typography>
|
||||||
<div style={{ display: "flex", gap: "1rem" }}>
|
<div style={{ display: "flex", gap: "1rem" }}>
|
||||||
{onRetry && (
|
{onRetry && (
|
||||||
<Button variant="contained" color="primary" onClick={onRetry}>
|
<Button variant="contained" color="primary" onClick={onRetry}>
|
||||||
Повторить
|
Retry
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{onExit && (
|
{onExit && (
|
||||||
<Button variant="outlined" color="secondary" onClick={onExit}>
|
<Button variant="outlined" color="secondary" onClick={onExit}>
|
||||||
Выйти
|
Exit
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ const StatsForNerds = ({ playerRef }: StatsForNerdsProps) => {
|
|||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Статистика
|
Stats for Nerds
|
||||||
</Typography>
|
</Typography>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="small"
|
size="small"
|
||||||
@@ -138,29 +138,29 @@ const StatsForNerds = ({ playerRef }: StatsForNerdsProps) => {
|
|||||||
gap: "0.5em 1em",
|
gap: "0.5em 1em",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span>ID видео:</span> <span>{itemId}</span>
|
<span>Video ID:</span> <span>{itemId}</span>
|
||||||
<span>ID источника:</span> <span>{mediaSourceId}</span>
|
<span>Media Source ID:</span> <span>{mediaSourceId}</span>
|
||||||
<span>ID сеанса:</span> <span>{playsessionId}</span>
|
<span>Play Session ID:</span> <span>{playsessionId}</span>
|
||||||
<span>Метод воспроизведения:</span> <span>{mediaSource.playMethod}</span>
|
<span>Playback Method:</span> <span>{mediaSource.playMethod}</span>
|
||||||
<span>Контейнер:</span> <span>{mediaSource.container}</span>
|
<span>Container:</span> <span>{mediaSource.container}</span>
|
||||||
<span>Видеокодек:</span> <span>{mediaSource.videoCodec}</span>
|
<span>Video Codec:</span> <span>{mediaSource.videoCodec}</span>
|
||||||
<span>Аудиокодек:</span> <span>{mediaSource.audioCodec}</span>
|
<span>Audio Codec:</span> <span>{mediaSource.audioCodec}</span>
|
||||||
<span>Битрейт:</span>{" "}
|
<span>Bitrate:</span>{" "}
|
||||||
<span>
|
<span>
|
||||||
{mediaSource.bitrate
|
{mediaSource.bitrate
|
||||||
? `${(mediaSource.bitrate / 1000000).toFixed(2)} Mbps`
|
? `${(mediaSource.bitrate / 1000000).toFixed(2)} Mbps`
|
||||||
: "-"}
|
: "-"}
|
||||||
</span>
|
</span>
|
||||||
<span>URL потока:</span>{" "}
|
<span>Stream URL:</span>{" "}
|
||||||
<span style={{ wordBreak: "break-all" }}>{playbackStream}</span>
|
<span style={{ wordBreak: "break-all" }}>{playbackStream}</span>
|
||||||
<span>Разрешение:</span> <span>{videoStats.resolution}</span>
|
<span>Resolution:</span> <span>{videoStats.resolution}</span>
|
||||||
<span>Громкость:</span> <span>{Math.round(volume * 100)}%</span>
|
<span>Volume:</span> <span>{Math.round(volume * 100)}%</span>
|
||||||
<span>Буфер:</span> <span>{videoStats.buffered}</span>
|
<span>Buffer Health:</span> <span>{videoStats.buffered}</span>
|
||||||
<span>Пропущенные кадры:</span>{" "}
|
<span>Dropped Frames:</span>{" "}
|
||||||
<span>
|
<span>
|
||||||
{videoStats.droppedFrames} / {videoStats.totalFrames}
|
{videoStats.droppedFrames} / {videoStats.totalFrames}
|
||||||
</span>
|
</span>
|
||||||
<span>Буферизация:</span> <span>{isBuffering ? "Да" : "Нет"}</span>
|
<span>Is Buffering:</span> <span>{isBuffering ? "Yes" : "No"}</span>
|
||||||
</div>
|
</div>
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -190,11 +190,14 @@ const BubbleSlider = () => {
|
|||||||
const backgroundOffsetY = -(imageOffsetY * trickplayResolution?.Height);
|
const backgroundOffsetY = -(imageOffsetY * trickplayResolution?.Height);
|
||||||
|
|
||||||
const imgUrlParamsObject: Record<string, string> = {
|
const imgUrlParamsObject: Record<string, string> = {
|
||||||
ApiKey: String(api?.accessToken),
|
api_key: String(api?.accessToken),
|
||||||
MediaSourceId: mediaSource.id ?? "",
|
MediaSourceId: mediaSource.id ?? "",
|
||||||
};
|
};
|
||||||
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
|
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
|
||||||
|
|
||||||
|
const _imageAspectRatio =
|
||||||
|
trickplayResolution.Width / trickplayResolution.Height;
|
||||||
|
|
||||||
trickplayStyle = {
|
trickplayStyle = {
|
||||||
backgroundImage: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
backgroundImage: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
||||||
backgroundPositionX: `${backgroundOffsetX}px`,
|
backgroundPositionX: `${backgroundOffsetX}px`,
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
import { IconButton, Tooltip } from "@mui/material";
|
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import React, { useEffect, useState } from "react";
|
|
||||||
import {
|
|
||||||
getPlayerVideoElement,
|
|
||||||
isPictureInPictureActive,
|
|
||||||
supportsPictureInPicture,
|
|
||||||
togglePictureInPicture,
|
|
||||||
} from "@/utils/methods/pictureInPicture";
|
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
|
||||||
|
|
||||||
const PictureInPictureButton = () => {
|
|
||||||
const playsessionId = usePlaybackStore((state) => state.playsessionId);
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
const [supported, setSupported] = useState(() => supportsPictureInPicture());
|
|
||||||
const [active, setActive] = useState(false);
|
|
||||||
const [busy, setBusy] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const update = () => {
|
|
||||||
const currentVideo = getPlayerVideoElement();
|
|
||||||
if (currentVideo) {
|
|
||||||
setSupported(supportsPictureInPicture(currentVideo));
|
|
||||||
}
|
|
||||||
setActive(currentVideo ? isPictureInPictureActive(currentVideo) : false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const video = getPlayerVideoElement();
|
|
||||||
if (video) {
|
|
||||||
setSupported(supportsPictureInPicture(video));
|
|
||||||
setActive(isPictureInPictureActive(video));
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("enterpictureinpicture", update, true);
|
|
||||||
document.addEventListener("leavepictureinpicture", update, true);
|
|
||||||
document.addEventListener("webkitpresentationmodechanged", update, true);
|
|
||||||
const interval = window.setInterval(update, 1000);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
window.clearInterval(interval);
|
|
||||||
document.removeEventListener("enterpictureinpicture", update, true);
|
|
||||||
document.removeEventListener("leavepictureinpicture", update, true);
|
|
||||||
document.removeEventListener(
|
|
||||||
"webkitpresentationmodechanged",
|
|
||||||
update,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}, [playsessionId]);
|
|
||||||
|
|
||||||
if (!supported) return null;
|
|
||||||
|
|
||||||
const label = active ? "Выйти из картинки в картинке" : "Картинка в картинке";
|
|
||||||
|
|
||||||
const handleClick = async () => {
|
|
||||||
const video = getPlayerVideoElement();
|
|
||||||
if (!video) {
|
|
||||||
enqueueSnackbar("Видео ещё не готово", { variant: "info" });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
setBusy(true);
|
|
||||||
await togglePictureInPicture(video);
|
|
||||||
setActive(isPictureInPictureActive(video));
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Picture-in-picture failed", error);
|
|
||||||
enqueueSnackbar("Не удалось включить картинку в картинке", {
|
|
||||||
variant: "error",
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setBusy(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tooltip title={label}>
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
onClick={handleClick}
|
|
||||||
disabled={busy}
|
|
||||||
aria-label={label}
|
|
||||||
title={label}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded fill">
|
|
||||||
{active ? "picture_in_picture" : "picture_in_picture_alt"}
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default PictureInPictureButton;
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
import { Button } from "@mui/material";
|
import { Box, Button } from "@mui/material";
|
||||||
import { AnimatePresence, motion } from "motion/react";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
import useQueue from "@/utils/store/queue";
|
|
||||||
|
|
||||||
const SkipSegmentButton = () => {
|
const SkipSegmentButton = () => {
|
||||||
const {
|
const {
|
||||||
@@ -26,16 +25,11 @@ const SkipSegmentButton = () => {
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasNextItem = useQueue((state) =>
|
|
||||||
Boolean(state.tracks?.[state.currentItemIndex + 1]),
|
|
||||||
);
|
|
||||||
const segmentType = mediaSegments?.Items?.[currentSegmentIndex]?.Type;
|
|
||||||
const shouldShow =
|
const shouldShow =
|
||||||
mediaSegments?.Items?.length &&
|
mediaSegments?.Items?.length &&
|
||||||
currentSegmentIndex >= 0 &&
|
currentSegmentIndex >= 0 &&
|
||||||
activeSegmentId &&
|
activeSegmentId &&
|
||||||
(segmentType !== "Outro" || !hasNextItem);
|
mediaSegments?.Items?.[currentSegmentIndex].Type !== "Outro";
|
||||||
const label = segmentType === "Outro" ? "Пропустить титры" : segmentType === "Intro" ? "Пропустить интро" : segmentType === "Recap" ? "Пропустить рекап" : segmentType === "Commercial" ? "Пропустить рекламу" : segmentType === "Preview" ? "Пропустить превью" : "Пропустить";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
@@ -87,7 +81,7 @@ const SkipSegmentButton = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{label}
|
Skip {mediaSegments?.Items?.[currentSegmentIndex].Type}
|
||||||
</Button>
|
</Button>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
import {
|
|
||||||
IconButton,
|
|
||||||
ListItemIcon,
|
|
||||||
ListItemText,
|
|
||||||
Menu,
|
|
||||||
MenuItem,
|
|
||||||
Tooltip,
|
|
||||||
} from "@mui/material";
|
|
||||||
import React, { useState } from "react";
|
|
||||||
import type { VideoFitMode } from "@/utils/types/videoFitMode";
|
|
||||||
|
|
||||||
const OPTIONS: Array<{
|
|
||||||
value: VideoFitMode;
|
|
||||||
label: string;
|
|
||||||
icon: string;
|
|
||||||
hint: string;
|
|
||||||
}> = [
|
|
||||||
{
|
|
||||||
value: "fit",
|
|
||||||
label: "По размеру",
|
|
||||||
icon: "fit_screen",
|
|
||||||
hint: "Вписать видео целиком",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "fill",
|
|
||||||
label: "Заполнить экран",
|
|
||||||
icon: "zoom_out_map",
|
|
||||||
hint: "Убрать полосы, обрезав края",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "stretch",
|
|
||||||
label: "Растянуть",
|
|
||||||
icon: "aspect_ratio",
|
|
||||||
hint: "Растянуть на весь экран",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
type VideoFitButtonProps = {
|
|
||||||
mode: VideoFitMode;
|
|
||||||
onChange: (mode: VideoFitMode) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
const VideoFitButton = ({ mode, onChange }: VideoFitButtonProps) => {
|
|
||||||
const [anchor, setAnchor] = useState<HTMLButtonElement | null>(null);
|
|
||||||
const current = OPTIONS.find((option) => option.value === mode) ?? OPTIONS[0];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Tooltip title={`Режим изображения: ${current.label}`}>
|
|
||||||
<IconButton
|
|
||||||
onClick={(event) => setAnchor(event.currentTarget)}
|
|
||||||
aria-label="Режим изображения"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">aspect_ratio</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<Menu
|
|
||||||
anchorEl={anchor}
|
|
||||||
open={Boolean(anchor)}
|
|
||||||
onClose={() => setAnchor(null)}
|
|
||||||
anchorOrigin={{ vertical: "top", horizontal: "center" }}
|
|
||||||
transformOrigin={{ vertical: "bottom", horizontal: "center" }}
|
|
||||||
slotProps={{ paper: { className: "glass-menu-paper" } }}
|
|
||||||
>
|
|
||||||
{OPTIONS.map((option) => (
|
|
||||||
<MenuItem
|
|
||||||
key={option.value}
|
|
||||||
selected={option.value === mode}
|
|
||||||
onClick={() => {
|
|
||||||
onChange(option.value);
|
|
||||||
setAnchor(null);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
|
||||||
<span className="material-symbols-rounded">{option.icon}</span>
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText primary={option.label} secondary={option.hint} />
|
|
||||||
{option.value === mode && (
|
|
||||||
<span
|
|
||||||
className="material-symbols-rounded"
|
|
||||||
style={{ marginLeft: "1em" }}
|
|
||||||
>
|
|
||||||
check
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</MenuItem>
|
|
||||||
))}
|
|
||||||
</Menu>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default VideoFitButton;
|
|
||||||
@@ -1,34 +1,10 @@
|
|||||||
.video-player {
|
.video-player {
|
||||||
--media-object-fit: contain;
|
|
||||||
|
|
||||||
background: black;
|
background: black;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|
||||||
video {
|
|
||||||
object-fit: var(--media-object-fit);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.video-fit-fill {
|
|
||||||
--media-object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.video-fit-stretch {
|
|
||||||
--media-object-fit: fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-drag-region {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0 0 auto;
|
|
||||||
height: 38px;
|
|
||||||
z-index: 4;
|
|
||||||
cursor: default;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-osd {
|
&-osd {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
@@ -51,29 +27,6 @@
|
|||||||
&.hovering {
|
&.hovering {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
&-back,
|
|
||||||
&-actions {
|
|
||||||
position: absolute;
|
|
||||||
top: 2em;
|
|
||||||
z-index: 3;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0.3em;
|
|
||||||
border-radius: 999px;
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.08);
|
|
||||||
background: rgb(0 0 0 / 0.28);
|
|
||||||
backdrop-filter: blur(12px);
|
|
||||||
}
|
|
||||||
&-back {
|
|
||||||
left: 3em;
|
|
||||||
}
|
|
||||||
&-actions {
|
|
||||||
right: 3em;
|
|
||||||
gap: 0.35em;
|
|
||||||
}
|
|
||||||
&-info {
|
|
||||||
margin-top: auto;
|
|
||||||
}
|
|
||||||
&-controls {
|
&-controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||||
import { IconButton, Slider, Tooltip, Typography } from "@mui/material";
|
import { IconButton, Slider, Typography } from "@mui/material";
|
||||||
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
||||||
import { AnimatePresence, motion } from "motion/react";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import React, {
|
import React, {
|
||||||
@@ -10,36 +10,26 @@ import React, {
|
|||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import CastButton from "@/components/buttons/castButton";
|
|
||||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||||
import QueueButton from "@/components/buttons/queueButton";
|
import QueueButton from "@/components/buttons/queueButton";
|
||||||
import BubbleSlider from "@/components/playback/videoPlayer/bubbleSlider";
|
import BubbleSlider from "@/components/playback/videoPlayer/bubbleSlider";
|
||||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
import { secToTicks } from "@/utils/date/time";
|
||||||
import { buildPlayDeepLink } from "@/utils/deepLinks";
|
|
||||||
import { getPlayerVideoElement } from "@/utils/methods/pictureInPicture";
|
|
||||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useShareStore } from "@/utils/store/share";
|
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
import useSyncPlayback from "@/utils/store/syncPlayback";
|
|
||||||
import type { VideoFitMode } from "@/utils/types/videoFitMode";
|
|
||||||
import CaptionsButton from "./buttons/CaptionsButton";
|
import CaptionsButton from "./buttons/CaptionsButton";
|
||||||
import ChaptersListButton from "./buttons/ChaptersListButton";
|
import ChaptersListButton from "./buttons/ChaptersListButton";
|
||||||
import ForwardButton from "./buttons/ForwardButton";
|
import ForwardButton from "./buttons/ForwardButton";
|
||||||
import FullscreenButton from "./buttons/FullscreenButton";
|
import FullscreenButton from "./buttons/FullscreenButton";
|
||||||
import NextChapterButton from "./buttons/NextChapterButton";
|
import NextChapterButton from "./buttons/NextChapterButton";
|
||||||
import PictureInPictureButton from "./buttons/PictureInPictureButton";
|
|
||||||
import PlayPauseButton from "./buttons/PlayPauseButton";
|
import PlayPauseButton from "./buttons/PlayPauseButton";
|
||||||
import PrevChapterButton from "./buttons/PrevChapterButton";
|
import PrevChapterButton from "./buttons/PrevChapterButton";
|
||||||
import RewindButton from "./buttons/RewindButton";
|
import RewindButton from "./buttons/RewindButton";
|
||||||
import VideoFitButton from "./buttons/VideoFitButton";
|
|
||||||
import EndsAtDisplay from "./EndsAtDisplay";
|
import EndsAtDisplay from "./EndsAtDisplay";
|
||||||
import VideoPlayerSettingsMenu from "./settingsMenu";
|
import VideoPlayerSettingsMenu from "./settingsMenu";
|
||||||
|
|
||||||
import "./controls.scss";
|
import "./controls.scss";
|
||||||
import { clearQueue } from "@/utils/store/queue";
|
import { clearQueue } from "@/utils/store/queue";
|
||||||
import useQueue from "@/utils/store/queue";
|
|
||||||
import ProgressDisplay from "./ProgressDisplay";
|
import ProgressDisplay from "./ProgressDisplay";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,36 +42,19 @@ type VideoPlayerControlsProps = {
|
|||||||
// isVisible: boolean;
|
// isVisible: boolean;
|
||||||
onHover?: (event: MouseEvent<HTMLDivElement>) => void;
|
onHover?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||||
onLeave?: (event: MouseEvent<HTMLDivElement>) => void;
|
onLeave?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||||
fitMode: VideoFitMode;
|
|
||||||
onFitModeChange: (mode: VideoFitMode) => void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const VideoPlayerControls = ({
|
const VideoPlayerControls = ({
|
||||||
// isVisible,
|
// isVisible,
|
||||||
onHover,
|
onHover,
|
||||||
onLeave,
|
onLeave,
|
||||||
fitMode,
|
|
||||||
onFitModeChange,
|
|
||||||
}: VideoPlayerControlsProps) => {
|
}: VideoPlayerControlsProps) => {
|
||||||
const playerOSDRef = useRef<HTMLDivElement>(null);
|
const playerOSDRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const api = useApiInContext((state) => state.api);
|
const api = useApiInContext((state) => state.api);
|
||||||
const syncEnabled = useSyncPlayback((state) => state.enabled);
|
|
||||||
const syncMaster = useSyncPlayback((state) => state.master);
|
|
||||||
const startSync = useSyncPlayback((state) => state.start);
|
|
||||||
const stopSync = useSyncPlayback((state) => state.stop);
|
|
||||||
const syncThisVideo = syncEnabled && syncMaster?.sessionId === null;
|
|
||||||
const toggleSync = () => {
|
|
||||||
if (syncThisVideo) {
|
|
||||||
stopSync();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (itemId) startSync({ itemId, sessionId: null });
|
|
||||||
};
|
|
||||||
const {
|
const {
|
||||||
mediaSourceId,
|
mediaSourceId,
|
||||||
itemId,
|
itemId,
|
||||||
item,
|
|
||||||
itemName,
|
itemName,
|
||||||
episodeTitle,
|
episodeTitle,
|
||||||
playsessionId,
|
playsessionId,
|
||||||
@@ -98,13 +71,11 @@ const VideoPlayerControls = ({
|
|||||||
decreaseVolumeByStep,
|
decreaseVolumeByStep,
|
||||||
getCurrentTime,
|
getCurrentTime,
|
||||||
isUserHovering,
|
isUserHovering,
|
||||||
currentTime,
|
|
||||||
} = usePlaybackStore(
|
} = usePlaybackStore(
|
||||||
useShallow((state) => ({
|
useShallow((state) => ({
|
||||||
mediaSourceId: state.mediaSource.id,
|
mediaSourceId: state.mediaSource.id,
|
||||||
itemChapters: state.metadata.item.Chapters,
|
itemChapters: state.metadata.item.Chapters,
|
||||||
itemId: state.metadata.item.Id,
|
itemId: state.metadata.item.Id,
|
||||||
item: state.metadata.item,
|
|
||||||
itemName: state.metadata.itemName,
|
itemName: state.metadata.itemName,
|
||||||
episodeTitle: state.metadata.episodeTitle,
|
episodeTitle: state.metadata.episodeTitle,
|
||||||
// mediaSegments: state.metadata.mediaSegments,
|
// mediaSegments: state.metadata.mediaSegments,
|
||||||
@@ -122,7 +93,6 @@ const VideoPlayerControls = ({
|
|||||||
decreaseVolumeByStep: state.decreaseVolumeByStep,
|
decreaseVolumeByStep: state.decreaseVolumeByStep,
|
||||||
getCurrentTime: state.getCurrentTime,
|
getCurrentTime: state.getCurrentTime,
|
||||||
isUserHovering: state.playerState.isUserHovering,
|
isUserHovering: state.playerState.isUserHovering,
|
||||||
currentTime: state.playerState.currentTime,
|
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -146,76 +116,11 @@ const VideoPlayerControls = ({
|
|||||||
};
|
};
|
||||||
}, [increaseVolumeByStep, decreaseVolumeByStep]);
|
}, [increaseVolumeByStep, decreaseVolumeByStep]);
|
||||||
|
|
||||||
const [clickTimeout, setClickTimeout] = useState<ReturnType<
|
const [clickTimeout, setClickTimeout] = useState<NodeJS.Timeout | null>(null);
|
||||||
typeof setTimeout
|
|
||||||
> | null>(null);
|
|
||||||
const [showVolumeControl, setShowVolumeControl] = useState(false);
|
const [showVolumeControl, setShowVolumeControl] = useState(false);
|
||||||
|
|
||||||
const [settingsMenuRef, setSettingsMenuRef] =
|
const [settingsMenuRef, setSettingsMenuRef] =
|
||||||
useState<HTMLButtonElement | null>(null);
|
useState<HTMLButtonElement | null>(null);
|
||||||
const [videoFrame, setVideoFrame] = useState<{
|
|
||||||
top: number;
|
|
||||||
left: number;
|
|
||||||
right: number;
|
|
||||||
} | null>(null);
|
|
||||||
|
|
||||||
// Keep the back button and the top action buttons on one line inside the
|
|
||||||
// visible video area, below any letterbox bars.
|
|
||||||
useEffect(() => {
|
|
||||||
let frame = 0;
|
|
||||||
const update = () => {
|
|
||||||
const video = getPlayerVideoElement();
|
|
||||||
if (!video) return;
|
|
||||||
|
|
||||||
const rect = video.getBoundingClientRect();
|
|
||||||
const ratio =
|
|
||||||
video.videoWidth > 0 && video.videoHeight > 0
|
|
||||||
? video.videoWidth / video.videoHeight
|
|
||||||
: null;
|
|
||||||
const contentWidth = ratio
|
|
||||||
? Math.min(rect.width, rect.height * ratio)
|
|
||||||
: rect.width;
|
|
||||||
const contentHeight = ratio ? contentWidth / ratio : rect.height;
|
|
||||||
const contentLeft = rect.left + (rect.width - contentWidth) / 2;
|
|
||||||
const contentTop = rect.top + (rect.height - contentHeight) / 2;
|
|
||||||
|
|
||||||
setVideoFrame((current) => {
|
|
||||||
const next = {
|
|
||||||
// 14% keeps the controls inside the picture even when the
|
|
||||||
// file has letterbox bars baked into a 16:9 frame.
|
|
||||||
top: Math.round(
|
|
||||||
contentTop + Math.max(28, contentHeight * 0.14),
|
|
||||||
),
|
|
||||||
left: Math.round(contentLeft + 24),
|
|
||||||
right: Math.round(
|
|
||||||
window.innerWidth - contentLeft - contentWidth + 24,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
return current?.top === next.top &&
|
|
||||||
current?.left === next.left &&
|
|
||||||
current?.right === next.right
|
|
||||||
? current
|
|
||||||
: next;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const schedule = () => {
|
|
||||||
cancelAnimationFrame(frame);
|
|
||||||
frame = requestAnimationFrame(update);
|
|
||||||
};
|
|
||||||
|
|
||||||
schedule();
|
|
||||||
const video = getPlayerVideoElement();
|
|
||||||
video?.addEventListener("loadedmetadata", schedule);
|
|
||||||
window.addEventListener("resize", schedule);
|
|
||||||
const interval = window.setInterval(schedule, 1000);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cancelAnimationFrame(frame);
|
|
||||||
window.clearInterval(interval);
|
|
||||||
video?.removeEventListener("loadedmetadata", schedule);
|
|
||||||
window.removeEventListener("resize", schedule);
|
|
||||||
};
|
|
||||||
}, [playsessionId]);
|
|
||||||
|
|
||||||
// const creditInfo = mediaSegments?.Items?.find(
|
// const creditInfo = mediaSegments?.Items?.find(
|
||||||
// (segment) => segment.Type === "Outro",
|
// (segment) => segment.Type === "Outro",
|
||||||
@@ -300,59 +205,11 @@ const VideoPlayerControls = ({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div className="video-player-osd-header flex flex-justify-spaced-between flex-align-center">
|
||||||
className="video-player-osd-back"
|
<IconButton onClick={handleExitPlayer}>
|
||||||
style={
|
|
||||||
videoFrame
|
|
||||||
? { top: videoFrame.top, left: videoFrame.left }
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
onClick={handleExitPlayer}
|
|
||||||
aria-label="Выйти из плеера"
|
|
||||||
title="Выйти из плеера"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">arrow_back</span>
|
<span className="material-symbols-rounded">arrow_back</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
<IconButton onClick={(e) => setSettingsMenuRef(e.currentTarget)}>
|
||||||
<div
|
|
||||||
className="video-player-osd-actions"
|
|
||||||
style={
|
|
||||||
videoFrame
|
|
||||||
? { top: videoFrame.top, right: videoFrame.right }
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
onClick={() =>
|
|
||||||
useShareStore
|
|
||||||
.getState()
|
|
||||||
.openShareDialog(
|
|
||||||
buildPlayDeepLink(
|
|
||||||
itemId ?? "",
|
|
||||||
currentTime > 0 ? ticksToSec(currentTime) : getCurrentTime(),
|
|
||||||
),
|
|
||||||
"Поделиться этой сценой",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
aria-label="Поделиться сценой"
|
|
||||||
title="Поделиться сценой"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">share</span>
|
|
||||||
</IconButton>
|
|
||||||
<IconButton
|
|
||||||
onClick={openSyncPlayDialog}
|
|
||||||
aria-label="Смотреть вместе"
|
|
||||||
title="Смотреть вместе"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">groups</span>
|
|
||||||
</IconButton>
|
|
||||||
<IconButton
|
|
||||||
onClick={(e) => setSettingsMenuRef(e.currentTarget)}
|
|
||||||
aria-label="Настройки плеера"
|
|
||||||
title="Настройки плеера"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">settings</span>
|
<span className="material-symbols-rounded">settings</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<VideoPlayerSettingsMenu
|
<VideoPlayerSettingsMenu
|
||||||
@@ -447,39 +304,11 @@ const VideoPlayerControls = ({
|
|||||||
: "volume_up"}
|
: "volume_up"}
|
||||||
</span>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<CastButton
|
|
||||||
item={item}
|
|
||||||
getTransfer={() => ({
|
|
||||||
kind: "video",
|
|
||||||
positionTicks: secToTicks(
|
|
||||||
usePlaybackStore.getState().getCurrentTime(),
|
|
||||||
),
|
|
||||||
queue: useQueue.getState().tracks ?? [],
|
|
||||||
startIndex: useQueue.getState().currentItemIndex,
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
<Tooltip
|
|
||||||
title={syncThisVideo ? "Остановить синхронизацию" : "Синхронизация воспроизведения"}
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
aria-label="Синхронизация воспроизведения"
|
|
||||||
onClick={toggleSync}
|
|
||||||
sx={
|
|
||||||
syncThisVideo
|
|
||||||
? { color: "var(--mui-palette-primary-main)" }
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">sync</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<QueueButton />
|
<QueueButton />
|
||||||
|
|
||||||
<ChaptersListButton />
|
<ChaptersListButton />
|
||||||
|
|
||||||
<VideoFitButton mode={fitMode} onChange={onFitModeChange} />
|
|
||||||
<CaptionsButton />
|
<CaptionsButton />
|
||||||
<PictureInPictureButton />
|
|
||||||
<FullscreenButton />
|
<FullscreenButton />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
MenuItem,
|
MenuItem,
|
||||||
MenuList,
|
|
||||||
Popover,
|
Popover,
|
||||||
Switch,
|
Switch,
|
||||||
TextField,
|
TextField,
|
||||||
@@ -10,23 +9,16 @@ import { toNumber } from "lodash";
|
|||||||
import React, {
|
import React, {
|
||||||
type ChangeEventHandler,
|
type ChangeEventHandler,
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
|
||||||
useMemo,
|
useMemo,
|
||||||
useState,
|
|
||||||
useTransition,
|
useTransition,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import {
|
|
||||||
getAutoSkipSegments,
|
|
||||||
setAutoSkipSegments,
|
|
||||||
} from "@/utils/storage/player";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import {
|
import {
|
||||||
changeAudioTrack,
|
changeAudioTrack,
|
||||||
changeSubtitleTrack,
|
changeSubtitleTrack,
|
||||||
usePlaybackStore,
|
usePlaybackStore,
|
||||||
} from "@/utils/store/playback";
|
} from "@/utils/store/playback";
|
||||||
import useSyncPlayback from "@/utils/store/syncPlayback";
|
|
||||||
|
|
||||||
type VideoPlayerSettingsMenuProps = {
|
type VideoPlayerSettingsMenuProps = {
|
||||||
settingsMenuRef: HTMLButtonElement | null;
|
settingsMenuRef: HTMLButtonElement | null;
|
||||||
@@ -48,50 +40,15 @@ const VideoPlayerSettingsMenu = ({
|
|||||||
setIsBuffering,
|
setIsBuffering,
|
||||||
showStatsForNerds,
|
showStatsForNerds,
|
||||||
toggleShowStatsForNerds,
|
toggleShowStatsForNerds,
|
||||||
itemId,
|
|
||||||
} = usePlaybackStore(
|
} = usePlaybackStore(
|
||||||
useShallow((state) => ({
|
useShallow((state) => ({
|
||||||
mediaSource: state.mediaSource,
|
mediaSource: state.mediaSource,
|
||||||
setIsBuffering: state.setIsBuffering,
|
setIsBuffering: state.setIsBuffering,
|
||||||
showStatsForNerds: state.playerState.showStatsForNerds,
|
showStatsForNerds: state.playerState.showStatsForNerds,
|
||||||
toggleShowStatsForNerds: state.toggleShowStatsForNerds,
|
toggleShowStatsForNerds: state.toggleShowStatsForNerds,
|
||||||
itemId: state.metadata.item?.Id,
|
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
const syncEnabled = useSyncPlayback((state) => state.enabled);
|
|
||||||
const syncMaster = useSyncPlayback((state) => state.master);
|
|
||||||
const startSync = useSyncPlayback((state) => state.start);
|
|
||||||
const stopSync = useSyncPlayback((state) => state.stop);
|
|
||||||
const syncForThisVideo =
|
|
||||||
syncEnabled && syncMaster?.sessionId === null && Boolean(itemId);
|
|
||||||
const toggleSync = () => {
|
|
||||||
if (syncForThisVideo) {
|
|
||||||
stopSync();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (itemId) startSync({ itemId, sessionId: null });
|
|
||||||
};
|
|
||||||
|
|
||||||
const [autoSkip, setAutoSkip] = useState(false);
|
|
||||||
useEffect(() => {
|
|
||||||
let cancelled = false;
|
|
||||||
getAutoSkipSegments().then((enabled) => {
|
|
||||||
if (!cancelled) setAutoSkip(enabled);
|
|
||||||
});
|
|
||||||
return () => {
|
|
||||||
cancelled = true;
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const toggleAutoSkip = () => {
|
|
||||||
setAutoSkip((enabled) => {
|
|
||||||
const next = !enabled;
|
|
||||||
setAutoSkipSegments(next);
|
|
||||||
return next;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
||||||
const handleSubtitleChange: ChangeEventHandler<
|
const handleSubtitleChange: ChangeEventHandler<
|
||||||
HTMLInputElement | HTMLTextAreaElement
|
HTMLInputElement | HTMLTextAreaElement
|
||||||
@@ -156,7 +113,7 @@ const VideoPlayerSettingsMenu = ({
|
|||||||
>
|
>
|
||||||
<TextField
|
<TextField
|
||||||
select
|
select
|
||||||
label="Аудио"
|
label="Audio"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={mediaSource.audio?.track}
|
value={mediaSource.audio?.track}
|
||||||
onChange={handleAudioTrackChange}
|
onChange={handleAudioTrackChange}
|
||||||
@@ -171,7 +128,7 @@ const VideoPlayerSettingsMenu = ({
|
|||||||
</TextField>
|
</TextField>
|
||||||
<TextField
|
<TextField
|
||||||
select
|
select
|
||||||
label="Субтитры"
|
label="Subtitles"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={mediaSource.subtitle?.track}
|
value={mediaSource.subtitle?.track}
|
||||||
onChange={handleSubtitleChange}
|
onChange={handleSubtitleChange}
|
||||||
@@ -179,7 +136,7 @@ const VideoPlayerSettingsMenu = ({
|
|||||||
disabled={mediaSource.subtitle?.track === -2 || subtitleIsChanging}
|
disabled={mediaSource.subtitle?.track === -2 || subtitleIsChanging}
|
||||||
>
|
>
|
||||||
<MenuItem key={-1} value={-1}>
|
<MenuItem key={-1} value={-1}>
|
||||||
Без субтитров
|
No Subtitle
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{mediaSource.subtitle?.allTracks?.map((sub) => (
|
{mediaSource.subtitle?.allTracks?.map((sub) => (
|
||||||
<MenuItem key={sub.Index} value={sub.Index}>
|
<MenuItem key={sub.Index} value={sub.Index}>
|
||||||
@@ -187,47 +144,16 @@ const VideoPlayerSettingsMenu = ({
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</TextField>
|
</TextField>
|
||||||
<MenuList disablePadding>
|
|
||||||
<MenuItem onClick={toggleShowStatsForNerds}>
|
<MenuItem onClick={toggleShowStatsForNerds}>
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Статистика
|
Stats for Nerds
|
||||||
</Typography>
|
</Typography>
|
||||||
<Switch checked={showStatsForNerds} />
|
<Switch checked={showStatsForNerds} />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem onClick={toggleSync} disabled={!itemId}>
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
flexGrow: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Синхронизация воспроизведения
|
|
||||||
</Typography>
|
|
||||||
<Switch
|
|
||||||
checked={syncForThisVideo}
|
|
||||||
disabled={!itemId}
|
|
||||||
onClick={(event) => event.stopPropagation()}
|
|
||||||
onChange={toggleSync}
|
|
||||||
/>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem onClick={toggleAutoSkip}>
|
|
||||||
<Typography
|
|
||||||
sx={{
|
|
||||||
flexGrow: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Автопропуск заставок, рекапов, рекламы и превью
|
|
||||||
</Typography>
|
|
||||||
<Switch
|
|
||||||
checked={autoSkip}
|
|
||||||
onClick={(event) => event.stopPropagation()}
|
|
||||||
onChange={toggleAutoSkip}
|
|
||||||
/>
|
|
||||||
</MenuItem>
|
|
||||||
</MenuList>
|
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ const UpNextFlyout = () => {
|
|||||||
quality: 90,
|
quality: 90,
|
||||||
fillWidth: 320,
|
fillWidth: 320,
|
||||||
})}
|
})}
|
||||||
alt="Миниатюра следующего элемента"
|
alt="next item thumbnail"
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
@@ -142,7 +142,7 @@ const UpNextFlyout = () => {
|
|||||||
letterSpacing: 1.2,
|
letterSpacing: 1.2,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
ДАЛЕЕ
|
UP NEXT
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h6"
|
variant="h6"
|
||||||
@@ -192,7 +192,7 @@ const UpNextFlyout = () => {
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Смотреть
|
Play Now
|
||||||
</Button>
|
</Button>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => setIsHidden(true)}
|
onClick={() => setIsHidden(true)}
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
import { CircularProgress } from "@mui/material";
|
|
||||||
import QRCode from "qrcode";
|
|
||||||
import React, { useEffect, useState } from "react";
|
|
||||||
|
|
||||||
const QRCodeImage = ({
|
|
||||||
value,
|
|
||||||
size = 220,
|
|
||||||
}: {
|
|
||||||
value: string;
|
|
||||||
size?: number;
|
|
||||||
}) => {
|
|
||||||
const [src, setSrc] = useState<string | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let cancelled = false;
|
|
||||||
setSrc(null);
|
|
||||||
QRCode.toDataURL(value, {
|
|
||||||
errorCorrectionLevel: "M",
|
|
||||||
margin: 1,
|
|
||||||
width: size,
|
|
||||||
color: { dark: "#ffffffff", light: "#00000000" },
|
|
||||||
})
|
|
||||||
.then((url) => {
|
|
||||||
if (!cancelled) setSrc(url);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error("Could not create QR code", error);
|
|
||||||
});
|
|
||||||
return () => {
|
|
||||||
cancelled = true;
|
|
||||||
};
|
|
||||||
}, [value, size]);
|
|
||||||
|
|
||||||
if (!src) return <CircularProgress size={24} />;
|
|
||||||
return (
|
|
||||||
<img
|
|
||||||
src={src}
|
|
||||||
alt="QR-код"
|
|
||||||
width={size}
|
|
||||||
height={size}
|
|
||||||
style={{ display: "block", borderRadius: 12 }}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default React.memo(QRCodeImage);
|
|
||||||
@@ -1,325 +0,0 @@
|
|||||||
.queue {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-height: 0;
|
|
||||||
height: 100%;
|
|
||||||
color: white;
|
|
||||||
|
|
||||||
&-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 1rem;
|
|
||||||
padding-bottom: 0.75rem;
|
|
||||||
|
|
||||||
&-text {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-actions {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.125rem;
|
|
||||||
flex-shrink: 0;
|
|
||||||
|
|
||||||
.MuiIconButton-root {
|
|
||||||
color: rgb(255 255 255 / 0.75);
|
|
||||||
&:hover {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-title {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-summary {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-body {
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1.25rem;
|
|
||||||
// Room so focus rings and the dragged row aren't clipped
|
|
||||||
padding: 2px 2px 1rem;
|
|
||||||
margin: 0 -2px;
|
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
|
||||||
width: 6px;
|
|
||||||
}
|
|
||||||
&::-webkit-scrollbar-thumb {
|
|
||||||
background: rgb(255 255 255 / 0.2);
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.5rem;
|
|
||||||
|
|
||||||
&-label {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 0.7rem;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
text-transform: uppercase;
|
|
||||||
opacity: 0.55;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-toggle {
|
|
||||||
all: unset;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 0.25rem 0.5rem;
|
|
||||||
margin: 0 -0.5rem;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
|
|
||||||
&:hover,
|
|
||||||
&:focus-visible {
|
|
||||||
background: rgb(255 255 255 / 0.05);
|
|
||||||
}
|
|
||||||
.material-symbols-rounded {
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-hint {
|
|
||||||
margin: 0.25rem 0 0;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
opacity: 0.4;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-empty {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.25rem;
|
|
||||||
padding: 2rem 1rem;
|
|
||||||
text-align: center;
|
|
||||||
border: 1px dashed rgb(255 255 255 / 0.12);
|
|
||||||
border-radius: 0.75rem;
|
|
||||||
|
|
||||||
&-icon {
|
|
||||||
font-size: 2.25rem;
|
|
||||||
opacity: 0.4;
|
|
||||||
margin-bottom: 0.25rem;
|
|
||||||
}
|
|
||||||
&-title {
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
&-text {
|
|
||||||
font-size: 0.85rem;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.queue-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.75rem;
|
|
||||||
padding: 0.4rem 0.5rem;
|
|
||||||
border-radius: 0.6rem;
|
|
||||||
outline: none;
|
|
||||||
background: transparent;
|
|
||||||
transition: background-color 0.15s ease;
|
|
||||||
|
|
||||||
&[role="button"] {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover,
|
|
||||||
&:focus-visible,
|
|
||||||
&.is-dragging {
|
|
||||||
background: rgb(255 255 255 / 0.07);
|
|
||||||
}
|
|
||||||
&:focus-visible {
|
|
||||||
box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.4);
|
|
||||||
}
|
|
||||||
&.is-dragging {
|
|
||||||
box-shadow: 0 8px 24px rgb(0 0 0 / 0.45);
|
|
||||||
background: rgb(40 40 50 / 0.95);
|
|
||||||
}
|
|
||||||
|
|
||||||
&-current {
|
|
||||||
background: rgb(255 255 255 / 0.08);
|
|
||||||
|
|
||||||
.queue-row-title {
|
|
||||||
color: $clr-accent-default;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-history {
|
|
||||||
opacity: 0.6;
|
|
||||||
&:hover,
|
|
||||||
&:focus-visible {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-handle {
|
|
||||||
all: unset;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 1.25rem;
|
|
||||||
margin-right: -0.25rem;
|
|
||||||
cursor: grab;
|
|
||||||
touch-action: none;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.15s ease;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
||||||
&:active {
|
|
||||||
cursor: grabbing;
|
|
||||||
}
|
|
||||||
&:focus-visible {
|
|
||||||
opacity: 1;
|
|
||||||
outline: 2px solid rgb(255 255 255 / 0.4);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-art {
|
|
||||||
position: relative;
|
|
||||||
flex-shrink: 0;
|
|
||||||
width: 44px;
|
|
||||||
height: 44px;
|
|
||||||
border-radius: 6px;
|
|
||||||
overflow: hidden;
|
|
||||||
background: rgb(255 255 255 / 0.08);
|
|
||||||
|
|
||||||
img {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-fallback,
|
|
||||||
&-overlay,
|
|
||||||
&-play {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
&-fallback {
|
|
||||||
opacity: 0.4;
|
|
||||||
font-size: 1.25rem !important;
|
|
||||||
}
|
|
||||||
&-overlay,
|
|
||||||
&-play {
|
|
||||||
background: rgb(0 0 0 / 0.55);
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
&-overlay {
|
|
||||||
color: $clr-accent-default;
|
|
||||||
}
|
|
||||||
&-play {
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.15s ease;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-text {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-title {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
font-weight: 600;
|
|
||||||
line-height: 1.25;
|
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
-webkit-line-clamp: 2;
|
|
||||||
overflow: hidden;
|
|
||||||
overflow-wrap: anywhere;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-subtitle {
|
|
||||||
font-size: 0.78rem;
|
|
||||||
opacity: 0.6;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-duration {
|
|
||||||
flex-shrink: 0;
|
|
||||||
font-size: 0.78rem;
|
|
||||||
opacity: 0.55;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-remove.MuiIconButton-root {
|
|
||||||
flex-shrink: 0;
|
|
||||||
color: rgb(255 255 255 / 0.7);
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.15s ease;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reveal row controls on hover / keyboard focus; always shown on touch screens
|
|
||||||
&:hover,
|
|
||||||
&:focus-within {
|
|
||||||
.queue-row-handle,
|
|
||||||
.queue-row-remove {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
.queue-row-art-play {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media (hover: none) {
|
|
||||||
.queue-row-handle,
|
|
||||||
.queue-row-remove {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Queue drawer (mini player / video player)
|
|
||||||
.queue-drawer-paper.MuiPaper-root {
|
|
||||||
width: 420px;
|
|
||||||
max-width: 100%;
|
|
||||||
padding: 1.25rem 1rem 0 1.25rem;
|
|
||||||
box-sizing: border-box;
|
|
||||||
background: rgb(18 18 24 / 0.97);
|
|
||||||
border-left: 1px solid rgb(255 255 255 / 0.08);
|
|
||||||
background-image: none;
|
|
||||||
}
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
import { useSortable } from "@dnd-kit/sortable";
|
|
||||||
import { CSS } from "@dnd-kit/utilities";
|
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
|
||||||
import React from "react";
|
|
||||||
import { getRuntimeMusic } from "@/utils/date/time";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
|
|
||||||
export const getQueueItemText = (item: BaseItemDto) => {
|
|
||||||
if (item.Type === "Episode") {
|
|
||||||
const episode = item.IndexNumberEnd
|
|
||||||
? `E${item.IndexNumber}-${item.IndexNumberEnd}`
|
|
||||||
: `E${item.IndexNumber}`;
|
|
||||||
return {
|
|
||||||
title: item.Name ?? "Неизвестная серия",
|
|
||||||
subtitle: [item.SeriesName, `S${item.ParentIndexNumber}:${episode}`]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(" · "),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
title: item.Name ?? "Неизвестный трек",
|
|
||||||
subtitle: item.Artists?.join(", ") || item.AlbumArtist || "",
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const useQueueItemImage = (item: BaseItemDto) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
if (!api || !item.Id) return undefined;
|
|
||||||
const size = { fillWidth: 96, fillHeight: 96, quality: 85 };
|
|
||||||
if (item.ImageTags?.Primary) {
|
|
||||||
return getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
|
|
||||||
...size,
|
|
||||||
tag: item.ImageTags.Primary,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
|
||||||
return getImageUrlsApi(api).getItemImageUrlById(item.AlbumId, "Primary", {
|
|
||||||
...size,
|
|
||||||
tag: item.AlbumPrimaryImageTag,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
type QueueRowProps = {
|
|
||||||
item: BaseItemDto;
|
|
||||||
variant: "current" | "upcoming" | "history";
|
|
||||||
onPlay?: () => void;
|
|
||||||
onRemove?: () => void;
|
|
||||||
/** Drag handle props from useSortable (upcoming rows only). */
|
|
||||||
dragHandle?: React.HTMLAttributes<HTMLButtonElement>;
|
|
||||||
isDragging?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const QueueRow = React.forwardRef<
|
|
||||||
HTMLDivElement,
|
|
||||||
QueueRowProps & { style?: React.CSSProperties }
|
|
||||||
>(({ item, variant, onPlay, onRemove, dragHandle, isDragging, style }, ref) => {
|
|
||||||
const imageUrl = useQueueItemImage(item);
|
|
||||||
const { title, subtitle } = getQueueItemText(item);
|
|
||||||
const isCurrent = variant === "current";
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
ref={ref}
|
|
||||||
style={style}
|
|
||||||
className={`queue-row queue-row-${variant} ${isDragging ? "is-dragging" : ""}`}
|
|
||||||
{...(onPlay && {
|
|
||||||
role: "button",
|
|
||||||
tabIndex: 0,
|
|
||||||
"aria-label": `Play ${title}`,
|
|
||||||
})}
|
|
||||||
onClick={onPlay}
|
|
||||||
onKeyDown={(e) => {
|
|
||||||
if (e.target !== e.currentTarget) return;
|
|
||||||
if (onPlay && (e.key === "Enter" || e.key === " ")) {
|
|
||||||
e.preventDefault();
|
|
||||||
onPlay();
|
|
||||||
} else if (onRemove && (e.key === "Delete" || e.key === "Backspace")) {
|
|
||||||
e.preventDefault();
|
|
||||||
onRemove();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{dragHandle && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="queue-row-handle"
|
|
||||||
aria-label={`Reorder ${title}`}
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
{...dragHandle}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">drag_indicator</span>
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
<div className="queue-row-art">
|
|
||||||
<span className="material-symbols-rounded queue-row-art-fallback">
|
|
||||||
{item.Type === "Episode" ? "tv_gen" : "music_note"}
|
|
||||||
</span>
|
|
||||||
{imageUrl && <img src={imageUrl} alt="" loading="lazy" />}
|
|
||||||
{isCurrent && (
|
|
||||||
<span className="queue-row-art-overlay material-symbols-rounded">
|
|
||||||
graphic_eq
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{onPlay && (
|
|
||||||
<span className="queue-row-art-play material-symbols-rounded">
|
|
||||||
play_arrow
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="queue-row-text">
|
|
||||||
<span className="queue-row-title" title={title}>
|
|
||||||
{title}
|
|
||||||
</span>
|
|
||||||
{subtitle && <span className="queue-row-subtitle">{subtitle}</span>}
|
|
||||||
</div>
|
|
||||||
<span className="queue-row-duration">
|
|
||||||
{item.RunTimeTicks ? getRuntimeMusic(item.RunTimeTicks) : ""}
|
|
||||||
</span>
|
|
||||||
{onRemove && (
|
|
||||||
<Tooltip title="Удалить из очереди">
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
className="queue-row-remove"
|
|
||||||
aria-label={`Remove ${title} from queue`}
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onRemove();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">close</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
/** An upcoming row that can be dragged to reorder. */
|
|
||||||
export const SortableQueueRow = (
|
|
||||||
props: Omit<QueueRowProps, "dragHandle" | "isDragging" | "variant">,
|
|
||||||
) => {
|
|
||||||
const {
|
|
||||||
attributes,
|
|
||||||
listeners,
|
|
||||||
setNodeRef,
|
|
||||||
setActivatorNodeRef,
|
|
||||||
transform,
|
|
||||||
transition,
|
|
||||||
isDragging,
|
|
||||||
} = useSortable({ id: props.item.Id ?? "" });
|
|
||||||
|
|
||||||
return (
|
|
||||||
<QueueRow
|
|
||||||
{...props}
|
|
||||||
ref={setNodeRef}
|
|
||||||
variant="upcoming"
|
|
||||||
isDragging={isDragging}
|
|
||||||
style={{
|
|
||||||
transform: CSS.Translate.toString(transform),
|
|
||||||
transition,
|
|
||||||
zIndex: isDragging ? 2 : undefined,
|
|
||||||
position: "relative",
|
|
||||||
}}
|
|
||||||
dragHandle={
|
|
||||||
{
|
|
||||||
...attributes,
|
|
||||||
...listeners,
|
|
||||||
ref: setActivatorNodeRef,
|
|
||||||
} as React.HTMLAttributes<HTMLButtonElement>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,273 +0,0 @@
|
|||||||
import {
|
|
||||||
closestCenter,
|
|
||||||
DndContext,
|
|
||||||
type DragEndEvent,
|
|
||||||
KeyboardSensor,
|
|
||||||
PointerSensor,
|
|
||||||
useSensor,
|
|
||||||
useSensors,
|
|
||||||
} from "@dnd-kit/core";
|
|
||||||
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
|
||||||
import {
|
|
||||||
arrayMove,
|
|
||||||
SortableContext,
|
|
||||||
sortableKeyboardCoordinates,
|
|
||||||
verticalListSortingStrategy,
|
|
||||||
} from "@dnd-kit/sortable";
|
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import Button from "@mui/material/Button";
|
|
||||||
import Collapse from "@mui/material/Collapse";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import React, { useMemo, useState } from "react";
|
|
||||||
import { getRuntimeCompact } from "@/utils/date/time";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import { playItemFromQueue } from "@/utils/store/playback";
|
|
||||||
import useQueue, {
|
|
||||||
clearUpcoming,
|
|
||||||
insertIntoQueue,
|
|
||||||
removeFromQueue,
|
|
||||||
reorderQueue,
|
|
||||||
shuffleUpcoming,
|
|
||||||
} from "@/utils/store/queue";
|
|
||||||
import { getQueueItemText, QueueRow, SortableQueueRow } from "./queueRow";
|
|
||||||
|
|
||||||
import "./queue.scss";
|
|
||||||
|
|
||||||
type QueueViewProps = {
|
|
||||||
/**
|
|
||||||
* "drawer": standalone queue with the now playing row and a close button.
|
|
||||||
* "panel": embedded next to a full player that already shows the current track.
|
|
||||||
*/
|
|
||||||
variant: "drawer" | "panel";
|
|
||||||
onClose?: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
const QueueView = ({ variant, onClose }: QueueViewProps) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const userId = useCentralStore((s) => s.currentUser?.Id ?? undefined);
|
|
||||||
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
|
|
||||||
const [tracks, currentIndex] = useQueue((s) => [
|
|
||||||
s.tracks,
|
|
||||||
s.currentItemIndex,
|
|
||||||
]);
|
|
||||||
const [showHistory, setShowHistory] = useState(false);
|
|
||||||
|
|
||||||
const queue = tracks ?? [];
|
|
||||||
const current = queue[currentIndex];
|
|
||||||
const history = queue.slice(0, currentIndex);
|
|
||||||
const upcoming = useMemo(
|
|
||||||
() => queue.slice(currentIndex + 1),
|
|
||||||
[queue, currentIndex],
|
|
||||||
);
|
|
||||||
const upcomingTicks = upcoming.reduce(
|
|
||||||
(total, item) => total + (item.RunTimeTicks ?? 0),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
|
|
||||||
const sensors = useSensors(
|
|
||||||
useSensor(PointerSensor, { activationConstraint: { distance: 4 } }),
|
|
||||||
useSensor(KeyboardSensor, {
|
|
||||||
coordinateGetter: sortableKeyboardCoordinates,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
const play = (index: number) => {
|
|
||||||
playItemFromQueue(index, userId, api);
|
|
||||||
};
|
|
||||||
|
|
||||||
const remove = (item: BaseItemDto, index: number) => {
|
|
||||||
removeFromQueue(index);
|
|
||||||
const { title } = getQueueItemText(item);
|
|
||||||
enqueueSnackbar(`«${title}» удалён`, {
|
|
||||||
variant: "default",
|
|
||||||
action: (key) => (
|
|
||||||
<Button
|
|
||||||
color="inherit"
|
|
||||||
size="small"
|
|
||||||
onClick={() => {
|
|
||||||
insertIntoQueue(item, index);
|
|
||||||
closeSnackbar(key);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Отменить
|
|
||||||
</Button>
|
|
||||||
),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const clearAll = () => {
|
|
||||||
const removed = upcoming;
|
|
||||||
clearUpcoming();
|
|
||||||
enqueueSnackbar(`Очищено треков из очереди: ${removed.length}`, {
|
|
||||||
action: (key) => (
|
|
||||||
<Button
|
|
||||||
color="inherit"
|
|
||||||
size="small"
|
|
||||||
onClick={() => {
|
|
||||||
const state = useQueue.getState();
|
|
||||||
reorderQueue([
|
|
||||||
...(state.tracks ?? []).slice(0, state.currentItemIndex + 1),
|
|
||||||
...removed,
|
|
||||||
]);
|
|
||||||
closeSnackbar(key);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Отменить
|
|
||||||
</Button>
|
|
||||||
),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDragEnd = ({ active, over }: DragEndEvent) => {
|
|
||||||
if (!over || active.id === over.id) return;
|
|
||||||
const from = upcoming.findIndex((item) => item.Id === active.id);
|
|
||||||
const to = upcoming.findIndex((item) => item.Id === over.id);
|
|
||||||
if (from === -1 || to === -1) return;
|
|
||||||
reorderQueue([
|
|
||||||
...queue.slice(0, currentIndex + 1),
|
|
||||||
...arrayMove(upcoming, from, to),
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
const summary =
|
|
||||||
upcoming.length > 0
|
|
||||||
? `${upcoming.length} ${upcoming.length === 1 ? "track" : "tracks"} · ${getRuntimeCompact(upcomingTicks)}`
|
|
||||||
: "Очередь пуста";
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={`queue queue-${variant}`}>
|
|
||||||
<header className="queue-header">
|
|
||||||
<div className="queue-header-text">
|
|
||||||
<h2 className="queue-title">
|
|
||||||
{variant === "drawer" ? "Очередь" : "Далее"}
|
|
||||||
</h2>
|
|
||||||
<span className="queue-summary">{summary}</span>
|
|
||||||
</div>
|
|
||||||
<div className="queue-header-actions">
|
|
||||||
<Tooltip title="Перемешать очередь">
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
onClick={shuffleUpcoming}
|
|
||||||
disabled={upcoming.length < 2}
|
|
||||||
aria-label="Перемешать очередь"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">shuffle</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Очистить очередь">
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
onClick={clearAll}
|
|
||||||
disabled={upcoming.length === 0}
|
|
||||||
aria-label="Очистить очередь"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
playlist_remove
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
{onClose && (
|
|
||||||
<IconButton onClick={onClose} aria-label="Закрыть очередь">
|
|
||||||
<span className="material-symbols-rounded">close</span>
|
|
||||||
</IconButton>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div className="queue-body">
|
|
||||||
{variant === "drawer" && current && (
|
|
||||||
<section className="queue-section">
|
|
||||||
<h3 className="queue-section-label">Сейчас играет</h3>
|
|
||||||
<QueueRow item={current} variant="current" />
|
|
||||||
</section>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<section className="queue-section">
|
|
||||||
{variant === "drawer" && (
|
|
||||||
<h3 className="queue-section-label">Далее</h3>
|
|
||||||
)}
|
|
||||||
{upcoming.length > 0 ? (
|
|
||||||
<>
|
|
||||||
<DndContext
|
|
||||||
sensors={sensors}
|
|
||||||
collisionDetection={closestCenter}
|
|
||||||
onDragEnd={handleDragEnd}
|
|
||||||
modifiers={[restrictToVerticalAxis]}
|
|
||||||
>
|
|
||||||
<SortableContext
|
|
||||||
items={upcoming.map((item) => item.Id ?? "")}
|
|
||||||
strategy={verticalListSortingStrategy}
|
|
||||||
>
|
|
||||||
<div className="queue-list">
|
|
||||||
{upcoming.map((item, offset) => {
|
|
||||||
const index = currentIndex + 1 + offset;
|
|
||||||
return (
|
|
||||||
<SortableQueueRow
|
|
||||||
key={item.Id ?? index}
|
|
||||||
item={item}
|
|
||||||
onPlay={() => play(index)}
|
|
||||||
onRemove={() => remove(item, index)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</SortableContext>
|
|
||||||
</DndContext>
|
|
||||||
<p className="queue-hint">
|
|
||||||
Нажмите на трек, чтобы включить его, перетащите для сортировки
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<div className="queue-empty">
|
|
||||||
<span className="material-symbols-rounded queue-empty-icon">
|
|
||||||
queue_music
|
|
||||||
</span>
|
|
||||||
<span className="queue-empty-title">Очередь пуста</span>
|
|
||||||
<span className="queue-empty-text">
|
|
||||||
Включите альбом, плейлист или исполнителя, чтобы заполнить очередь.
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</section>
|
|
||||||
|
|
||||||
{history.length > 0 && (
|
|
||||||
<section className="queue-section">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="queue-section-toggle"
|
|
||||||
onClick={() => setShowHistory((open) => !open)}
|
|
||||||
aria-expanded={showHistory}
|
|
||||||
>
|
|
||||||
<span className="queue-section-label">
|
|
||||||
Ранее играло · {history.length}
|
|
||||||
</span>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
{showHistory ? "expand_less" : "expand_more"}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
<Collapse in={showHistory} unmountOnExit>
|
|
||||||
<div className="queue-list">
|
|
||||||
{history.map((item, index) => (
|
|
||||||
<QueueRow
|
|
||||||
key={item.Id ?? index}
|
|
||||||
item={item}
|
|
||||||
variant="history"
|
|
||||||
onPlay={() => play(index)}
|
|
||||||
onRemove={() => remove(item, index)}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</Collapse>
|
|
||||||
</section>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default QueueView;
|
|
||||||
@@ -0,0 +1,236 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
IconButton,
|
||||||
|
ListItem,
|
||||||
|
ListItemAvatar,
|
||||||
|
ListItemText,
|
||||||
|
} from "@mui/material";
|
||||||
|
import React from "react";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
|
|
||||||
|
type QueueListItemProps = {
|
||||||
|
queueItem: BaseItemDto;
|
||||||
|
active?: boolean;
|
||||||
|
onDelete?: () => void;
|
||||||
|
onPlay?: () => void;
|
||||||
|
dragHandleProps?: any;
|
||||||
|
isEpisode?: boolean;
|
||||||
|
index?: number;
|
||||||
|
className?: string;
|
||||||
|
sx?: any;
|
||||||
|
};
|
||||||
|
|
||||||
|
const QueueListItem = ({
|
||||||
|
queueItem,
|
||||||
|
active,
|
||||||
|
onDelete,
|
||||||
|
onPlay,
|
||||||
|
dragHandleProps,
|
||||||
|
isEpisode,
|
||||||
|
className,
|
||||||
|
sx,
|
||||||
|
}: QueueListItemProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
|
const imageUrl =
|
||||||
|
api &&
|
||||||
|
queueItem.Id &&
|
||||||
|
(queueItem.ImageTags?.Primary
|
||||||
|
? getImageUrlsApi(api).getItemImageUrlById(queueItem.Id, "Primary", {
|
||||||
|
tag: queueItem.ImageTags.Primary,
|
||||||
|
})
|
||||||
|
: queueItem.AlbumPrimaryImageTag?.[0]
|
||||||
|
? getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
queueItem.AlbumId || "",
|
||||||
|
"Primary",
|
||||||
|
{ tag: queueItem.AlbumPrimaryImageTag[0] },
|
||||||
|
)
|
||||||
|
: null);
|
||||||
|
|
||||||
|
const primaryText = queueItem.SeriesName || queueItem.Name;
|
||||||
|
|
||||||
|
let secondaryText = "";
|
||||||
|
if (isEpisode) {
|
||||||
|
const season = queueItem.ParentIndexNumber;
|
||||||
|
const episode = queueItem.IndexNumber;
|
||||||
|
const episodeEnd = queueItem.IndexNumberEnd;
|
||||||
|
const episodeString = episodeEnd
|
||||||
|
? `S${season}:E${episode}-${episodeEnd}`
|
||||||
|
: `S${season}:E${episode}`;
|
||||||
|
|
||||||
|
secondaryText = `${episodeString} - ${queueItem.Name}`;
|
||||||
|
} else {
|
||||||
|
secondaryText = queueItem.Artists?.join(", ") || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ListItem
|
||||||
|
component="div"
|
||||||
|
className={className}
|
||||||
|
secondaryAction={
|
||||||
|
onDelete && (
|
||||||
|
<IconButton
|
||||||
|
edge="end"
|
||||||
|
aria-label="delete"
|
||||||
|
onClick={onDelete}
|
||||||
|
size="small"
|
||||||
|
sx={{
|
||||||
|
opacity: 0,
|
||||||
|
transition: "opacity 0.2s",
|
||||||
|
".MuiListItem-root:hover &": { opacity: 0.7 },
|
||||||
|
"&:hover": { opacity: "1 !important", bgcolor: "action.hover" },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded" style={{ fontSize: 20 }}>
|
||||||
|
close
|
||||||
|
</span>
|
||||||
|
</IconButton>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
sx={{
|
||||||
|
opacity: active ? 1 : 1,
|
||||||
|
bgcolor: active ? "rgba(255, 255, 255, 0.1)" : "rgba(0,0,0,0.2)",
|
||||||
|
borderRadius: 3,
|
||||||
|
mb: 0,
|
||||||
|
transition: "all 0.2s ease",
|
||||||
|
border: "1px solid",
|
||||||
|
borderColor: active
|
||||||
|
? "rgba(255, 255, 255, 0.2)"
|
||||||
|
: "rgba(255,255,255,0.05)",
|
||||||
|
"&:hover": {
|
||||||
|
bgcolor: active
|
||||||
|
? "rgba(255, 255, 255, 0.15)"
|
||||||
|
: "rgba(255,255,255,0.05)",
|
||||||
|
transform: active ? "none" : "translateY(-2px)",
|
||||||
|
borderColor: active
|
||||||
|
? "rgba(255, 255, 255, 0.3)"
|
||||||
|
: "rgba(255,255,255,0.2)",
|
||||||
|
boxShadow: active ? "none" : "0 4px 12px rgba(0,0,0,0.2)",
|
||||||
|
},
|
||||||
|
pr: onDelete ? 6 : 2,
|
||||||
|
...sx,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{dragHandleProps && (
|
||||||
|
<div
|
||||||
|
{...dragHandleProps}
|
||||||
|
style={{
|
||||||
|
cursor: "grab",
|
||||||
|
marginRight: 12,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
opacity: 0.5,
|
||||||
|
transition: "opacity 0.2s",
|
||||||
|
}}
|
||||||
|
className="drag-handle"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">drag_indicator</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<ListItemAvatar sx={{ minWidth: 64 }}>
|
||||||
|
<Box
|
||||||
|
onClick={onPlay}
|
||||||
|
sx={{
|
||||||
|
width: 48,
|
||||||
|
height: 48,
|
||||||
|
borderRadius: 2,
|
||||||
|
overflow: "hidden",
|
||||||
|
position: "relative",
|
||||||
|
boxShadow: "0 2px 8px rgba(0,0,0,0.2)",
|
||||||
|
cursor: onPlay ? "pointer" : "default",
|
||||||
|
"&:hover .play-overlay": {
|
||||||
|
opacity: 1,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{imageUrl ? (
|
||||||
|
<img
|
||||||
|
src={imageUrl}
|
||||||
|
alt={queueItem.Name || ""}
|
||||||
|
style={{ width: "100%", height: "100%", objectFit: "cover" }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
background: "#2a2a2a",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{queueItem.Type && getTypeIcon(queueItem.Type)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{active && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
inset: 0,
|
||||||
|
background: "rgba(0,0,0,0.4)",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
backdropFilter: "blur(2px)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{ fontSize: "1.5rem", color: "white" }}
|
||||||
|
>
|
||||||
|
equalizer
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!active && onPlay && (
|
||||||
|
<Box
|
||||||
|
className="play-overlay"
|
||||||
|
sx={{
|
||||||
|
position: "absolute",
|
||||||
|
inset: 0,
|
||||||
|
background: "rgba(0,0,0,0.4)",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
opacity: 0,
|
||||||
|
transition: "opacity 0.2s",
|
||||||
|
backdropFilter: "blur(1px)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={{ fontSize: "2rem", color: "white" }}
|
||||||
|
>
|
||||||
|
play_arrow
|
||||||
|
</span>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</ListItemAvatar>
|
||||||
|
|
||||||
|
<ListItemText
|
||||||
|
primary={primaryText}
|
||||||
|
secondary={secondaryText}
|
||||||
|
slotProps={{
|
||||||
|
primary: {
|
||||||
|
noWrap: true,
|
||||||
|
variant: "body2",
|
||||||
|
sx: { mb: 0.5, fontWeight: active ? 700 : 500 },
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
noWrap: true,
|
||||||
|
variant: "caption",
|
||||||
|
sx: { opacity: 0.7 },
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ListItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default QueueListItem;
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
import { getAuthenticationApi } from "@jellyfin/sdk/lib/utils/api/authentication-api";
|
|
||||||
import {
|
|
||||||
Alert,
|
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
DialogActions,
|
|
||||||
DialogContent,
|
|
||||||
DialogTitle,
|
|
||||||
Stack,
|
|
||||||
TextField,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import React, { useEffect, useState } from "react";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import useQuickConnectApprovalStore from "@/utils/store/quickConnectApproval";
|
|
||||||
|
|
||||||
const QuickConnectApprovalDialog = () => {
|
|
||||||
const open = useQuickConnectApprovalStore((state) => state.open);
|
|
||||||
const storeCode = useQuickConnectApprovalStore((state) => state.code);
|
|
||||||
const setStoreCode = useQuickConnectApprovalStore((state) => state.setCode);
|
|
||||||
const close = useQuickConnectApprovalStore(
|
|
||||||
(state) => state.closeQuickConnectApproval,
|
|
||||||
);
|
|
||||||
const api = useApiInContext((state) => state.api);
|
|
||||||
const user = useCentralStore((state) => state.currentUser);
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
const [code, setCode] = useState(storeCode);
|
|
||||||
const [busy, setBusy] = useState(false);
|
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
const [approved, setApproved] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (open) {
|
|
||||||
setCode(storeCode);
|
|
||||||
setError(null);
|
|
||||||
setApproved(false);
|
|
||||||
}
|
|
||||||
}, [open, storeCode]);
|
|
||||||
|
|
||||||
const approve = async () => {
|
|
||||||
if (!api || !user?.Id) {
|
|
||||||
setError("Войдите, чтобы подтвердить другое устройство");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const trimmed = code.trim().toUpperCase();
|
|
||||||
if (!trimmed) {
|
|
||||||
setError("Введите код, показанный на другом устройстве");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setBusy(true);
|
|
||||||
setError(null);
|
|
||||||
try {
|
|
||||||
const result = await getAuthenticationApi(api).authorizeQuickConnect({
|
|
||||||
code: trimmed,
|
|
||||||
userId: user.Id,
|
|
||||||
});
|
|
||||||
if (result.data) {
|
|
||||||
setApproved(true);
|
|
||||||
setStoreCode("");
|
|
||||||
enqueueSnackbar("Устройство подтверждено", { variant: "success" });
|
|
||||||
setTimeout(close, 1200);
|
|
||||||
} else {
|
|
||||||
setError("Код недействителен или истёк");
|
|
||||||
}
|
|
||||||
} catch (reason) {
|
|
||||||
console.error("Quick Connect approval failed", reason);
|
|
||||||
setError("Код недействителен или истёк");
|
|
||||||
} finally {
|
|
||||||
setBusy(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog
|
|
||||||
open={open}
|
|
||||||
onClose={close}
|
|
||||||
maxWidth="xs"
|
|
||||||
fullWidth
|
|
||||||
slotProps={{
|
|
||||||
paper: { className: "glass", sx: { borderRadius: "22px" } },
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<DialogTitle>Подтвердить вход на ТВ</DialogTitle>
|
|
||||||
<DialogContent>
|
|
||||||
<Stack spacing={2}>
|
|
||||||
<Typography variant="body2" sx={{ opacity: 0.75 }}>
|
|
||||||
Введите код Quick Connect, показанный на ТВ или другом устройстве. Это
|
|
||||||
выполнит вход в аккаунт {user?.Name ?? "ваш аккаунт"} без ввода пароля
|
|
||||||
на этом устройстве.
|
|
||||||
</Typography>
|
|
||||||
<TextField
|
|
||||||
autoFocus
|
|
||||||
fullWidth
|
|
||||||
label="Код Quick Connect"
|
|
||||||
value={code}
|
|
||||||
onChange={(event) =>
|
|
||||||
setCode(event.target.value.replace(/\s/g, "").toUpperCase())
|
|
||||||
}
|
|
||||||
onKeyDown={(event) => {
|
|
||||||
if (event.key === "Enter") void approve();
|
|
||||||
}}
|
|
||||||
slotProps={{
|
|
||||||
htmlInput: {
|
|
||||||
maxLength: 8,
|
|
||||||
style: {
|
|
||||||
letterSpacing: "0.25em",
|
|
||||||
fontWeight: 700,
|
|
||||||
textTransform: "uppercase",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{error && <Alert severity="error">{error}</Alert>}
|
|
||||||
{approved && <Alert severity="success">Устройство подтверждено</Alert>}
|
|
||||||
</Stack>
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions>
|
|
||||||
<Button onClick={close}>Отмена</Button>
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
onClick={approve}
|
|
||||||
disabled={busy || approved || !code.trim()}
|
|
||||||
>
|
|
||||||
{busy ? "Подтверждение…" : "Подтвердить"}
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default React.memo(QuickConnectApprovalDialog);
|
|
||||||
@@ -1,465 +0,0 @@
|
|||||||
import {
|
|
||||||
GeneralCommandType,
|
|
||||||
MediaType,
|
|
||||||
PlayCommand,
|
|
||||||
PlaystateCommand,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
|
||||||
import { OutboundWebSocketMessageType } from "@jellyfin/sdk/lib/websocket";
|
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
|
||||||
import TauriWebSocket from "@tauri-apps/plugin-websocket";
|
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import React, { useEffect, useRef } from "react";
|
|
||||||
import {
|
|
||||||
getLocalPlayback,
|
|
||||||
pauseLocalPlayback,
|
|
||||||
resumeLocalPlayback,
|
|
||||||
seekLocalPlayback,
|
|
||||||
setLocalMuted,
|
|
||||||
setLocalVolume,
|
|
||||||
stopLocalPlayback,
|
|
||||||
} from "@/utils/methods/localPlayback";
|
|
||||||
import { startPlaybackFromIds } from "@/utils/methods/startPlayback";
|
|
||||||
import {
|
|
||||||
handleSyncPlayCommand,
|
|
||||||
handleSyncPlayGroupUpdate,
|
|
||||||
} from "@/utils/methods/syncPlay";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import { playItemFromQueue, usePlaybackStore } from "@/utils/store/playback";
|
|
||||||
import { clearQueue } from "@/utils/store/queue";
|
|
||||||
import useRealtimeStore from "@/utils/store/realtime";
|
|
||||||
|
|
||||||
const SUPPORTED_COMMANDS: GeneralCommandType[] = [
|
|
||||||
GeneralCommandType.VolumeUp,
|
|
||||||
GeneralCommandType.VolumeDown,
|
|
||||||
GeneralCommandType.Mute,
|
|
||||||
GeneralCommandType.Unmute,
|
|
||||||
GeneralCommandType.ToggleMute,
|
|
||||||
GeneralCommandType.SetVolume,
|
|
||||||
GeneralCommandType.ToggleFullscreen,
|
|
||||||
GeneralCommandType.ToggleStats,
|
|
||||||
GeneralCommandType.DisplayMessage,
|
|
||||||
GeneralCommandType.GoHome,
|
|
||||||
GeneralCommandType.GoToSearch,
|
|
||||||
GeneralCommandType.GoToSettings,
|
|
||||||
GeneralCommandType.SendString,
|
|
||||||
GeneralCommandType.SendKey,
|
|
||||||
GeneralCommandType.Back,
|
|
||||||
GeneralCommandType.SetSubtitleStreamIndex,
|
|
||||||
GeneralCommandType.SetAudioStreamIndex,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Keeps one WebSocket subscription alive for the session. Apart from live
|
|
||||||
* session lists it makes this client a controllable Jellyfin target and
|
|
||||||
* applies remote playstate/general commands locally.
|
|
||||||
*/
|
|
||||||
const RealtimeBridge = () => {
|
|
||||||
const api = useApiInContext((state) => state.api);
|
|
||||||
const user = useCentralStore((state) => state.currentUser);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
const invalidationTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!api?.accessToken) return;
|
|
||||||
const sessionApi = getSessionApi(api);
|
|
||||||
const userId = user?.Id;
|
|
||||||
|
|
||||||
const invalidate = () => {
|
|
||||||
if (invalidationTimer.current) clearTimeout(invalidationTimer.current);
|
|
||||||
invalidationTimer.current = setTimeout(() => {
|
|
||||||
for (const queryKey of [
|
|
||||||
["item"],
|
|
||||||
["home"],
|
|
||||||
["favorite"],
|
|
||||||
["library"],
|
|
||||||
["search"],
|
|
||||||
["playButton"],
|
|
||||||
]) {
|
|
||||||
queryClient.invalidateQueries({ queryKey });
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
};
|
|
||||||
|
|
||||||
const applyPlaystate = (
|
|
||||||
command?: PlaystateCommand,
|
|
||||||
seekTicks?: number | null,
|
|
||||||
) => {
|
|
||||||
if (!command) return;
|
|
||||||
if (command === PlaystateCommand.Seek) {
|
|
||||||
if (seekTicks != null) seekLocalPlayback(seekTicks);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (command === PlaystateCommand.Pause) {
|
|
||||||
pauseLocalPlayback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (command === PlaystateCommand.Unpause) {
|
|
||||||
resumeLocalPlayback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (command === PlaystateCommand.PlayPause) {
|
|
||||||
const local = getLocalPlayback();
|
|
||||||
if (local.paused) resumeLocalPlayback();
|
|
||||||
else pauseLocalPlayback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (command === PlaystateCommand.Stop) {
|
|
||||||
const local = getLocalPlayback();
|
|
||||||
const playback = usePlaybackStore.getState();
|
|
||||||
const stoppedItemId = playback.metadata.item?.Id;
|
|
||||||
const stoppedMediaSourceId = playback.mediaSource.id;
|
|
||||||
const stoppedPlaySessionId = playback.playsessionId;
|
|
||||||
stopLocalPlayback();
|
|
||||||
if (local.kind === "video") {
|
|
||||||
usePlaybackStore.setState(usePlaybackStore.getInitialState());
|
|
||||||
clearQueue();
|
|
||||||
navigate({ to: "/home" });
|
|
||||||
if (stoppedItemId) {
|
|
||||||
getSessionApi(api)
|
|
||||||
.reportPlaybackStopped({
|
|
||||||
playbackStopInfo: {
|
|
||||||
Failed: false,
|
|
||||||
ItemId: stoppedItemId,
|
|
||||||
MediaSourceId: stoppedMediaSourceId,
|
|
||||||
PlaySessionId: stoppedPlaySessionId,
|
|
||||||
PositionTicks: local.positionTicks,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.warn(
|
|
||||||
"Could not report the remotely stopped playback",
|
|
||||||
error,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
command === PlaystateCommand.NextTrack ||
|
|
||||||
command === PlaystateCommand.PreviousTrack
|
|
||||||
) {
|
|
||||||
if (!userId) return;
|
|
||||||
const local = getLocalPlayback();
|
|
||||||
playItemFromQueue(
|
|
||||||
command === PlaystateCommand.NextTrack ? "next" : "previous",
|
|
||||||
userId,
|
|
||||||
api,
|
|
||||||
).then(() => {
|
|
||||||
if (local.kind === "video") navigate({ to: "/player" });
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
command === PlaystateCommand.Rewind ||
|
|
||||||
command === PlaystateCommand.FastForward
|
|
||||||
) {
|
|
||||||
const local = getLocalPlayback();
|
|
||||||
const delta =
|
|
||||||
(command === PlaystateCommand.Rewind ? -30 : 30) * 10_000_000;
|
|
||||||
seekLocalPlayback(Math.max(0, local.positionTicks + delta));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const applyGeneralCommand = (
|
|
||||||
name?: GeneralCommandType,
|
|
||||||
args?: { [key: string]: string },
|
|
||||||
) => {
|
|
||||||
if (!name) return;
|
|
||||||
const local = getLocalPlayback();
|
|
||||||
const video = usePlaybackStore.getState();
|
|
||||||
const volume = video.playerState.volume;
|
|
||||||
|
|
||||||
switch (name) {
|
|
||||||
case GeneralCommandType.VolumeUp:
|
|
||||||
setLocalVolume(volume + 0.05);
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.VolumeDown:
|
|
||||||
setLocalVolume(volume - 0.05);
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.SetVolume: {
|
|
||||||
const target = Number(args?.Volume);
|
|
||||||
if (Number.isFinite(target)) {
|
|
||||||
setLocalVolume(target > 1 ? target / 100 : target);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GeneralCommandType.Mute:
|
|
||||||
setLocalMuted(true);
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.Unmute:
|
|
||||||
setLocalMuted(false);
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.ToggleMute:
|
|
||||||
setLocalMuted(!video.playerState.isPlayerMuted);
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.ToggleFullscreen:
|
|
||||||
if (local.kind === "video") {
|
|
||||||
try {
|
|
||||||
video.toggleIsPlayerFullscreen();
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Remote fullscreen failed", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.ToggleStats:
|
|
||||||
if (local.kind === "video") {
|
|
||||||
video.toggleShowStatsForNerds();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.DisplayMessage:
|
|
||||||
enqueueSnackbar(
|
|
||||||
[args?.Header, args?.Text].filter(Boolean).join(": ") ||
|
|
||||||
"Сообщение с сервера",
|
|
||||||
{
|
|
||||||
variant: "info",
|
|
||||||
autoHideDuration: Number(args?.TimeoutMs) || 5000,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.GoHome:
|
|
||||||
navigate({ to: "/home" });
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.GoToSearch:
|
|
||||||
case GeneralCommandType.SendString:
|
|
||||||
navigate({
|
|
||||||
to: "/search",
|
|
||||||
search: { query: args?.String ?? "" },
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case GeneralCommandType.Back:
|
|
||||||
window.history.back();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.info("Unhandled remote command", name, args);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const applyPlay = (play?: {
|
|
||||||
ItemIds?: string[] | null;
|
|
||||||
StartIndex?: number | null;
|
|
||||||
StartPositionTicks?: number | null;
|
|
||||||
AudioStreamIndex?: number | null;
|
|
||||||
SubtitleStreamIndex?: number | null;
|
|
||||||
PlayCommand?: PlayCommand;
|
|
||||||
}) => {
|
|
||||||
if (!play?.ItemIds?.length || !userId) return;
|
|
||||||
if (play.PlayCommand && play.PlayCommand !== PlayCommand.PlayNow) {
|
|
||||||
// PlayNext/PlayLast are uncommon from a remote; behave like PlayNow
|
|
||||||
// instead of silently ignoring the user's intent.
|
|
||||||
console.info("Remote play command", play.PlayCommand);
|
|
||||||
}
|
|
||||||
startPlaybackFromIds(api, userId, play.ItemIds, {
|
|
||||||
startIndex: play.StartIndex ?? 0,
|
|
||||||
startPositionTicks: play.StartPositionTicks ?? 0,
|
|
||||||
audioStreamIndex: play.AudioStreamIndex ?? undefined,
|
|
||||||
subtitleStreamIndex: play.SubtitleStreamIndex ?? undefined,
|
|
||||||
})
|
|
||||||
.then((result) => {
|
|
||||||
if (result.kind === "video") navigate({ to: "/player" });
|
|
||||||
if (result.kind === "audio") navigate({ to: "/player/audio" });
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error("Remote play failed", error);
|
|
||||||
enqueueSnackbar("Не удалось запустить удалённое воспроизведение", {
|
|
||||||
variant: "error",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const advertise = () => {
|
|
||||||
sessionApi
|
|
||||||
.postCapabilities({
|
|
||||||
playableMediaTypes: [
|
|
||||||
MediaType.Audio,
|
|
||||||
MediaType.Video,
|
|
||||||
MediaType.Photo,
|
|
||||||
],
|
|
||||||
supportedCommands: SUPPORTED_COMMANDS,
|
|
||||||
supportsMediaControl: true,
|
|
||||||
supportsPersistentIdentifier: true,
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.warn(
|
|
||||||
"Could not advertise remote-control capabilities",
|
|
||||||
error,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
advertise();
|
|
||||||
|
|
||||||
// Jellyfin 12 attaches the socket using the Authorization header sent
|
|
||||||
// by the Rust WebSocket client, so keep the token out of the URL.
|
|
||||||
const socketUrl = api.getUri("socket").replace(/^http/, "ws");
|
|
||||||
const handleMessage = (parsed: {
|
|
||||||
MessageType: OutboundWebSocketMessageType;
|
|
||||||
Data?: any;
|
|
||||||
}) => {
|
|
||||||
useRealtimeStore.getState().markMessage();
|
|
||||||
switch (parsed.MessageType) {
|
|
||||||
case OutboundWebSocketMessageType.Sessions:
|
|
||||||
useRealtimeStore.getState().setSessions(parsed.Data ?? []);
|
|
||||||
queryClient.setQueryData(["remoteSessions"], parsed.Data ?? []);
|
|
||||||
break;
|
|
||||||
case OutboundWebSocketMessageType.Playstate:
|
|
||||||
applyPlaystate(parsed.Data?.Command, parsed.Data?.SeekPositionTicks);
|
|
||||||
break;
|
|
||||||
case OutboundWebSocketMessageType.GeneralCommand:
|
|
||||||
applyGeneralCommand(parsed.Data?.Name, parsed.Data?.Arguments);
|
|
||||||
break;
|
|
||||||
case OutboundWebSocketMessageType.Play:
|
|
||||||
applyPlay(parsed.Data);
|
|
||||||
break;
|
|
||||||
case OutboundWebSocketMessageType.UserDataChanged:
|
|
||||||
case OutboundWebSocketMessageType.LibraryChanged:
|
|
||||||
invalidate();
|
|
||||||
break;
|
|
||||||
case OutboundWebSocketMessageType.SyncPlayGroupUpdate:
|
|
||||||
if (parsed.Data) {
|
|
||||||
void handleSyncPlayGroupUpdate(api, userId, parsed.Data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OutboundWebSocketMessageType.SyncPlayCommand:
|
|
||||||
if (parsed.Data) handleSyncPlayCommand(parsed.Data);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Jellyfin 12 only attaches a socket to the session when the handshake
|
|
||||||
// carries the Authorization header, which a browser WebSocket cannot set.
|
|
||||||
// The Tauri plugin opens the socket from Rust, so pass the real header.
|
|
||||||
let disposed = false;
|
|
||||||
let socket: TauriWebSocket | null = null;
|
|
||||||
let connecting = false;
|
|
||||||
let lastMessageAt = Date.now();
|
|
||||||
let keepAliveTimer: ReturnType<typeof setInterval> | null = null;
|
|
||||||
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
|
||||||
let reconnectAttempts = 0;
|
|
||||||
|
|
||||||
const clearKeepAlive = () => {
|
|
||||||
if (keepAliveTimer) {
|
|
||||||
clearInterval(keepAliveTimer);
|
|
||||||
keepAliveTimer = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const scheduleReconnect = () => {
|
|
||||||
if (disposed || reconnectTimer) return;
|
|
||||||
useRealtimeStore.getState().setConnected(false);
|
|
||||||
const delay = Math.min(30_000, 1000 * 1.5 ** reconnectAttempts);
|
|
||||||
reconnectAttempts += 1;
|
|
||||||
reconnectTimer = setTimeout(() => {
|
|
||||||
reconnectTimer = null;
|
|
||||||
void connect();
|
|
||||||
}, delay);
|
|
||||||
};
|
|
||||||
|
|
||||||
const connect = async (): Promise<void> => {
|
|
||||||
if (disposed || connecting || socket) return;
|
|
||||||
connecting = true;
|
|
||||||
try {
|
|
||||||
const nextSocket = await TauriWebSocket.connect(socketUrl, {
|
|
||||||
headers: { Authorization: api.authorizationHeader },
|
|
||||||
});
|
|
||||||
if (disposed) {
|
|
||||||
await nextSocket.disconnect().catch(() => undefined);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
socket = nextSocket;
|
|
||||||
lastMessageAt = Date.now();
|
|
||||||
reconnectAttempts = 0;
|
|
||||||
useRealtimeStore.getState().setConnected(true);
|
|
||||||
advertise();
|
|
||||||
|
|
||||||
nextSocket.addListener((message) => {
|
|
||||||
if (message.type === "Close") {
|
|
||||||
clearKeepAlive();
|
|
||||||
socket = null;
|
|
||||||
scheduleReconnect();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (message.type !== "Text") return;
|
|
||||||
lastMessageAt = Date.now();
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(message.data) as {
|
|
||||||
MessageType: OutboundWebSocketMessageType;
|
|
||||||
Data?: unknown;
|
|
||||||
};
|
|
||||||
if (
|
|
||||||
parsed.MessageType === OutboundWebSocketMessageType.ForceKeepAlive
|
|
||||||
) {
|
|
||||||
clearKeepAlive();
|
|
||||||
const seconds = Number(parsed.Data) || 60;
|
|
||||||
const sendKeepAlive = () => {
|
|
||||||
socket
|
|
||||||
?.send(JSON.stringify({ MessageType: "KeepAlive" }))
|
|
||||||
.catch(() => undefined);
|
|
||||||
};
|
|
||||||
sendKeepAlive();
|
|
||||||
keepAliveTimer = setInterval(
|
|
||||||
sendKeepAlive,
|
|
||||||
Math.max(1000, (seconds * 1000) / 2),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handleMessage(parsed);
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Could not parse a WebSocket message", error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await nextSocket.send(
|
|
||||||
JSON.stringify({
|
|
||||||
MessageType: "SessionsStart",
|
|
||||||
Data: "0,1000",
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("WebSocket connection failed", error);
|
|
||||||
scheduleReconnect();
|
|
||||||
} finally {
|
|
||||||
connecting = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const reconnectIfStale = () => {
|
|
||||||
if (disposed) return;
|
|
||||||
if (socket && Date.now() - lastMessageAt < 30_000) return;
|
|
||||||
socket?.disconnect().catch(() => undefined);
|
|
||||||
socket = null;
|
|
||||||
scheduleReconnect();
|
|
||||||
};
|
|
||||||
|
|
||||||
const watchdog = window.setInterval(reconnectIfStale, 15_000);
|
|
||||||
window.addEventListener("online", reconnectIfStale);
|
|
||||||
window.addEventListener("focus", reconnectIfStale);
|
|
||||||
|
|
||||||
void connect();
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
disposed = true;
|
|
||||||
clearKeepAlive();
|
|
||||||
window.clearInterval(watchdog);
|
|
||||||
window.removeEventListener("online", reconnectIfStale);
|
|
||||||
window.removeEventListener("focus", reconnectIfStale);
|
|
||||||
if (reconnectTimer) clearTimeout(reconnectTimer);
|
|
||||||
socket?.disconnect().catch(() => undefined);
|
|
||||||
socket = null;
|
|
||||||
useRealtimeStore.getState().setConnected(false);
|
|
||||||
if (invalidationTimer.current) {
|
|
||||||
clearTimeout(invalidationTimer.current);
|
|
||||||
invalidationTimer.current = null;
|
|
||||||
}
|
|
||||||
useRealtimeStore.getState().reset();
|
|
||||||
};
|
|
||||||
}, [api, user?.Id, navigate, queryClient, enqueueSnackbar]);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default React.memo(RealtimeBridge);
|
|
||||||
@@ -1,428 +0,0 @@
|
|||||||
import {
|
|
||||||
PlaystateCommand,
|
|
||||||
type SessionInfoDto,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Chip,
|
|
||||||
CircularProgress,
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogTitle,
|
|
||||||
Divider,
|
|
||||||
IconButton,
|
|
||||||
LinearProgress,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
Tooltip,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import React from "react";
|
|
||||||
import {
|
|
||||||
playOnSession,
|
|
||||||
queueStartingWith,
|
|
||||||
} from "@/utils/methods/transferPlayback";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { stopPlayback } from "@/utils/store/audioPlayback";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
|
||||||
import { clearQueue } from "@/utils/store/queue";
|
|
||||||
import useRemoteControlStore from "@/utils/store/remoteControl";
|
|
||||||
|
|
||||||
const TICKS_PER_SECOND = 10_000_000;
|
|
||||||
|
|
||||||
const formatTime = (ticks: number | null | undefined) => {
|
|
||||||
const total = Math.max(0, Math.round((ticks ?? 0) / TICKS_PER_SECOND));
|
|
||||||
const h = Math.floor(total / 3600);
|
|
||||||
const m = Math.floor((total % 3600) / 60);
|
|
||||||
const s = total % 60;
|
|
||||||
return h > 0
|
|
||||||
? `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`
|
|
||||||
: `${m}:${String(s).padStart(2, "0")}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const sessionLabel = (session: SessionInfoDto) =>
|
|
||||||
session.DeviceName || session.Client || session.DeviceId || "Неизвестное устройство";
|
|
||||||
|
|
||||||
const RemoteControlDialog = () => {
|
|
||||||
const { open, transfer, closeDialog } = useRemoteControlStore();
|
|
||||||
const item = transfer?.item;
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const sessions = useQuery({
|
|
||||||
queryKey: ["remoteSessions"],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!api || !user?.Id) return [];
|
|
||||||
const result = await getSessionApi(api).getSessions();
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
enabled: open && !!api && !!user?.Id,
|
|
||||||
refetchInterval: open ? 3000 : false,
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const sendCommand = useMutation({
|
|
||||||
mutationFn: async ({
|
|
||||||
session,
|
|
||||||
command,
|
|
||||||
seekPositionTicks,
|
|
||||||
}: {
|
|
||||||
session: SessionInfoDto;
|
|
||||||
command: PlaystateCommand;
|
|
||||||
seekPositionTicks?: number;
|
|
||||||
}) => {
|
|
||||||
if (!api || !session.Id) return;
|
|
||||||
await getSessionApi(api).sendPlaystateCommand({
|
|
||||||
sessionId: session.Id,
|
|
||||||
command,
|
|
||||||
seekPositionTicks,
|
|
||||||
controllingUserId: user?.Id,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: () =>
|
|
||||||
enqueueSnackbar("Команда не выполнена", { variant: "error" }),
|
|
||||||
onSettled: () => sessions.refetch(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const playOn = useMutation({
|
|
||||||
mutationFn: async (session: SessionInfoDto) => {
|
|
||||||
if (!api || !session.Id || !item?.Id || !user?.Id) return;
|
|
||||||
const queueIds = queueStartingWith(transfer?.queue ?? [], item.Id);
|
|
||||||
await playOnSession(api, user.Id, session.Id, {
|
|
||||||
itemIds: queueIds.length > 0 ? queueIds : [item.Id],
|
|
||||||
startIndex: 0,
|
|
||||||
startPositionTicks: transfer?.positionTicks ?? 0,
|
|
||||||
mediaSourceId: item.MediaSources?.[0]?.Id ?? undefined,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onSuccess: async (_data, session) => {
|
|
||||||
enqueueSnackbar(
|
|
||||||
transfer?.kind === "audio" || transfer?.kind === "video"
|
|
||||||
? `Воспроизведение перенесено на ${sessionLabel(session)}`
|
|
||||||
: `Воспроизведение на ${sessionLabel(session)}`,
|
|
||||||
{ variant: "success" },
|
|
||||||
);
|
|
||||||
if (transfer?.kind === "audio") {
|
|
||||||
stopPlayback();
|
|
||||||
} else if (transfer?.kind === "video") {
|
|
||||||
const playback = usePlaybackStore.getState();
|
|
||||||
const transferredItemId = playback.metadata.item?.Id;
|
|
||||||
const stoppedPosition = playback.playerState.currentTime;
|
|
||||||
// Stop local playback first so a trailing timeupdate cannot
|
|
||||||
// re-mark the old session as playing after we report it stopped.
|
|
||||||
(
|
|
||||||
document
|
|
||||||
.querySelector("hls-video")
|
|
||||||
?.shadowRoot?.querySelector("video") as HTMLVideoElement | null
|
|
||||||
)?.pause();
|
|
||||||
usePlaybackStore.setState(usePlaybackStore.getInitialState());
|
|
||||||
clearQueue();
|
|
||||||
navigate({ to: "/home" });
|
|
||||||
if (api && transferredItemId) {
|
|
||||||
try {
|
|
||||||
await getSessionApi(api).reportPlaybackStopped({
|
|
||||||
playbackStopInfo: {
|
|
||||||
Failed: false,
|
|
||||||
ItemId: transferredItemId,
|
|
||||||
MediaSourceId: playback.mediaSource.id,
|
|
||||||
PlaySessionId: playback.playsessionId,
|
|
||||||
PositionTicks: stoppedPosition,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Could not report the transferred video as stopped", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closeDialog();
|
|
||||||
},
|
|
||||||
onError: () =>
|
|
||||||
enqueueSnackbar("Не удалось запустить воспроизведение на устройстве", {
|
|
||||||
variant: "error",
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Show all other sessions: some clients report SupportsRemoteControl=false
|
|
||||||
// even though they accept playstate commands, so do not hide them.
|
|
||||||
const remoteSessions = (sessions.data ?? []).filter(
|
|
||||||
(session) =>
|
|
||||||
session.Id &&
|
|
||||||
session.DeviceId !== api?.deviceInfo.id &&
|
|
||||||
session.UserId === user?.Id,
|
|
||||||
);
|
|
||||||
|
|
||||||
const seek = (session: SessionInfoDto, offsetSeconds: number) => {
|
|
||||||
const current = (session.PlayState?.PositionTicks ?? 0) / TICKS_PER_SECOND;
|
|
||||||
const next = Math.max(0, current + offsetSeconds);
|
|
||||||
sendCommand.mutate({
|
|
||||||
session,
|
|
||||||
command: PlaystateCommand.Seek,
|
|
||||||
seekPositionTicks: Math.round(next * TICKS_PER_SECOND),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog
|
|
||||||
open={open}
|
|
||||||
onClose={closeDialog}
|
|
||||||
fullWidth
|
|
||||||
maxWidth="sm"
|
|
||||||
slotProps={{
|
|
||||||
paper: {
|
|
||||||
className: "glass-dialog-paper",
|
|
||||||
sx: { borderRadius: 3 },
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<DialogTitle sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
|
||||||
<span className="material-symbols-rounded">cast</span>
|
|
||||||
<span style={{ flex: 1 }}>
|
|
||||||
{item ? `Воспроизвести «${item.Name}» на…` : "Удалённое управление"}
|
|
||||||
</span>
|
|
||||||
<IconButton onClick={closeDialog} aria-label="Закрыть">
|
|
||||||
<span className="material-symbols-rounded">close</span>
|
|
||||||
</IconButton>
|
|
||||||
</DialogTitle>
|
|
||||||
<DialogContent sx={{ pb: 2 }}>
|
|
||||||
{item && (
|
|
||||||
<Typography variant="body2" sx={{ opacity: 0.7, mb: 1 }}>
|
|
||||||
Выберите устройство для запуска воспроизведения.
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
{sessions.isPending ? (
|
|
||||||
<div style={{ display: "flex", justifyContent: "center", padding: 24 }}>
|
|
||||||
<CircularProgress size={28} />
|
|
||||||
</div>
|
|
||||||
) : remoteSessions.length === 0 ? (
|
|
||||||
<Typography sx={{ opacity: 0.7, py: 2 }}>
|
|
||||||
Нет доступных устройств. Откройте клиент Jellyfin (например, на ТВ)
|
|
||||||
и разрешите удалённое управление.
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
<List disablePadding>
|
|
||||||
{remoteSessions.map((session) => {
|
|
||||||
const nowPlaying = session.NowPlayingItem;
|
|
||||||
const playState = session.PlayState;
|
|
||||||
const duration = nowPlaying?.RunTimeTicks ?? 0;
|
|
||||||
const position = playState?.PositionTicks ?? 0;
|
|
||||||
const supportsControl = true;
|
|
||||||
return (
|
|
||||||
<React.Fragment key={session.Id}>
|
|
||||||
<ListItem
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
alignItems: "stretch",
|
|
||||||
gap: 1,
|
|
||||||
px: 0,
|
|
||||||
py: 1.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 8,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">tv</span>
|
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
|
||||||
<Typography variant="subtitle1" noWrap>
|
|
||||||
{sessionLabel(session)}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="caption"
|
|
||||||
sx={{ opacity: 0.6, display: "block" }}
|
|
||||||
noWrap
|
|
||||||
>
|
|
||||||
{[session.Client, session.UserName]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(" · ")}
|
|
||||||
</Typography>
|
|
||||||
{session.SupportsRemoteControl === false && (
|
|
||||||
<Typography
|
|
||||||
variant="caption"
|
|
||||||
color="warning.main"
|
|
||||||
sx={{ display: "block" }}
|
|
||||||
>
|
|
||||||
Нет канала управления (WebSocket) — проверьте
|
|
||||||
обратный прокси.
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{item && (
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
variant="contained"
|
|
||||||
disabled={playOn.isPending || !item.Id}
|
|
||||||
onClick={() => playOn.mutate(session)}
|
|
||||||
>
|
|
||||||
Смотреть здесь
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{nowPlaying ? (
|
|
||||||
<>
|
|
||||||
<Typography variant="body2" noWrap>
|
|
||||||
{nowPlaying.Name}
|
|
||||||
{nowPlaying.Genres?.length ? (
|
|
||||||
<Chip
|
|
||||||
component="span"
|
|
||||||
size="small"
|
|
||||||
label={nowPlaying.Genres[0]}
|
|
||||||
sx={{ ml: 1 }}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
</Typography>
|
|
||||||
<LinearProgress
|
|
||||||
variant="determinate"
|
|
||||||
value={
|
|
||||||
duration > 0
|
|
||||||
? Math.min(100, (position / duration) * 100)
|
|
||||||
: 0
|
|
||||||
}
|
|
||||||
sx={{ borderRadius: 1 }}
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography variant="caption" sx={{ opacity: 0.6 }}>
|
|
||||||
{formatTime(position)} / {formatTime(duration)}
|
|
||||||
{playState?.IsPaused ? " · пауза" : ""}
|
|
||||||
</Typography>
|
|
||||||
<div style={{ display: "flex" }}>
|
|
||||||
<Tooltip title="Назад на 10 с">
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
disabled={!supportsControl || playState?.CanSeek === false}
|
|
||||||
onClick={() => seek(session, -10)}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
replay_10
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Предыдущий">
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
disabled={!supportsControl}
|
|
||||||
onClick={() =>
|
|
||||||
sendCommand.mutate({
|
|
||||||
session,
|
|
||||||
command: PlaystateCommand.PreviousTrack,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
skip_previous
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip
|
|
||||||
title={playState?.IsPaused ? "Смотреть" : "Пауза"}
|
|
||||||
>
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
disabled={!supportsControl}
|
|
||||||
onClick={() =>
|
|
||||||
sendCommand.mutate({
|
|
||||||
session,
|
|
||||||
command: PlaystateCommand.PlayPause,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
{playState?.IsPaused
|
|
||||||
? "play_arrow"
|
|
||||||
: "pause"}
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Следующий">
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
disabled={!supportsControl}
|
|
||||||
onClick={() =>
|
|
||||||
sendCommand.mutate({
|
|
||||||
session,
|
|
||||||
command: PlaystateCommand.NextTrack,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
skip_next
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Вперёд на 10 с">
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
disabled={!supportsControl || playState?.CanSeek === false}
|
|
||||||
onClick={() => seek(session, 10)}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
forward_10
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Остановить">
|
|
||||||
<span>
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
disabled={!supportsControl}
|
|
||||||
onClick={() =>
|
|
||||||
sendCommand.mutate({
|
|
||||||
session,
|
|
||||||
command: PlaystateCommand.Stop,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
stop
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Typography variant="caption" sx={{ opacity: 0.6 }}>
|
|
||||||
Свободно
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</ListItem>
|
|
||||||
<Divider />
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</List>
|
|
||||||
)}
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default RemoteControlDialog;
|
|
||||||
@@ -1,24 +1,10 @@
|
|||||||
import { CircularProgress } from "@mui/material";
|
import { CircularProgress } from "@mui/material";
|
||||||
import { useRouterState } from "@tanstack/react-router";
|
import { useRouterState } from "@tanstack/react-router";
|
||||||
import React, { useEffect, useState } from "react";
|
import React from "react";
|
||||||
|
|
||||||
/** Only show the full-screen loader for genuinely slow navigations. */
|
|
||||||
const SHOW_DELAY_MS = 250;
|
|
||||||
|
|
||||||
export default function RouterLoading() {
|
export default function RouterLoading() {
|
||||||
const routeLoading = useRouterState().isLoading;
|
const routeLoading = useRouterState().isLoading;
|
||||||
const [visible, setVisible] = useState(false);
|
if (!routeLoading) return null;
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!routeLoading) {
|
|
||||||
setVisible(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const timer = setTimeout(() => setVisible(true), SHOW_DELAY_MS);
|
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}, [routeLoading]);
|
|
||||||
|
|
||||||
if (!visible) return null;
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import type { TransitionProps } from "@mui/material/transitions";
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { register } from "@tauri-apps/plugin-global-shortcut";
|
import { register } from "@tauri-apps/plugin-global-shortcut";
|
||||||
|
|
||||||
import React, {
|
import React, {
|
||||||
type ChangeEvent,
|
type ChangeEvent,
|
||||||
useCallback,
|
useCallback,
|
||||||
@@ -43,10 +42,6 @@ const Transition = React.forwardRef(function Transition(
|
|||||||
return <Grow ref={ref} {...props} />;
|
return <Grow ref={ref} {...props} />;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register the global shortcut once. StrictMode mounts this component twice
|
|
||||||
// in development, and a second register() fails with an unhandled rejection.
|
|
||||||
let searchShortcutRegistered = false;
|
|
||||||
|
|
||||||
const Search = () => {
|
const Search = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { isOpen, handleClose, toggleSearchDialog } = useSearchStore(
|
const { isOpen, handleClose, toggleSearchDialog } = useSearchStore(
|
||||||
@@ -59,7 +54,7 @@ const Search = () => {
|
|||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const userId = useCentralStore((s) => s.currentUser?.Id || "");
|
const userId = useCentralStore((s) => s.currentUser?.Id || "");
|
||||||
const suggestions = useQuery({
|
const suggestions = useQuery({
|
||||||
queryKey: ["search", "suggestions", userId],
|
queryKey: ["search", "suggestions"],
|
||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
api &&
|
api &&
|
||||||
(
|
(
|
||||||
@@ -72,9 +67,6 @@ const Search = () => {
|
|||||||
recursive: true,
|
recursive: true,
|
||||||
})
|
})
|
||||||
).data,
|
).data,
|
||||||
// Do not fetch random suggestions during app startup.
|
|
||||||
enabled: isOpen && Boolean(api && userId),
|
|
||||||
staleTime: 5 * 60 * 1000,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
@@ -143,15 +135,14 @@ const Search = () => {
|
|||||||
}, [navigate, toggleSearchDialog, debouncedSearchTerm]);
|
}, [navigate, toggleSearchDialog, debouncedSearchTerm]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (searchShortcutRegistered) return;
|
async function registerglobalShortcut() {
|
||||||
searchShortcutRegistered = true;
|
await register("CommandOrControl+K", (e) => {
|
||||||
register("CommandOrControl+K", (e) => {
|
|
||||||
if (e.state === "Pressed") {
|
if (e.state === "Pressed") {
|
||||||
useSearchStore.getState().toggleSearchDialog();
|
toggleSearchDialog();
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
|
||||||
console.warn("Global search shortcut is unavailable", error);
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
registerglobalShortcut();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -193,7 +184,7 @@ const Search = () => {
|
|||||||
</span>
|
</span>
|
||||||
<InputBase
|
<InputBase
|
||||||
inputRef={inputRef}
|
inputRef={inputRef}
|
||||||
placeholder="Поиск фильмов, сериалов и другого..."
|
placeholder="Search movies, shows, and more..."
|
||||||
onChange={handleSearchChange}
|
onChange={handleSearchChange}
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -291,13 +282,13 @@ const Search = () => {
|
|||||||
display: "block",
|
display: "block",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Результаты
|
Results
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack spacing={0.5} sx={{ px: 1 }}>
|
<Stack spacing={0.5} sx={{ px: 1 }}>
|
||||||
{searchResults.data.SearchHints.map((item) => (
|
{searchResults.data.SearchHints.map((item) => (
|
||||||
<SearchItem
|
<SearchItem
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
itemName={item.Name || "Без названия"}
|
itemName={item.Name || "Untitled"}
|
||||||
imageUrl={
|
imageUrl={
|
||||||
api &&
|
api &&
|
||||||
item.PrimaryImageTag &&
|
item.PrimaryImageTag &&
|
||||||
@@ -334,13 +325,13 @@ const Search = () => {
|
|||||||
display: "block",
|
display: "block",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Подсказки
|
Suggestions
|
||||||
</Typography>
|
</Typography>
|
||||||
<Stack spacing={0.5} sx={{ px: 1 }}>
|
<Stack spacing={0.5} sx={{ px: 1 }}>
|
||||||
{suggestions.data?.Items?.map((item) => (
|
{suggestions.data?.Items?.map((item) => (
|
||||||
<SearchItem
|
<SearchItem
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
itemName={item.Name || "Без названия"}
|
itemName={item.Name || "Untitled"}
|
||||||
imageUrl={
|
imageUrl={
|
||||||
api &&
|
api &&
|
||||||
item.ImageTags?.Primary &&
|
item.ImageTags?.Primary &&
|
||||||
@@ -381,7 +372,7 @@ const Search = () => {
|
|||||||
search_off
|
search_off
|
||||||
</span>
|
</span>
|
||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
Ничего не найдено по запросу «{debouncedSearchTerm}»
|
No results found for "{debouncedSearchTerm}"
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
@@ -420,7 +411,7 @@ const Search = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Расширенный поиск
|
Advanced Search
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
Loaded 100 of 187 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user