Compare commits
125
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7f2c1c8a7 | ||
|
|
b8f544b483 | ||
|
|
690cfb398c | ||
|
|
45dbfbb7ec | ||
|
|
e5171b7bb8 | ||
|
|
9211faabf0 | ||
|
|
422b1d6aa4 | ||
|
|
7f7866b28d | ||
|
|
1defb53945 | ||
|
|
73e3b865ab | ||
|
|
691df70aff | ||
|
|
6f2d5a5627 | ||
|
|
7804ab2b86 | ||
|
|
4ade92bccc | ||
|
|
ab1aa23725 | ||
|
|
0131a23dc2 | ||
|
|
72ca2fb4f3 | ||
|
|
b39a15449d | ||
|
|
cb83b05c7a | ||
|
|
32f5b3b3cf | ||
|
|
94e6a03e87 | ||
|
|
690070207b | ||
|
|
79c70e6d46 | ||
|
|
cf1f3c772d | ||
|
|
b870a119e5 | ||
|
|
0883cb0fe1 | ||
|
|
8519c12c45 | ||
|
|
d6c1b0992e | ||
|
|
9c3cc53278 | ||
|
|
abc7d68016 | ||
|
|
ad8d8545e9 | ||
|
|
1c8c048df0 | ||
|
|
c0402fe8cf | ||
|
|
ce6e4b681b | ||
|
|
6bf7f434b5 | ||
|
|
4834a31cb5 | ||
|
|
b49f187098 | ||
|
|
e41b5b3085 | ||
|
|
c19198e706 | ||
|
|
78c4b7a206 | ||
|
|
5579d5e5e8 | ||
|
|
e50ae60216 | ||
|
|
4bc6044ca2 | ||
|
|
7d55810f08 | ||
|
|
40651fd3d6 | ||
|
|
fdf43aba18 | ||
|
|
03bd7c027b | ||
|
|
995d75dbec | ||
|
|
4952d8842b | ||
|
|
f527d97912 | ||
|
|
ef8dfbc23a | ||
|
|
6576bfe5f3 | ||
|
|
3000146e66 | ||
|
|
81e0c3b9a8 | ||
|
|
27d8e04b0f | ||
|
|
50de0b7b51 | ||
|
|
64c5b7570b | ||
|
|
d46e143262 | ||
|
|
6542ed9487 | ||
|
|
d39c064600 | ||
|
|
d254d3033d | ||
|
|
3abf27724f | ||
|
|
120e283e3d | ||
|
|
706fb7b890 | ||
|
|
11b4a878ac | ||
|
|
6695bdc6ee | ||
|
|
17922127dd | ||
|
|
a135d1be5f | ||
|
|
88c42d8110 | ||
|
|
8e667a2253 | ||
|
|
e08eaea1d1 | ||
|
|
937e9385f2 | ||
|
|
bb2c0272a2 | ||
|
|
6b4d6ed0d3 | ||
|
|
374cba8f63 | ||
|
|
07522b50c5 | ||
|
|
257ff8e552 | ||
|
|
37e898e4cf | ||
|
|
65e5370dbf | ||
|
|
2d4b0d66b4 | ||
|
|
54d0b07666 | ||
|
|
9ac556d001 | ||
|
|
333fe09f45 | ||
|
|
a8ee9c190c | ||
|
|
0cf87da218 | ||
|
|
f919162dfc | ||
|
|
c9d16f4669 | ||
|
|
53311a1728 | ||
|
|
c4073f1368 | ||
|
|
c69a547379 | ||
|
|
7b0b22b611 | ||
|
|
47a486a3ad | ||
|
|
0f5482627a | ||
|
|
4ca90e713d | ||
|
|
093e40a929 | ||
|
|
797d0600c3 | ||
|
|
18d55a4af6 | ||
|
|
d7f3317913 | ||
|
|
52b73f7475 | ||
|
|
0c8b282469 | ||
|
|
25479b2278 | ||
|
|
dfb8eeee12 | ||
|
|
790f3f163b | ||
|
|
db74b4f58b | ||
|
|
18ebe4ef1e | ||
|
|
f0c8458dc4 | ||
|
|
80080e841a | ||
|
|
d60cb2b5fb | ||
|
|
7086892843 | ||
|
|
951cf61a89 | ||
|
|
ceee9311aa | ||
|
|
21a6e492f4 | ||
|
|
b916560c6a | ||
|
|
d3d5c5ac54 | ||
|
|
3f5e764cd7 | ||
|
|
4381b6e28e | ||
|
|
83c96cf65c | ||
|
|
4ff422ae61 | ||
|
|
c0d7d4e03d | ||
|
|
cd768a088b | ||
|
|
2f12fe0862 | ||
|
|
f6c0963f48 | ||
|
|
4ae8a087ed | ||
|
|
412e54fd82 | ||
|
|
51848a39ae |
No files matched your search
@@ -0,0 +1,15 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [prayag17] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
polar: # Replace with a single Polar username
|
||||
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||
thanks_dev: # Replace with a single thanks.dev username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
@@ -0,0 +1,11 @@
|
||||
changelog:
|
||||
categories:
|
||||
- title: 🏕 Features
|
||||
labels:
|
||||
- '*'
|
||||
exclude:
|
||||
labels:
|
||||
- dependencies
|
||||
- title: 👒 Dependencies
|
||||
labels:
|
||||
- dependencies
|
||||
@@ -13,12 +13,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- uses: pnpm/action-setup@v3
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
version: 7
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v4
|
||||
- uses: actions/cache@v5
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Sync node version and setup cache
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
cache: "pnpm"
|
||||
@@ -56,12 +56,12 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [macos-latest, ubuntu-22.04, windows-latest]
|
||||
platform: [macos-latest, ubuntu-22.04, windows-latest, windows-11-arm]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
environment: TAURI
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install dependencies (ubuntu only)
|
||||
if: matrix.platform == 'ubuntu-22.04'
|
||||
@@ -78,10 +78,10 @@ jobs:
|
||||
with:
|
||||
workspaces: "./src-tauri -> target"
|
||||
|
||||
- uses: pnpm/action-setup@v3
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
version: 7
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
@@ -89,7 +89,7 @@ jobs:
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v4
|
||||
- uses: actions/cache@v5
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
@@ -98,7 +98,7 @@ jobs:
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Sync node version and setup cache
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
cache: "pnpm"
|
||||
@@ -115,8 +115,59 @@ jobs:
|
||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||
|
||||
# TODO: Remove the below command after upstream issue is fixed
|
||||
# Related issue: https://github.com/tauri-apps/tauri/issues/10702
|
||||
WEBKIT_DISABLE_DMABUF_RENDERER: 1 # Disable DMABUF renderer on Wayland
|
||||
|
||||
- name: Upload build Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: Blink-${{ matrix.platform }}-dev${{ github.sha }}
|
||||
path: src-tauri/target/debug/bundle/*
|
||||
|
||||
# Create or update nightly release
|
||||
nightly_release:
|
||||
needs: build
|
||||
if: github.repository == 'prayag17/Blink' && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write # Required for creating/updating releases
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6.1.0
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v7.0.0
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Prepare assets
|
||||
run: |
|
||||
mkdir -p release_assets
|
||||
find artifacts -type f \( -name "*.exe" -o -name "*.msi" -o -name "*.dmg" -o -name "*.deb" -o -name "*.AppImage" -o -name "*.rpm" -o -name "*.tar.gz" \) | while read -r file; do
|
||||
# Extract platform from artifact name (e.g. Blink-ubuntu-22.04-devSHA)
|
||||
artifact_name=$(echo "$file" | cut -d'/' -f2)
|
||||
platform=$(echo "$artifact_name" | sed -E 's/Blink-(.*)-dev.*/\1/' | sed 's/-/_/g')
|
||||
filename=$(basename "$file")
|
||||
cp "$file" "release_assets/${platform}-${filename}"
|
||||
done
|
||||
|
||||
- name: Delete old nightly release
|
||||
run: gh release delete nightly --yes --repo ${{ github.repository }} || true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create nightly release
|
||||
uses: softprops/action-gh-release@v2.5.0
|
||||
with:
|
||||
tag_name: nightly
|
||||
name: Nightly Build (${{ github.sha }})
|
||||
body: |
|
||||
Nightly build from the latest main branch.
|
||||
|
||||
**Last commit:** ${{ github.event.head_commit.message }}
|
||||
**SHA:** ${{ github.sha }}
|
||||
prerelease: true
|
||||
files: release_assets/*
|
||||
fail_on_unmatched_files: true
|
||||
|
||||
@@ -12,12 +12,12 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [macos-latest, ubuntu-22.04, windows-latest]
|
||||
platform: [macos-latest, ubuntu-22.04, windows-latest, windows-11-arm]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
environment: TAURI
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install dependencies (ubuntu only)
|
||||
if: matrix.platform == 'ubuntu-22.04'
|
||||
@@ -37,10 +37,10 @@ jobs:
|
||||
with:
|
||||
workspaces: "./src-tauri -> target"
|
||||
|
||||
- uses: pnpm/action-setup@v3
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
version: 7
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v4
|
||||
- uses: actions/cache@v5
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Sync node version and setup cache
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
cache: "pnpm" # Set this to npm, yarn or pnpm.
|
||||
@@ -67,7 +67,7 @@ jobs:
|
||||
run: pnpm install --no-frozen-lockfile && pnpm run build # Change this to npm, yarn or pnpm.
|
||||
|
||||
- name: Build the app
|
||||
uses: tauri-apps/tauri-action@dev
|
||||
uses: tauri-apps/tauri-action@v0
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
name: Publish Releases to WinGet
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
jobs:
|
||||
publish-alpha:
|
||||
runs-on: ubuntu-latest
|
||||
if: contains(github.event.release.tag_name, '-alpha')
|
||||
steps:
|
||||
- uses: vedantmgoyal9/winget-releaser@main
|
||||
with:
|
||||
identifier: prayag17.Blink.Alpha
|
||||
version: ${{ github.event.release.tag_name }}
|
||||
installers-regex: '\.exe$'
|
||||
token: ${{ secrets.WINGET_TOKEN }}
|
||||
|
||||
publish-stable:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.release.tag_name, '-alpha')"
|
||||
steps:
|
||||
- uses: vedantmgoyal9/winget-releaser@main
|
||||
with:
|
||||
identifier: prayag17.Blink
|
||||
version: ${{ github.event.release.tag_name }}
|
||||
installers-regex: '\.exe$'
|
||||
token: ${{ secrets.WINGET_TOKEN }}
|
||||
+3
-1
@@ -39,4 +39,6 @@ target/
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
generateBanner
|
||||
generateBanner
|
||||
# Million Lint
|
||||
.million
|
||||
@@ -1 +0,0 @@
|
||||
{"encodings":["src\\main.tsx","ProviderWrapper",[52,0,71,1],[53,39,57,3],[53,8,53,11],[53,13,53,22],[53,24,53,35],[58,34,61,3],[58,8,58,12],[58,14,58,30],[66,2,69,4],"src\\components\\notices\\errorNotice\\errorNotice.tsx","ErrorNotice",[6,27,54,1],[6,28,6,56],[9,2,52,8],[20,3,31,9],[32,3,34,16],[35,3,51,16],"src\\utils\\store\\api.tsx","ApiProvider",[50,27,67,1],[50,28,50,65],[51,17,65,2],[66,8,66,75],"useApiInContext",[69,7,75,1],[70,15,70,37],[74,8,74,57],"src\\utils\\store\\central.tsx","CentralProvider",[48,31,71,1],[48,32,48,69],[49,17,67,2],[69,2,69,77],"useCentralStore",[73,7,79,1],[74,15,74,41],[78,8,78,57],"src\\routes\\_api\\player\\index.tsx","VideoPlayer",[88,0,918,1],[89,13,89,42],[90,21,90,32],[90,9,90,16],[91,39,91,54],[92,16,92,48],[94,14,94,51],[106,5,116,3],[97,2,97,16],[98,2,98,6],[99,2,99,10],[100,2,100,14],[101,2,101,15],[102,2,102,14],[103,2,103,13],[104,2,104,15],[105,2,105,11],[117,40,120,3],[117,8,117,29],[117,31,117,36],[122,31,122,45],[123,41,125,2],[127,51,127,66],[130,31,130,46],[131,31,131,45],[132,35,132,50],[133,45,133,68],[134,33,134,56],[135,43,135,58],[137,29,137,40],[138,27,138,42],[140,1,140,41],[142,41,142,72],[219,24,257,7],[259,1,267,21],[267,5,267,19],[269,1,287,7],[289,1,292,15],[292,5,292,13],[294,41,311,62],[311,5,311,31],[311,33,311,60],[313,1,334,3],[331,2,331,28],[332,2,332,29],[333,2,333,37],[336,29,344,15],[344,5,344,13],[346,24,364,25],[364,5,364,13],[364,15,364,23],[366,25,370,15],[370,5,370,13],[372,49,372,64],[373,27,375,7],[376,1,376,56],[376,46,376,54],[378,22,384,21],[384,5,384,19],[464,5,481,11],[465,6,474,8],[475,6,477,19],[478,6,480,19],[485,4,499,10],[486,5,495,7],[496,5,498,18],[504,4,511,10],[505,5,507,18],[508,5,510,18],[515,3,519,9],[516,4,518,17],[523,51,523,66],[524,1,530,13],[530,5,530,11],[542,2,916,8],[543,3,566,21],[545,5,564,18],[563,6,563,52],[568,4,582,13],[585,4,585,55],[587,3,605,21],[589,5,603,18],[595,6,597,12],[598,6,602,8],[606,3,883,16],[642,4,696,10],[643,5,645,18],[644,6,644,66],[646,5,648,18],[647,6,647,64],[649,5,695,12],[670,6,694,18],[686,7,688,18],[690,8,692,19],[698,5,881,11],[699,6,706,19],[702,8,704,21],[707,6,880,12],[708,7,763,13],[709,8,756,10],[757,8,762,14],[758,9,760,22],[761,9,761,62],[764,7,879,13],[765,8,800,14],[766,9,766,31],[767,9,777,22],[774,10,776,17],[778,9,782,22],[779,10,781,17],[783,9,793,22],[790,10,792,17],[794,9,794,27],[795,9,799,22],[801,8,878,14],[802,9,840,22],[824,10,826,23],[827,10,839,12],[841,9,854,22],[847,10,853,17],[855,9,855,24],[856,9,865,22],[860,10,864,17],[866,9,877,22],[874,10,876,17],[884,3,915,5],"sliderDisplayFormat",[386,29,521,2],"src\\routes\\_api\\home\\index.tsx","Home",[40,0,400,1],[41,13,41,42],[42,14,42,51],[44,19,54,3],[56,21,80,3],[82,26,96,3],[98,26,111,3],[113,21,130,3],[132,47,134,6],[136,18,136,31],[138,21,138,59],[140,24,142,2],[144,1,157,26],[157,5,157,24],[161,3,397,10],[168,4,208,20],[170,6,170,26],[173,7,205,9],[210,4,245,20],[212,6,214,12],[213,7,213,51],[218,6,218,23],[220,6,243,21],[224,10,240,12],[246,4,301,20],[248,6,250,12],[249,7,249,52],[254,6,254,23],[258,6,299,21],[261,9,296,11],[302,4,354,20],[304,6,306,12],[305,7,305,59],[310,6,310,23],[315,6,352,21],[318,9,349,11],[355,4,385,20],[357,6,359,12],[358,7,358,59],[363,6,363,23],[368,6,383,21],[371,9,380,11],[386,4,396,20],[388,6,390,12],[389,7,389,62],[394,13,394,69],"src\\routes\\_api\\search\\index.jsx","SearchPage",[32,0,386,1],[33,13,33,36],[35,18,35,31],[36,19,36,36],[36,9,36,14],[38,37,38,49],[41,14,41,51],[45,16,58,3],[59,16,72,3],[73,20,86,3],[87,15,100,3],[101,14,114,3],[115,22,128,3],[129,16,140,3],[141,18,153,3],[155,23,155,71],[155,8,155,19],[157,1,160,7],[162,2,384,8],[172,3,203,9],[173,4,194,6],[195,4,202,10],[201,5,201,61],[204,3,358,9],[210,5,229,20],[212,7,227,9],[232,5,257,20],[234,7,255,9],[260,5,274,20],[263,8,271,10],[277,5,290,20],[279,7,288,9],[293,5,307,20],[295,7,305,9],[310,5,324,20],[312,7,322,9],[327,5,340,20],[329,7,338,9],[343,5,356,20],[345,7,354,9],[375,5,381,11],[380,6,380,68],[383,3,383,13],"src\\routes\\_api\\favorite\\index.tsx","FavoritePage",[21,0,297,1],[22,13,22,36],[23,23,23,71],[23,8,23,19],[25,14,25,51],[27,16,38,3],[40,16,51,3],[53,20,64,3],[66,15,77,3],[79,14,90,3],[92,22,103,3],[105,16,116,3],[118,1,120,3],[123,2,295,9],[134,4,153,19],[136,6,151,8],[156,4,181,19],[158,6,179,8],[184,4,203,19],[186,6,201,8],[206,4,226,19],[208,6,224,8],[229,4,249,19],[231,6,247,8],[252,4,271,19],[254,6,269,8],[274,4,293,19],[276,6,291,8],"src\\routes\\setup\\server.list.tsx","ServerList",[28,0,206,1],[29,18,29,31],[30,39,30,53],[31,29,31,42],[31,9,31,24],[33,19,33,54],[35,21,35,37],[37,17,40,3],[42,23,45,3],[47,28,65,3],[90,1,92,7],[95,2,204,8],[96,3,96,21],[97,3,117,9],[106,4,108,17],[109,4,116,17],[115,5,115,56],[118,3,203,11],[121,6,201,12],[122,7,124,13],[125,7,173,13],[126,8,154,21],[136,10,152,12],[138,12,144,25],[155,8,163,21],[164,8,172,21],[174,7,200,13],[175,8,186,21],[185,9,185,62],[187,8,199,21],[198,9,198,71],"src\\routes\\setup\\server.add.tsx","ServerSetup",Line truncated
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
## 📝 Prerequisites
|
||||
|
||||
- Nodejs (≥19.1.0)
|
||||
- Rust (≥1.76.0)
|
||||
- Nodejs (22.14.0)
|
||||
- Rust (>=1.85.0)
|
||||
- Visual Studio C++ Build tools
|
||||
- [pnpm](https://pnpm.io/)
|
||||
|
||||
@@ -60,21 +60,25 @@
|
||||
- Sort/Filter library items
|
||||
- Queue playback support
|
||||
- Intro Skip button using [jumoog/Intro-Skipper](https://github.com/jumoog/intro-skipper) plugin
|
||||
- Mediasegment support
|
||||
|
||||
## 📷 Screenshots
|
||||
|
||||
- Home
|
||||

|
||||
- Title Page - Movie
|
||||

|
||||
- Title Page - Show
|
||||

|
||||
- Episode List
|
||||

|
||||
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212208" src="https://github.com/user-attachments/assets/036c2339-e8f1-4c8d-a908-af0ece9bb1f3" />
|
||||
- Library
|
||||
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212723" src="https://github.com/user-attachments/assets/6520a325-3cf3-47a0-9056-b27aded4bb8c" />
|
||||
- Music Player Detailed
|
||||
<img width="2560" height="1600" alt="Screenshot 2026-02-10 213017" src="https://github.com/user-attachments/assets/00a89efa-0a4c-4272-868e-f52c9fcfeaac" />
|
||||
- Item Page
|
||||
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212653" src="https://github.com/user-attachments/assets/5d281f8c-48ba-4787-b8ca-a4b86ccab5c1" />
|
||||
- Album / Music Player
|
||||
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212949" src="https://github.com/user-attachments/assets/d99aaea5-e242-4b3d-a5c5-d2868313728b" />
|
||||
- Search Dialog
|
||||
<img width="2560" height="1600" alt="Screenshot 2026-02-10 212749" src="https://github.com/user-attachments/assets/4ad87072-86ad-4510-95a4-567d6d11e997" />
|
||||
- Video Player
|
||||

|
||||
- About Dialog
|
||||

|
||||
<img width="2560" height="1600" alt="Screenshot 2026-02-10 213049" src="https://github.com/user-attachments/assets/effcca22-3650-46e1-9a86-b3b434851f2f" />
|
||||
|
||||
|
||||
## 📃 Roadmap
|
||||
|
||||
@@ -86,3 +90,4 @@
|
||||
- [@ferferga](https://github.com/ferferga) for helping in development behind the scenes.
|
||||
- All contributors of [jellyfin/jellyfin-vue](https://github.com/jellyfin/jellyfin-vue).
|
||||
- And also [@jellyfin](https://github.com/jellyfin/) for creating the main service
|
||||
|
||||
+22
-16
@@ -1,19 +1,27 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
},
|
||||
"$schema": "https://biomejs.dev/schemas/2.3.13/schema.json",
|
||||
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"style": {
|
||||
"noNonNullAssertion": "off",
|
||||
"useEnumInitializers": "off"
|
||||
"useEnumInitializers": "off",
|
||||
"noParameterAssign": "error",
|
||||
"useAsConstAssertion": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"noUnusedTemplateLiteral": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noInferrableTypes": "error",
|
||||
"noUselessElse": "error"
|
||||
},
|
||||
"a11y": {
|
||||
"useKeyWithClickEvents": "off",
|
||||
"useMediaCaption": "off"
|
||||
"useMediaCaption": "off",
|
||||
"noStaticElementInteractions": "off"
|
||||
},
|
||||
"correctness": {
|
||||
"useExhaustiveDependencies": "off",
|
||||
@@ -22,19 +30,17 @@
|
||||
"suspicious": {
|
||||
"noExplicitAny": "off"
|
||||
},
|
||||
"nursery": {
|
||||
"useComponentExportOnlyModules": "error"
|
||||
}
|
||||
"nursery": {}
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.jsx",
|
||||
"src/**/*.js",
|
||||
"*.json",
|
||||
"*.scss"
|
||||
"includes": [
|
||||
"**/src/**/*.ts",
|
||||
"**/src/**/*.tsx",
|
||||
"**/src/**/*.jsx",
|
||||
"**/src/**/*.js",
|
||||
"**/*.json",
|
||||
"**/*.scss"
|
||||
],
|
||||
"ignoreUnknown": true
|
||||
},
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="http://localhost:8097"></script>
|
||||
<!-- <script src="http://localhost:8097"></script> -->
|
||||
<title>Blink</title>
|
||||
<style>
|
||||
.app-loading {
|
||||
|
||||
+71
-63
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "blink",
|
||||
"private": true,
|
||||
"version": "1.0.0-alpha.3",
|
||||
"version": "1.0.0-alpha.4",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --force && tsr watch",
|
||||
@@ -13,78 +13,86 @@
|
||||
"tanstack-router-dev": "tsr watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dnd-kit/core": "^6.2.0",
|
||||
"@dnd-kit/modifiers": "^8.0.0",
|
||||
"@dnd-kit/sortable": "^9.0.0",
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/modifiers": "^9.0.0",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@emotion/react": "^11.13.5",
|
||||
"@emotion/styled": "^11.13.5",
|
||||
"@fontsource-variable/jetbrains-mono": "^5.1.1",
|
||||
"@fontsource-variable/noto-sans": "^5.1.0",
|
||||
"@fontsource-variable/plus-jakarta-sans": "^5.1.0",
|
||||
"@fontsource-variable/space-grotesk": "^5.1.0",
|
||||
"@jellyfin/sdk": "0.11.0",
|
||||
"@million/lint": "^1.0.13",
|
||||
"@mui/lab": "6.0.0-beta.17",
|
||||
"@mui/material": "6.1.9",
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@fontsource-variable/jetbrains-mono": "^5.2.8",
|
||||
"@fontsource-variable/noto-sans": "^5.2.10",
|
||||
"@fontsource-variable/plus-jakarta-sans": "^5.2.8",
|
||||
"@fontsource-variable/space-grotesk": "^5.2.10",
|
||||
"@jellyfin/sdk": "0.13.0",
|
||||
"@mui/lab": "7.0.1-beta.21",
|
||||
"@mui/material": "7.3.7",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@react-spring/web": "^9.7.5",
|
||||
"@tanem/react-nprogress": "^5.0.53",
|
||||
"@tanstack/react-query": "^5.62.0",
|
||||
"@tanstack/react-query-devtools": "^5.62.0",
|
||||
"@tanstack/react-router": "^1.85.0",
|
||||
"@tanstack/react-virtual": "^3.10.9",
|
||||
"@tauri-apps/api": "2.1.1",
|
||||
"@tauri-apps/plugin-clipboard-manager": "2.1.0-beta.6",
|
||||
"@tauri-apps/plugin-dialog": "2.0.1",
|
||||
"@tauri-apps/plugin-notification": "2.0.0",
|
||||
"@tauri-apps/plugin-process": "2.0.0",
|
||||
"@react-spring/web": "^10.0.3",
|
||||
"@tanem/react-nprogress": "^5.0.59",
|
||||
"@tanstack/react-form": "^1.28.0",
|
||||
"@tanstack/react-query": "^5.90.20",
|
||||
"@tanstack/react-query-devtools": "^5.91.3",
|
||||
"@tanstack/react-router": "^1.158.4",
|
||||
"@tanstack/react-router-devtools": "^1.158.4",
|
||||
"@tanstack/react-virtual": "^3.13.18",
|
||||
"@tauri-apps/api": "2.10.1",
|
||||
"@tauri-apps/plugin-clipboard-manager": "2.3.2",
|
||||
"@tauri-apps/plugin-dialog": "2.6.0",
|
||||
"@tauri-apps/plugin-global-shortcut": "~2.3.1",
|
||||
"@tauri-apps/plugin-notification": "2.3.3",
|
||||
"@tauri-apps/plugin-process": "2.3.1",
|
||||
"@tauri-apps/plugin-shell": "~2.3.5",
|
||||
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
||||
"@tauri-apps/plugin-updater": "2.0.0",
|
||||
"@tauri-apps/plugin-upload": "2.1.0",
|
||||
"@types/node": "^22.10.1",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"axios": "^1.7.8",
|
||||
"axios-tauri-api-adapter": "^2.0.3",
|
||||
"@tauri-apps/plugin-updater": "2.10.0",
|
||||
"@tauri-apps/plugin-upload": "2.4.0",
|
||||
"@tauri-apps/plugin-window-state": "~2.4.1",
|
||||
"@types/node": "^25.2.1",
|
||||
"@types/react": "^19.2.13",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"axios": "^1.13.4",
|
||||
"axios-tauri-api-adapter": "^2.0.6",
|
||||
"blurhash": "^2.0.5",
|
||||
"framer-motion": "^11.12.0",
|
||||
"immer": "^10.1.1",
|
||||
"jassub": "^1.7.17",
|
||||
"lodash": "^4.17.21",
|
||||
"material-symbols": "^0.27.1",
|
||||
"million": "^3.1.11",
|
||||
"notistack": "^3.0.1",
|
||||
"react": "18.3.1",
|
||||
"blurhash-wasm": "^0.2.0",
|
||||
"immer": "^11.1.3",
|
||||
"jassub": "^2.4.1",
|
||||
"libpgs": "^0.8.1",
|
||||
"lodash": "^4.17.23",
|
||||
"material-symbols": "^0.40.2",
|
||||
"motion": "^12.33.0",
|
||||
"notistack": "^3.0.2",
|
||||
"react": "^19.2.4",
|
||||
"react-blurhash": "^0.3.0",
|
||||
"react-dnd": "^16.0.1",
|
||||
"react-dnd-html5-backend": "^16.0.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react-error-boundary": "^4.1.2",
|
||||
"react-intersection-observer": "^9.13.1",
|
||||
"react-markdown": "^9.0.1",
|
||||
"react-multi-carousel": "^2.8.5",
|
||||
"react-player": "^2.16.0",
|
||||
"react-popper": "^2.3.0",
|
||||
"react-use-konami": "^1.1.0",
|
||||
"remark-gfm": "^4.0.0",
|
||||
"typescript": "^5.7.2",
|
||||
"vite-plugin-svgr": "^4.3.0",
|
||||
"wavesurfer.js": "^7.8.10",
|
||||
"zustand": "5.0.1"
|
||||
"react-dom": "^19.2.4",
|
||||
"react-error-boundary": "^6.1.0",
|
||||
"react-intersection-observer": "^10.0.2",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-multi-carousel": "^2.8.6",
|
||||
"react-player": "^3.4.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"typescript": "^5.9.3",
|
||||
"vite-plugin-svgr": "^4.5.0",
|
||||
"vite-plugin-top-level-await": "^1.6.0",
|
||||
"wavesurfer.js": "^7.12.1",
|
||||
"zod": "^4.3.6",
|
||||
"zustand": "5.0.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-optional-chaining-assign": "^7.25.9",
|
||||
"@biomejs/biome": "^1.9.4",
|
||||
"@tanstack/router-cli": "^1.84.4",
|
||||
"@tanstack/router-devtools": "^1.85.0",
|
||||
"@tanstack/router-vite-plugin": "^1.84.4",
|
||||
"@tauri-apps/cli": "2.1.0",
|
||||
"@types/lodash": "^4.17.13",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"@babel/plugin-proposal-optional-chaining-assign": "^7.27.1",
|
||||
"@biomejs/biome": "^2.3.14",
|
||||
"@tanstack/router-cli": "^1.158.4",
|
||||
"@tanstack/router-devtools": "^1.158.4",
|
||||
"@tanstack/router-vite-plugin": "^1.158.4",
|
||||
"@tauri-apps/cli": "2.10.0",
|
||||
"@types/lodash": "^4.17.23",
|
||||
"@vitejs/plugin-react": "^5.1.3",
|
||||
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
||||
"eslint-plugin-react-hooks": "7.0.1",
|
||||
"prop-types": "^15.8.1",
|
||||
"sass": "^1.81.0",
|
||||
"vite": "^6.0.2"
|
||||
"sass": "^1.97.3",
|
||||
"vite": "^7.3.1",
|
||||
"vite-plugin-wasm": "^3.5.0"
|
||||
},
|
||||
"license": "GPL-3.0-only"
|
||||
}
|
||||
Generated
+3187
-3167
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,4 @@
|
||||
onlyBuiltDependencies:
|
||||
- '@parcel/watcher'
|
||||
- core-js
|
||||
- esbuild
|
||||
Generated
+1997
-1677
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "blink"
|
||||
version = "1.0.0-alpha.3"
|
||||
version = "1.0.0-alpha.4"
|
||||
description = "A Modern Jellyfin Client"
|
||||
authors = ["prayag17", "Blink contributors (https://github.com/prayag17/Blink/graphs/contributors)"]
|
||||
license = "GPL-3.0-only"
|
||||
@@ -12,17 +12,16 @@ rust-version = "1.59"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.0.0-beta", features = [] }
|
||||
tauri-build = { version = "2.5.4", features = [] }
|
||||
|
||||
[dependencies]
|
||||
log = "^0.4.21"
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "2.0.0-beta", features = [ "devtools"] }
|
||||
tauri = { version = "2.10.1", features = [ "devtools"] }
|
||||
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2", features = ["colored"] }
|
||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||
portpicker = "0.1" # used in the example to pick a random free port
|
||||
tauri-plugin-process = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||
tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||
@@ -30,6 +29,7 @@ tauri-plugin-clipboard-manager = "2.1.0-beta.6"
|
||||
tauri-plugin-notification = "2.0.0-rc.1"
|
||||
tauri-plugin-upload = "2.0.0"
|
||||
tauri-plugin-dialog = "2.0.0"
|
||||
tauri-plugin-shell = "2.3.5"
|
||||
|
||||
[features]
|
||||
# by default Tauri runs in production mode
|
||||
@@ -38,3 +38,7 @@ default = [ "custom-protocol" ]
|
||||
# this feature is used for production builds where `devPath` points to the filesystem
|
||||
# DO NOT remove this
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-global-shortcut = "2"
|
||||
tauri-plugin-window-state = "2"
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"identifier": "desktop-capability",
|
||||
"platforms": [
|
||||
"macOS",
|
||||
"windows",
|
||||
"linux"
|
||||
],
|
||||
"windows": [
|
||||
"main"
|
||||
],
|
||||
"permissions": [
|
||||
"window-state:default",
|
||||
"global-shortcut:default",
|
||||
"global-shortcut:allow-is-registered",
|
||||
"global-shortcut:allow-register",
|
||||
"global-shortcut:allow-unregister",
|
||||
"shell:default"
|
||||
]
|
||||
}
|
||||
@@ -13,10 +13,14 @@
|
||||
"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"
|
||||
"clipboard-manager:allow-write-text",
|
||||
"shell:default",
|
||||
"shell:allow-open"
|
||||
]
|
||||
}
|
||||
@@ -1,17 +1,20 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"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"
|
||||
]
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"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"
|
||||
]
|
||||
}
|
||||
@@ -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-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-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 which includes:\n- 'core:path:default'\n- 'core:event:default'\n- 'core:window:default'\n- 'core:webview:default'\n- 'core:app:default'\n- 'core:image:default'\n- 'core:resources:default'\n- 'core:menu:default'\n- 'core:tray:default'\n","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"]},"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-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-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":["tauri_version"],"deny":[]}},"allow-version":{"identifier":"allow-version","description":"Enables the version command without any pre-configured scope.","commands":{"allow":["version"],"deny":[]}},"deny-app-hide":{"identifier":"deny-app-hide","description":"Denies the app_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["app_hide"]}},"deny-app-show":{"identifier":"deny-app-show","description":"Denies the app_show command without any pre-configured scope.","commands":{"allow":[],"deny":["app_show"]}},"deny-default-window-icon":{"identifier":"deny-default-window-icon","description":"Denies the default_winLine 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-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-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"]},"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-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.","commands":{"allow":["name"],"deny":[]}},"allow-register-listener":{"identifier":"allow-register-listener","description":"Enables the register_listener command without any pre-configured scope.","commands":{"allow":["register_listener"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-remove-listener":{"identifier":"allow-remove-listener","description":"Enables the remove_listener commLine truncated
|
||||
@@ -1 +1 @@
|
||||
{"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","notification:default","core:webview:allow-internal-toggle-devtools","dialog:default","upload:allow-download","clipboard-manager:allow-write-text"]},"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"]}}
|
||||
{"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"]}}
|
||||
+2730
-1741
File diff suppressed because it is too large.
Load diff
+2730
-1741
File diff suppressed because it is too large.
Load diff
@@ -4,6 +4,9 @@ use tauri_plugin_log::{fern::colors::ColoredLevelConfig, Target, TargetKind};
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.plugin(tauri_plugin_window_state::Builder::new().build())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_upload::init())
|
||||
.plugin(tauri_plugin_notification::init())
|
||||
|
||||
@@ -55,14 +55,13 @@
|
||||
"identifier": "com.blink.prayag17",
|
||||
"plugins": {
|
||||
"updater": {
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZEMTg0MjEzRDYzRjJDN0EKUldSNkxEL1dFMElZL1dxbHA0V2lyVDFEdGpOZXkxMG9XdHVLVnRpVVV5c1Z0OFNRUE45dkpxbFAK",
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZBOTJGNzM3REU2Q0JEMEYKUldRUHZXemVOL2VTK2k2andMWTZYbEN6SnIwV0V0L2Z3NlA4RzFabThPaXRqSFRMc004WGhCb2kK",
|
||||
"endpoints": [
|
||||
"https://rawcdn.githack.com/prayag17/Blink/refs/heads/main/latest.json"
|
||||
],
|
||||
"windows": {
|
||||
"installMode": "passive"
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
@@ -77,7 +76,8 @@
|
||||
"center": true,
|
||||
"label": "main",
|
||||
"dragDropEnabled": false,
|
||||
"backgroundColor": "#08001f"
|
||||
"backgroundColor": "#08001f",
|
||||
"transparent": false
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -1,17 +1,17 @@
|
||||
import { setServer } from "@/utils/storage/servers";
|
||||
import { jellyfin } from "@/utils/store/api";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
TextField,
|
||||
InputBase,
|
||||
Stack,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import React, { useState } from "react";
|
||||
import { setServer } from "@/utils/storage/servers";
|
||||
import { jellyfin } from "@/utils/store/api";
|
||||
|
||||
type AddServerDialogProps = {
|
||||
open: boolean;
|
||||
@@ -64,72 +64,99 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
onClose={() => setAddServerDialog(false)}
|
||||
hideBackdrop={Boolean(hideBackdrop)}
|
||||
fullWidth
|
||||
maxWidth="sm"
|
||||
disableScrollLock={true}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
backgroundColor: "rgba(20, 20, 30, 0.7)",
|
||||
backdropFilter: "blur(24px) saturate(180%)",
|
||||
backgroundImage:
|
||||
"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0))",
|
||||
border: "1px solid rgba(255, 255, 255, 0.08)",
|
||||
boxShadow: "0 20px 50px rgba(0,0,0,0.5)",
|
||||
borderRadius: 4,
|
||||
overflow: "hidden",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle variant="h4" align="center" mb={1}>
|
||||
Add Server
|
||||
</DialogTitle>
|
||||
<DialogContent className="settings-server-add">
|
||||
<TextField
|
||||
variant="filled"
|
||||
label="Address"
|
||||
fullWidth
|
||||
onChange={(e) => setServerIp(e.target.value)}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions
|
||||
style={{
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
padding: "1em",
|
||||
gap: "1em",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
cancel
|
||||
</span>
|
||||
}
|
||||
color="error"
|
||||
onClick={() => setAddServerDialog(false)}
|
||||
<Stack p={4} spacing={3}>
|
||||
<Stack spacing={1} alignItems="center">
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
fontSize: "48px",
|
||||
color: "var(--mui-palette-primary-main)",
|
||||
}}
|
||||
>
|
||||
add_to_queue
|
||||
</span>
|
||||
<Typography variant="h5" fontWeight="bold" textAlign="center">
|
||||
Connect to Server
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary" textAlign="center">
|
||||
Enter your Jellyfin server address to continue
|
||||
</Typography>
|
||||
</Stack>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
p: "2px 16px",
|
||||
bgcolor: "rgba(0,0,0,0.2)",
|
||||
borderRadius: 2,
|
||||
border: "1px solid",
|
||||
borderColor: "rgba(255,255,255,0.05)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: 2,
|
||||
"&:focus-within": {
|
||||
borderColor: "var(--mui-palette-primary-main)",
|
||||
bgcolor: "rgba(0,0,0,0.3)",
|
||||
},
|
||||
transition: "border-color 0.2s, background-color 0.2s",
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
{/* @ts-ignore */}
|
||||
<LoadingButton
|
||||
startIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
add_circle
|
||||
</span>
|
||||
}
|
||||
variant="contained"
|
||||
loading={addServer.isPending}
|
||||
loadingPosition="start"
|
||||
onClick={addServer.mutate}
|
||||
color="success"
|
||||
>
|
||||
Add
|
||||
</LoadingButton>
|
||||
</DialogActions>
|
||||
<span className="material-symbols-rounded" style={{ opacity: 0.5 }}>
|
||||
dns
|
||||
</span>
|
||||
<InputBase
|
||||
placeholder="https://jellyfin.example.com"
|
||||
fullWidth
|
||||
value={serverIp}
|
||||
onChange={(e) => setServerIp(e.target.value)}
|
||||
sx={{ py: 1.5 }}
|
||||
autoFocus
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
addServer.mutate();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Stack direction="row" spacing={2} justifyContent="flex-end" pt={1}>
|
||||
<Button
|
||||
onClick={() => setAddServerDialog(false)}
|
||||
color="inherit"
|
||||
variant="text"
|
||||
sx={{ borderRadius: 2 }}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<LoadingButton
|
||||
loading={addServer.isPending}
|
||||
onClick={() => addServer.mutate()}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
sx={{ borderRadius: 2, px: 3 }}
|
||||
disabled={!serverIp}
|
||||
>
|
||||
Connect
|
||||
</LoadingButton>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
.alpha-selector {
|
||||
position: sticky;
|
||||
top: 80px;
|
||||
right: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px;
|
||||
margin-left: auto;
|
||||
user-select: none;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.alpha-letter {
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
padding: 6px 8px;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: rgba(255,255,255,0.7);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.alpha-letter.active {
|
||||
background: rgba(255,255,255,0.12);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.alpha-letter:hover {
|
||||
background: rgba(255,255,255,0.08);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { getRouteApi } from "@tanstack/react-router";
|
||||
import React, { useMemo } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
import "./alphaSelector.scss";
|
||||
|
||||
const libraryRoute = getRouteApi("/_api/library/$id");
|
||||
|
||||
export const AlphaSelector = React.memo(function AlphaSelector() {
|
||||
const { id: currentLibraryId } = libraryRoute.useParams();
|
||||
const { nameStartsWith } = useLibraryStateStore(
|
||||
useShallow((s) => ({
|
||||
nameStartsWith: s.libraries[currentLibraryId || ""]?.nameStartsWith,
|
||||
})),
|
||||
);
|
||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||
|
||||
const letters = useMemo(() => {
|
||||
const arr = Array.from({ length: 26 }, (_, i) =>
|
||||
String.fromCharCode(65 + i),
|
||||
);
|
||||
return ["All", ...arr];
|
||||
}, []);
|
||||
|
||||
const handleSelect = (letter: string) => {
|
||||
const value = letter === "All" ? undefined : letter;
|
||||
if (currentLibraryId)
|
||||
updateLibrary(currentLibraryId, { nameStartsWith: value });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="alpha-selector">
|
||||
{letters.map((l) => {
|
||||
const active = (nameStartsWith || "All") === l;
|
||||
return (
|
||||
<button
|
||||
key={l}
|
||||
className={active ? "alpha-letter active" : "alpha-letter"}
|
||||
onClick={() => handleSelect(l)}
|
||||
aria-label={`Filter by ${l}`}
|
||||
type="button"
|
||||
>
|
||||
{l}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
export default AlphaSelector;
|
||||
@@ -1,20 +1,48 @@
|
||||
|
||||
.appBar {
|
||||
transition: background-color $transition-time-fast,
|
||||
backdrop-filter $transition-time-fast,
|
||||
box-shadow $transition-time-default !important;
|
||||
// Limit transitions to cheaper properties; avoid animating box-shadow directly
|
||||
transition: background-color $transition-time-fast;
|
||||
padding: 0.8em ($page-margin - 1.7em);
|
||||
z-index: 999 !important;
|
||||
.flex {
|
||||
transition: $transition-time-fast;
|
||||
// Avoid animating padding; it causes layout reflow on each frame.
|
||||
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;
|
||||
position: relative;
|
||||
|
||||
// Pseudo-element handles elevation shadow; we animate its opacity
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: -0.35em;
|
||||
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 {
|
||||
padding: 0.5em;
|
||||
background: rgb(0 0 0 / 0.4);
|
||||
backdrop-filter: blur(40px);
|
||||
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
||||
&::after {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply a subtle scale to simulate shrink without layout changes
|
||||
.flex-inner {
|
||||
transform: scaleY(0.95);
|
||||
}
|
||||
}
|
||||
&-avatar {
|
||||
@@ -62,48 +90,98 @@
|
||||
}
|
||||
}
|
||||
|
||||
.library-drawer{
|
||||
width: 20em;
|
||||
margin: 1.4em;
|
||||
height: calc(100vh - 2.8em) !important;
|
||||
border-radius: 20px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
.library-drawer-item{
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-radius: 1000px;
|
||||
> div::before{
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: transparent;
|
||||
transition: $transition-time-default;
|
||||
z-index: -1;
|
||||
border-radius: 100px;
|
||||
.library-drawer {
|
||||
// Ensure the drawer paper itself gets the styling
|
||||
&.MuiDrawer-paper {
|
||||
width: 280px;
|
||||
margin: 16px;
|
||||
height: calc(100% - 32px) !important; // float in the middle
|
||||
border-radius: 24px;
|
||||
background: rgba(20, 20, 25, 0.75); // Darker, substantial base
|
||||
backdrop-filter: blur(24px) saturate(180%);
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
box-shadow:
|
||||
0 24px 48px rgba(0, 0, 0, 0.4),
|
||||
0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
overflow: hidden; // Contain scrollbars
|
||||
}
|
||||
|
||||
.MuiList-root {
|
||||
padding: 8px; // Reduced from 16px
|
||||
gap: 2px; // Reduced gap
|
||||
}
|
||||
|
||||
.MuiDivider-root {
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
margin: 4px 12px; // Reduced margins
|
||||
}
|
||||
|
||||
// Navigation Items
|
||||
.MuiListItemButton-root {
|
||||
border-radius: 12px !important; // Slightly smaller radius
|
||||
padding: 8px 12px; // Reduced padding (was 12px 16px)
|
||||
margin-bottom: 2px;
|
||||
transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
color: #fff;
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
margin-right: 12px; // Reduced spacing
|
||||
font-size: 22px; // Slightly smaller icons usually look better with less padding
|
||||
transition: all 0.2s ease;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.MuiListItemText-primary {
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem; // Slightly smaller text
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
}
|
||||
.active.library-drawer-item {
|
||||
.material-symbols-rounded{
|
||||
--fill: 1;
|
||||
}
|
||||
&> div::before {
|
||||
background: $clr-accent-default;
|
||||
|
||||
// Active State
|
||||
.library-drawer-item.active {
|
||||
.MuiListItemButton-root {
|
||||
background: linear-gradient(90deg, rgba($clr-accent-default, 0.2), rgba($clr-accent-default, 0.05));
|
||||
color: $clr-accent-default;
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-variation-settings: 'FILL' 1;
|
||||
color: $clr-accent-default;
|
||||
}
|
||||
|
||||
// Active Indicator Bar
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
height: 24px;
|
||||
width: 4px;
|
||||
background: $clr-accent-default;
|
||||
border-radius: 0 4px 4px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Magic scrollbar
|
||||
|
||||
// Custom Scrollbar for the drawer content
|
||||
&::-webkit-scrollbar {
|
||||
&-thumb {
|
||||
height: 150px;
|
||||
max-height: 33%;
|
||||
}
|
||||
&-track {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
background: transparent !important;
|
||||
width: 4px;
|
||||
}
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 4px;
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,164 +1,54 @@
|
||||
import React, {
|
||||
type MouseEventHandler,
|
||||
useCallback,
|
||||
useMemo,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import MuiAppBar from "@mui/material/AppBar";
|
||||
import Avatar from "@mui/material/Avatar";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import ListItemIcon from "@mui/material/ListItemIcon";
|
||||
import Menu from "@mui/material/Menu";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import React, { useCallback, useMemo, useState } from "react";
|
||||
|
||||
import {
|
||||
Link,
|
||||
useLocation,
|
||||
useNavigate,
|
||||
useRouter,
|
||||
} from "@tanstack/react-router";
|
||||
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import "./appBar.scss";
|
||||
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
import { useShallow } from "zustand/shallow";
|
||||
// removed search placeholder; library state now managed via zustand
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
import {
|
||||
Divider,
|
||||
Drawer,
|
||||
List,
|
||||
ListItem,
|
||||
ListItemButton,
|
||||
ListItemText,
|
||||
} from "@mui/material";
|
||||
import useHeaderStore from "@/utils/store/header";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
import BackButton from "../buttons/backButton";
|
||||
|
||||
interface ListItemLinkProps {
|
||||
icon?: ReactNode;
|
||||
primary: string;
|
||||
to: string;
|
||||
}
|
||||
|
||||
function ListItemLink(props: ListItemLinkProps) {
|
||||
const { icon, primary, to } = props;
|
||||
|
||||
return (
|
||||
<li>
|
||||
{/* @ts-ignore */}
|
||||
<ListItem
|
||||
component={Link}
|
||||
activeClassName="active"
|
||||
className="library-drawer-item"
|
||||
to={to}
|
||||
>
|
||||
<ListItemButton
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
color: "white",
|
||||
textDecoration: "none",
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">{icon}</div>
|
||||
<ListItemText primary={primary} />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||
import { NavigationDrawer } from "./navigationDrawer";
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
|
||||
const HIDDEN_PATHS = [
|
||||
"/login",
|
||||
"/setup",
|
||||
"/server",
|
||||
"/player",
|
||||
"/error",
|
||||
"/settings",
|
||||
"/library",
|
||||
"/search",
|
||||
];
|
||||
|
||||
export const AppBar = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [display, setDisplay] = useState(false);
|
||||
|
||||
const location = useLocation();
|
||||
const router = useRouter();
|
||||
|
||||
const [user, resetCurrentUser] = useCentralStore((s) => [
|
||||
s.currentUser,
|
||||
s.resetCurrentUser,
|
||||
]);
|
||||
const libraries = useQuery({
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
if (!user?.Id || !api?.accessToken) {
|
||||
return;
|
||||
}
|
||||
const libs = await getUserViewsApi(api).getUserViews({
|
||||
userId: user.Id,
|
||||
});
|
||||
return libs.data;
|
||||
},
|
||||
enabled: !!user?.Id && !!api?.accessToken,
|
||||
networkMode: "always",
|
||||
});
|
||||
const toggleSearchDialog = useSearchStore(
|
||||
useShallow((s) => s.toggleSearchDialog),
|
||||
);
|
||||
|
||||
const display = !HIDDEN_PATHS.some(
|
||||
(path) =>
|
||||
(location.pathname.startsWith(path) &&
|
||||
location.pathname !== "/player/audio") ||
|
||||
location.pathname === "/",
|
||||
);
|
||||
|
||||
const trigger = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 20,
|
||||
});
|
||||
|
||||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
||||
const openMenu = Boolean(anchorEl);
|
||||
const handleMenuOpen: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||
(event) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
},
|
||||
[],
|
||||
);
|
||||
const handleMenuClose = useCallback(() => {
|
||||
setAnchorEl(null);
|
||||
}, []);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const handleLogout = async () => {
|
||||
console.log("Logging out user...");
|
||||
await api?.logout();
|
||||
createApi(api?.basePath ?? "", undefined);
|
||||
console.log(api);
|
||||
resetCurrentUser();
|
||||
delUser();
|
||||
sessionStorage.removeItem("accessToken");
|
||||
await router.invalidate();
|
||||
queryClient.clear();
|
||||
setAnchorEl(null);
|
||||
navigate({ to: "/login" });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
location.pathname.includes("login") ||
|
||||
location.pathname.includes("setup") ||
|
||||
location.pathname.includes("server") ||
|
||||
location.pathname === "/player" ||
|
||||
location.pathname.includes("error") ||
|
||||
location.pathname === "/"
|
||||
) {
|
||||
setDisplay(false);
|
||||
} else {
|
||||
setDisplay(true);
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
const [showDrawer, setShowDrawer] = useState(false);
|
||||
|
||||
const appBarStyling = useMemo(() => {
|
||||
@@ -167,18 +57,8 @@ export const AppBar = () => {
|
||||
paddingRight: "0 !important",
|
||||
};
|
||||
}, []);
|
||||
const menuStyle = useMemo(() => {
|
||||
return { mt: 2 };
|
||||
}, []);
|
||||
|
||||
const drawerPaperProps = useMemo(() => {
|
||||
return {
|
||||
className: "glass library-drawer",
|
||||
elevation: 6,
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleNavigateToSearch = useCallback(
|
||||
const _handleNavigateToSearch = useCallback(
|
||||
() => navigate({ to: "/search", search: { query: "" } }),
|
||||
[navigate],
|
||||
);
|
||||
@@ -196,10 +76,10 @@ export const AppBar = () => {
|
||||
navigate({ to: "/favorite" });
|
||||
}, []);
|
||||
|
||||
const menuButtonSx = useMemo(() => ({ p: 0 }), []);
|
||||
useHeaderStore(useShallow((s) => ({ pageTitle: s.pageTitle })));
|
||||
|
||||
if (!display) {
|
||||
return <></>;
|
||||
return null;
|
||||
}
|
||||
if (display) {
|
||||
return (
|
||||
@@ -216,11 +96,11 @@ export const AppBar = () => {
|
||||
>
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton onClick={handleDrawerOpen}>
|
||||
<div className="material-symbols-rounded">menu</div>
|
||||
<span className="material-symbols-rounded">menu</span>
|
||||
</IconButton>
|
||||
<MemoizeBackButton />
|
||||
<IconButton onClick={handleNavigateToHome}>
|
||||
<div
|
||||
<span
|
||||
className={
|
||||
location.pathname === "/home"
|
||||
? "material-symbols-rounded fill"
|
||||
@@ -228,169 +108,22 @@ export const AppBar = () => {
|
||||
}
|
||||
>
|
||||
home
|
||||
</div>
|
||||
</span>
|
||||
</IconButton>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton onClick={handleNavigateToSearch}>
|
||||
<div className="material-symbols-rounded">search</div>
|
||||
<IconButton onClick={toggleSearchDialog}>
|
||||
<span className="material-symbols-rounded">search</span>
|
||||
</IconButton>
|
||||
<IconButton onClick={handleNavigateToFavorite}>
|
||||
<div className="material-symbols-rounded">favorite</div>
|
||||
<span className="material-symbols-rounded">favorite</span>
|
||||
</IconButton>
|
||||
<IconButton sx={menuButtonSx} onClick={handleMenuOpen}>
|
||||
{!!user?.Id &&
|
||||
(user?.PrimaryImageTag === undefined ? (
|
||||
<Avatar className="appBar-avatar" alt={user?.Name ?? "image"}>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
) : (
|
||||
<Avatar
|
||||
className="appBar-avatar"
|
||||
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
||||
alt={user?.Name ?? "image"}
|
||||
>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
))}
|
||||
</IconButton>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
open={openMenu}
|
||||
onClose={handleMenuClose}
|
||||
sx={menuStyle}
|
||||
disableScrollLock
|
||||
>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
handleLogout();
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">logout</div>
|
||||
</ListItemIcon>
|
||||
Logout
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(1);
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">settings</div>
|
||||
</ListItemIcon>
|
||||
Settings
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(10);
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">info</div>
|
||||
</ListItemIcon>
|
||||
About
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<UserAvatarMenu />
|
||||
</div>
|
||||
</MuiAppBar>
|
||||
<Drawer
|
||||
open={showDrawer}
|
||||
PaperProps={drawerPaperProps}
|
||||
className="library-drawer"
|
||||
onClose={handleDrawerClose}
|
||||
>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
onClick={handleDrawerClose}
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">menu_open</span>
|
||||
Close
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItemLink to="/home" icon="home" primary="Home" />
|
||||
{libraries.isSuccess &&
|
||||
libraries.data?.Items?.map((library) => (
|
||||
<ListItemLink
|
||||
key={library.Id}
|
||||
to={`/library/${library.Id}`}
|
||||
icon={
|
||||
library.CollectionType &&
|
||||
getTypeIcon(library.CollectionType)
|
||||
}
|
||||
primary={library.Name ?? "Library"}
|
||||
/>
|
||||
))}
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(1);
|
||||
}}
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">settings</span>
|
||||
Settings
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(2);
|
||||
}}
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">dns</span>
|
||||
Change Server
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(10);
|
||||
}}
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">info</span>
|
||||
About
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</List>
|
||||
</Drawer>
|
||||
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,107 @@
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
import { Divider, Drawer, List, ListItem, ListItemButton } from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React, { useMemo } from "react";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import ListItemLink from "../listItemLink";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
interface NavigationDrawerProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const [user] = useCentralStore((s) => [s.currentUser]);
|
||||
|
||||
const libraries = useQuery({
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
if (!user?.Id || !api?.accessToken) {
|
||||
return;
|
||||
}
|
||||
const libs = await getUserViewsApi(api).getUserViews({
|
||||
userId: user.Id,
|
||||
});
|
||||
return libs.data;
|
||||
},
|
||||
enabled: !!user?.Id && !!api?.accessToken,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const drawerPaperProps = useMemo(() => {
|
||||
return {
|
||||
className: "glass library-drawer",
|
||||
elevation: 6,
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
open={open}
|
||||
slotProps={{ paper: drawerPaperProps }}
|
||||
className="library-drawer"
|
||||
onClose={onClose}
|
||||
>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemButton onClick={onClose}>
|
||||
<span className="material-symbols-rounded">menu_open</span>
|
||||
<div style={{ marginLeft: "8px" }}>Close</div>
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
to="/home"
|
||||
icon="home"
|
||||
primary="Home"
|
||||
onClick={onClose}
|
||||
/>
|
||||
{libraries.isSuccess &&
|
||||
libraries.data?.Items?.map((library) => (
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
key={library.Id}
|
||||
to="/library/$id"
|
||||
params={{ id: library.Id ?? "" }}
|
||||
icon={
|
||||
library.CollectionType &&
|
||||
getTypeIcon(library.CollectionType)
|
||||
}
|
||||
primary={library.Name ?? "Library"}
|
||||
onClick={onClose}
|
||||
/>
|
||||
))}
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItemLink
|
||||
to="/settings/preferences"
|
||||
icon="settings"
|
||||
primary="Settings"
|
||||
className="library-drawer-item"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/settings/changeServer"
|
||||
icon="dns"
|
||||
primary="Change Server"
|
||||
className="library-drawer-item"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/settings/about"
|
||||
icon="info"
|
||||
primary="About"
|
||||
className="library-drawer-item"
|
||||
onClick={onClose}
|
||||
/>
|
||||
</List>
|
||||
</Drawer>
|
||||
);
|
||||
};
|
||||
@@ -1,46 +1,50 @@
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import React, { useLayoutEffect, useState } from "react";
|
||||
import BlurhashCanvas from "../blurhash-canvas";
|
||||
|
||||
export default function Backdrop() {
|
||||
const [backdropLoading, setBackdropLoading] = useState(true);
|
||||
// const [backdropLoading, setBackdropLoading] = useState(true);
|
||||
|
||||
const [backdropId, backdropUrl] = useBackdropStore((state) => [
|
||||
state.backdropId,
|
||||
state.backdropUrl,
|
||||
]);
|
||||
const { backdropHash } = useBackdropStore(
|
||||
useShallow((state) => ({
|
||||
backdropHash: state.backdropHash,
|
||||
})),
|
||||
);
|
||||
|
||||
// Reset loading status for backdrop
|
||||
useLayoutEffect(() => {
|
||||
setBackdropLoading(true);
|
||||
}, [backdropId]);
|
||||
if (!backdropHash) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="app-backdrop-container">
|
||||
<AnimatePresence>
|
||||
<motion.img
|
||||
key={backdropId}
|
||||
src={backdropUrl}
|
||||
alt=""
|
||||
className="app-backdrop"
|
||||
initial={{
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
opacity: backdropLoading ? 0 : 1,
|
||||
}}
|
||||
exit={{
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
opacity: {
|
||||
duration: 1.2,
|
||||
<AnimatePresence mode="sync">
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
key={backdropHash}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{
|
||||
duration: 2,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="app-backdrop-container"
|
||||
>
|
||||
<BlurhashCanvas
|
||||
blurhashString={backdropHash}
|
||||
width={300}
|
||||
height={150}
|
||||
canvasProps={{
|
||||
style: {
|
||||
display: "block",
|
||||
width: "100vw",
|
||||
height: "100vh",
|
||||
margin: "0 auto",
|
||||
filter: "brightness(0.8) contrast(1.6) saturate(1.6)",
|
||||
},
|
||||
}}
|
||||
onLoad={() => setBackdropLoading(false)}
|
||||
loading="lazy"
|
||||
/>
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import * as blurhash from "blurhash-wasm";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
type BlurhashCanvasProps = {
|
||||
canvasProps?: React.CanvasHTMLAttributes<HTMLCanvasElement>;
|
||||
blurhashString: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
// punch?: number;
|
||||
onLoad?: () => void;
|
||||
onError?: (error: Error) => void;
|
||||
};
|
||||
|
||||
const BlurhashCanvas = ({
|
||||
canvasProps,
|
||||
blurhashString,
|
||||
width,
|
||||
height,
|
||||
// punch,
|
||||
onLoad,
|
||||
onError,
|
||||
}: BlurhashCanvasProps) => {
|
||||
const canvasRef = React.useRef<HTMLCanvasElement>(null);
|
||||
useEffect(() => {
|
||||
const canvas = canvasRef.current;
|
||||
if (!canvas) return;
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) return;
|
||||
const drawBlurhash = async () => {
|
||||
try {
|
||||
const imageDataBuffer = blurhash.decode(
|
||||
blurhashString,
|
||||
width || 32,
|
||||
height || 32,
|
||||
// punch || 1,
|
||||
);
|
||||
// canvas.width = width || 32;
|
||||
// canvas.height = height || 32;
|
||||
if (!imageDataBuffer) {
|
||||
throw new Error("Failed to decode blurhash");
|
||||
}
|
||||
const imageData = new ImageData(
|
||||
new Uint8ClampedArray(imageDataBuffer),
|
||||
width || 32,
|
||||
height || 32,
|
||||
);
|
||||
// imageData.data.set(imageDataBuffer);
|
||||
ctx.putImageData(imageData, 0, 0);
|
||||
if (onLoad) onLoad();
|
||||
} catch (error) {
|
||||
if (onError) onError(error as Error);
|
||||
else console.error("Error decoding blurhash:", error);
|
||||
}
|
||||
};
|
||||
drawBlurhash();
|
||||
}, [blurhash, width, height, onLoad, onError]);
|
||||
return <canvas ref={canvasRef} {...canvasProps} />;
|
||||
};
|
||||
|
||||
export default BlurhashCanvas;
|
||||
@@ -1,13 +1,11 @@
|
||||
import React from "react";
|
||||
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import type { UserItemDataDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { pink } from "@mui/material/colors";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React from "react";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
|
||||
export default function LikeButton({
|
||||
itemId,
|
||||
@@ -78,24 +76,24 @@ export default function LikeButton({
|
||||
transition: "opacity 250ms",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={
|
||||
isFavorite
|
||||
? {
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
"--fill": mutation.isPending ? 0 : 1,
|
||||
color: mutation.isPending ? "white" : pink.A700,
|
||||
}
|
||||
: {
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
"--fill": mutation.isPending ? 1 : 0,
|
||||
color: mutation.isPending ? pink.A700 : "white",
|
||||
}
|
||||
}
|
||||
>
|
||||
favorite
|
||||
</div>
|
||||
</span>
|
||||
</IconButton>
|
||||
);
|
||||
}
|
||||
@@ -1,45 +1,25 @@
|
||||
import React, { memo, type MouseEvent } from "react"; // Import memo
|
||||
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
import type { SxProps } from "@mui/material";
|
||||
import Button, { type ButtonProps } from "@mui/material/Button";
|
||||
import Fab from "@mui/material/Fab";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
type BaseItemDtoQueryResult,
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
ItemFilter,
|
||||
LocationType,
|
||||
type MediaSegmentDtoQueryResult,
|
||||
type PlaybackInfoResponse,
|
||||
SortOrder,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import { setQueue } from "@/utils/store/queue";
|
||||
|
||||
import { playItem, usePlaybackDataLoadStore } from "@/utils/store/playback";
|
||||
|
||||
import React, { type MouseEvent, memo } from "react"; // Import memo
|
||||
import type PlayResult from "@//utils/types/playResult";
|
||||
import { getRuntimeCompact } from "@/utils/date/time";
|
||||
import getSubtitle from "@/utils/methods/getSubtitles";
|
||||
import playbackProfile from "@/utils/playback-profiles";
|
||||
import { getNextEpisode, getPlaybackInfo } from "@/utils/methods/playback";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
||||
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import type { SxProps } from "@mui/material";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { initializePlayback } from "@/utils/store/playback";
|
||||
import { setQueue } from "@/utils/store/queue";
|
||||
|
||||
type PlayButtonProps = {
|
||||
item: BaseItemDto;
|
||||
@@ -76,7 +56,7 @@ const MemoizedLinearProgress = memo(({ value }: { value: number }) => (
|
||||
zIndex: 0,
|
||||
mixBlendMode: "difference",
|
||||
}}
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
color="white"
|
||||
/>
|
||||
));
|
||||
@@ -87,7 +67,7 @@ const PlayButton = ({
|
||||
itemType,
|
||||
currentAudioTrack,
|
||||
currentSubTrack,
|
||||
currentVideoTrack,
|
||||
// currentVideoTrack,
|
||||
className,
|
||||
sx,
|
||||
buttonProps,
|
||||
@@ -98,11 +78,10 @@ const PlayButton = ({
|
||||
playlistItemId = "",
|
||||
}: PlayButtonProps) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const setPlaybackDataLoading = usePlaybackDataLoadStore(
|
||||
(state) => state.setisPending,
|
||||
);
|
||||
// const setPlaybackDataLoading = usePlaybackDataLoadStore(
|
||||
// (state) => state.setisPending,
|
||||
// );
|
||||
const playPhotos = usePhotosPlayback((s) => s.playPhotos);
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
@@ -110,325 +89,25 @@ const PlayButton = ({
|
||||
const itemQuery = useMutation({
|
||||
mutationKey: ["playButton", item?.Id, userId],
|
||||
mutationFn: async (currentEpisodeId?: string) => {
|
||||
setPlaybackDataLoading(true);
|
||||
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
||||
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
||||
let introInfo: undefined | MediaSegmentDtoQueryResult;
|
||||
let index = 0;
|
||||
if (!api) {
|
||||
throw new Error("API is not available");
|
||||
}
|
||||
if (!userId) {
|
||||
throw new Error("User ID is not available");
|
||||
}
|
||||
if (!item.Id) {
|
||||
throw new Error("Item ID is not available");
|
||||
}
|
||||
if (playlistItem) {
|
||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
||||
userId: userId,
|
||||
playlistId: playlistItemId,
|
||||
});
|
||||
} else {
|
||||
switch (itemType) {
|
||||
case BaseItemKind.Episode:
|
||||
if (item.SeriesId && item.SeasonId) {
|
||||
result = await getTvShowsApi(api).getEpisodes({
|
||||
seriesId: item.SeriesId,
|
||||
fields: [
|
||||
ItemFields.MediaSources,
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.Overview,
|
||||
ItemFields.Chapters,
|
||||
ItemFields.Trickplay,
|
||||
],
|
||||
enableUserData: true,
|
||||
userId: userId,
|
||||
seasonId: item.SeasonId,
|
||||
isMissing: false,
|
||||
// startItemId: item.Id,
|
||||
});
|
||||
|
||||
if (
|
||||
result.data.Items?.map((i) => i.Id).indexOf(
|
||||
currentEpisodeId,
|
||||
) === -1
|
||||
) {
|
||||
throw new Error(
|
||||
`Episode having id ${currentEpisodeId} not found, index return -1`,
|
||||
);
|
||||
}
|
||||
index =
|
||||
result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ??
|
||||
0;
|
||||
if (currentAudioTrack === "auto") {
|
||||
const defaultAudioStreamIndex =
|
||||
result.data.Items?.[index].MediaSources?.[0]
|
||||
.DefaultAudioStreamIndex;
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: Number(defaultAudioStreamIndex),
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items?.[index]?.Id ?? "",
|
||||
startTimeTicks:
|
||||
result.data.Items?.[index].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[index].MediaSources?.[0]?.Id ?? "",
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: currentAudioTrack,
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items?.[index]?.Id ?? "",
|
||||
startTimeTicks:
|
||||
result.data.Items?.[index].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[index].MediaSources?.[0]?.Id ?? "",
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
}
|
||||
introInfo = (
|
||||
await getMediaSegmentsApi(api).getItemSegments({
|
||||
itemId: result.data.Items?.[index]?.Id ?? "",
|
||||
})
|
||||
)?.data;
|
||||
}
|
||||
break;
|
||||
case BaseItemKind.Series:
|
||||
result = await getTvShowsApi(api).getEpisodes({
|
||||
seriesId: item.Id,
|
||||
fields: [
|
||||
ItemFields.MediaSources,
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.Overview,
|
||||
ItemFields.Chapters,
|
||||
ItemFields.Trickplay,
|
||||
],
|
||||
enableUserData: true,
|
||||
userId: userId,
|
||||
isMissing: false,
|
||||
});
|
||||
if (
|
||||
currentEpisodeId &&
|
||||
result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ===
|
||||
-1
|
||||
) {
|
||||
throw new Error(
|
||||
`Episode having id=${currentEpisodeId} not found, index return -1`,
|
||||
);
|
||||
}
|
||||
if (!currentEpisodeId) {
|
||||
index = 0;
|
||||
} else {
|
||||
index =
|
||||
result.data.Items?.map((i) => i.Id).indexOf(currentEpisodeId) ??
|
||||
0;
|
||||
}
|
||||
if (
|
||||
result.data.Items?.[index].Id &&
|
||||
result.data.Items?.[index].MediaSources?.[0]?.Id
|
||||
) {
|
||||
if (currentAudioTrack === "auto") {
|
||||
const defaultAudioStreamIndex =
|
||||
result.data.Items?.[index].MediaSources?.[0]
|
||||
.DefaultAudioStreamIndex;
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: Number(defaultAudioStreamIndex),
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items[index].Id ?? "",
|
||||
startTimeTicks:
|
||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[index].MediaSources?.[0].Id ?? "",
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: currentAudioTrack,
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items[index].Id ?? "",
|
||||
startTimeTicks:
|
||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[index].MediaSources?.[0].Id ?? "",
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
introInfo = (
|
||||
await getMediaSegmentsApi(api).getItemSegments({
|
||||
itemId: result.data.Items?.[index].Id ?? "",
|
||||
})
|
||||
)?.data;
|
||||
} else {
|
||||
throw new Error(
|
||||
`No media source id provieded for the episode. Return values are seriesId = ${result.data.Items?.[index].Id}, mediaSourceId = ${result.data.Items?.[index].MediaSources?.[0]?.Id}, index = ${index}`,
|
||||
);
|
||||
}
|
||||
break;
|
||||
case BaseItemKind.Playlist:
|
||||
case BaseItemKind.MusicAlbum:
|
||||
result = await getItemsApi(api).getItems({
|
||||
parentId: item.Id,
|
||||
userId: userId,
|
||||
fields: [ItemFields.MediaSources, ItemFields.MediaStreams],
|
||||
sortOrder: [SortOrder.Ascending],
|
||||
sortBy: ["IndexNumber"],
|
||||
});
|
||||
break;
|
||||
case BaseItemKind.MusicArtist:
|
||||
result = await getItemsApi(api).getItems({
|
||||
artistIds: [item.Id ?? ""],
|
||||
recursive: true,
|
||||
includeItemTypes: [BaseItemKind.Audio],
|
||||
userId: userId,
|
||||
fields: [ItemFields.MediaSources, ItemFields.MediaStreams],
|
||||
sortOrder: [SortOrder.Ascending],
|
||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||
});
|
||||
break;
|
||||
case BaseItemKind.BoxSet:
|
||||
result = await getItemsApi(api).getItems({
|
||||
parentId: item.Id,
|
||||
userId,
|
||||
fields: [
|
||||
ItemFields.MediaSources,
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.Chapters,
|
||||
ItemFields.Trickplay,
|
||||
],
|
||||
sortOrder: [SortOrder.Ascending],
|
||||
sortBy: ["IndexNumber"],
|
||||
});
|
||||
if (
|
||||
result.data.Items?.[index]?.Id &&
|
||||
result.data.Items?.[index].MediaSources?.[0]?.Id
|
||||
) {
|
||||
if (currentAudioTrack === "auto") {
|
||||
const defaultAudioStreamIndex =
|
||||
result.data.Items?.[index].MediaSources?.[0]
|
||||
.DefaultAudioStreamIndex;
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: Number(defaultAudioStreamIndex),
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items?.[index].Id ?? "",
|
||||
startTimeTicks:
|
||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[index].MediaSources?.[0].Id ?? "",
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: currentAudioTrack,
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: result.data.Items?.[index].Id ?? "",
|
||||
startTimeTicks:
|
||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[index].MediaSources?.[0].Id ?? "",
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BaseItemKind.Photo:
|
||||
{
|
||||
const photo = (
|
||||
await getUserLibraryApi(api).getItem({
|
||||
itemId: item.Id,
|
||||
})
|
||||
).data;
|
||||
result = await getItemsApi(api).getItems({
|
||||
parentId: photo.ParentId ?? "",
|
||||
filters: [ItemFilter.IsNotFolder],
|
||||
recursive: false,
|
||||
sortBy: ["SortName"],
|
||||
mediaTypes: ["Photo"],
|
||||
excludeLocationTypes: [LocationType.Virtual],
|
||||
collapseBoxSetItems: false,
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = await getItemsApi(api).getItems({
|
||||
ids: [item.Id ?? ""],
|
||||
userId: userId,
|
||||
fields: [
|
||||
ItemFields.MediaSources,
|
||||
ItemFields.MediaStreams,
|
||||
ItemFields.Chapters,
|
||||
ItemFields.Trickplay,
|
||||
],
|
||||
sortOrder: [SortOrder.Ascending],
|
||||
sortBy: ["IndexNumber"],
|
||||
});
|
||||
if (currentAudioTrack === "auto") {
|
||||
const defaultAudioStreamIndex =
|
||||
result.data.Items?.[index].MediaSources?.[0]
|
||||
.DefaultAudioStreamIndex;
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: Number(defaultAudioStreamIndex),
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: item.Id ?? "",
|
||||
startTimeTicks:
|
||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[0].MediaSources?.[0]?.Id ?? "",
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
||||
audioStreamIndex: currentAudioTrack,
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: item.Id ?? "",
|
||||
startTimeTicks:
|
||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId:
|
||||
result.data.Items?.[0].MediaSources?.[0]?.Id ?? "",
|
||||
playbackInfoDto: {
|
||||
DeviceProfile: playbackProfile,
|
||||
},
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
item: result?.data,
|
||||
mediaSource: mediaSource?.data,
|
||||
introInfo,
|
||||
episodeIndex: index,
|
||||
};
|
||||
return await getPlaybackInfo(api, userId, item, {
|
||||
currentAudioTrack,
|
||||
currentSubTrack,
|
||||
currentEpisodeId,
|
||||
playlistItem,
|
||||
playlistItemId,
|
||||
});
|
||||
},
|
||||
onSuccess: (result: PlayResult | null) => {
|
||||
onSuccess: async (result: PlayResult | null) => {
|
||||
if (!api) {
|
||||
console.error("API is not available");
|
||||
enqueueSnackbar("API is not available", { variant: "error" });
|
||||
@@ -474,87 +153,39 @@ const PlayButton = ({
|
||||
return;
|
||||
}
|
||||
const episodeIndex = result.episodeIndex;
|
||||
const queue = result?.item?.Items ?? [];
|
||||
|
||||
// Creates a queue containing all Episodes for a particular season(series) or collection of movies
|
||||
const queue = result?.item?.Items;
|
||||
|
||||
let itemName = item.Name;
|
||||
let episodeTitle = "";
|
||||
if (result?.item?.Items?.[episodeIndex].SeriesId) {
|
||||
itemName = result?.item.Items[episodeIndex].SeriesName;
|
||||
episodeTitle = `S${result?.item.Items[episodeIndex].ParentIndexNumber ?? 0}:E${
|
||||
result?.item.Items[episodeIndex].IndexNumber ?? 0
|
||||
} ${result?.item.Items[episodeIndex].Name}`;
|
||||
}
|
||||
|
||||
if (itemType === "BoxSet") {
|
||||
itemName = result.item.Items[0].Name;
|
||||
}
|
||||
|
||||
// Subtitle
|
||||
const subtitle = getSubtitle(
|
||||
result.mediaSource.MediaSources?.[0].DefaultSubtitleStreamIndex ?? -1,
|
||||
result?.mediaSource?.MediaSources?.[0]?.MediaStreams,
|
||||
);
|
||||
|
||||
// Audio
|
||||
const audio = {
|
||||
track:
|
||||
result.mediaSource.MediaSources?.[0].DefaultAudioStreamIndex ?? 0,
|
||||
allTracks: result.mediaSource.MediaSources?.[0].MediaStreams?.filter(
|
||||
(value) => value.Type === "Audio",
|
||||
),
|
||||
};
|
||||
|
||||
// URL generation
|
||||
const urlOptions: URLSearchParams = {
|
||||
//@ts-ignore
|
||||
Static: true,
|
||||
tag: result?.mediaSource.MediaSources?.[0].ETag,
|
||||
mediaSourceId: result?.mediaSource.MediaSources?.[0].Id,
|
||||
deviceId: api?.deviceInfo.id,
|
||||
api_key: api?.accessToken,
|
||||
};
|
||||
const urlParams = new URLSearchParams(urlOptions).toString();
|
||||
let playbackUrl = `${api?.basePath}/Videos/${result?.mediaSource.MediaSources?.[0].Id}/stream.${result?.mediaSource.MediaSources?.[0].Container}?${urlParams}`;
|
||||
if (
|
||||
result?.mediaSource.MediaSources?.[0].SupportsTranscoding &&
|
||||
result?.mediaSource.MediaSources?.[0].TranscodingUrl
|
||||
) {
|
||||
playbackUrl = `${api.basePath}${result.mediaSource.MediaSources[0].TranscodingUrl}`;
|
||||
}
|
||||
let playItemValue = result?.item?.Items?.[episodeIndex];
|
||||
let playItemValue = queue[episodeIndex];
|
||||
if (itemType === BaseItemKind.Movie) {
|
||||
playItemValue = result?.item?.Items?.[0];
|
||||
playItemValue = queue[0];
|
||||
}
|
||||
|
||||
const startPosition =
|
||||
result?.item?.Items?.[episodeIndex].UserData?.PlaybackPositionTicks;
|
||||
if (!playItemValue) {
|
||||
console.error("No item to play found");
|
||||
return;
|
||||
}
|
||||
|
||||
playItem(
|
||||
itemName,
|
||||
episodeTitle,
|
||||
currentVideoTrack ?? 0,
|
||||
Number(result.mediaSource.MediaSources?.[0].DefaultAudioStreamIndex),
|
||||
result?.mediaSource?.MediaSources?.[0].Container ?? "mkv",
|
||||
playbackUrl,
|
||||
userId ?? "",
|
||||
startPosition,
|
||||
result?.item?.Items?.[episodeIndex].RunTimeTicks,
|
||||
playItemValue ?? item,
|
||||
queue,
|
||||
episodeIndex,
|
||||
result?.mediaSource?.MediaSources?.[0]?.Id,
|
||||
result?.mediaSource?.PlaySessionId,
|
||||
subtitle,
|
||||
result?.introInfo,
|
||||
audio,
|
||||
);
|
||||
const startPosition = playItemValue.UserData?.PlaybackPositionTicks;
|
||||
|
||||
initializePlayback({
|
||||
api,
|
||||
userId,
|
||||
item: playItemValue,
|
||||
mediaSource: result.mediaSource,
|
||||
mediaSegments: result.mediaSegments,
|
||||
queueItems: queue,
|
||||
queueIndex: episodeIndex,
|
||||
startPositionTicks: startPosition,
|
||||
audioStreamIndex:
|
||||
currentAudioTrack === "auto" ? undefined : currentAudioTrack,
|
||||
subtitleStreamIndex:
|
||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
});
|
||||
navigate({ to: "/player" });
|
||||
}
|
||||
},
|
||||
onSettled: () => {
|
||||
setPlaybackDataLoading(false);
|
||||
// setPlaybackDataLoading(false);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
@@ -570,70 +201,81 @@ const PlayButton = ({
|
||||
e.stopPropagation();
|
||||
itemQuery.mutate(currentEpisodeId);
|
||||
};
|
||||
const currentEpisode = useQuery({
|
||||
queryKey: ["playButton", "currentEpisode", item?.Id],
|
||||
queryFn: async () => {
|
||||
if (!api) {
|
||||
throw new Error("API is not available");
|
||||
}
|
||||
if (!userId) {
|
||||
throw new Error("User ID is not available");
|
||||
}
|
||||
if (!item.Id) {
|
||||
throw new Error("Item ID is not available");
|
||||
}
|
||||
const seasons = await getTvShowsApi(api).getSeasons({
|
||||
seriesId: item.Id,
|
||||
userId: userId,
|
||||
enableUserData: true,
|
||||
});
|
||||
|
||||
const currentSeason = seasons.data.Items?.find((season) => {
|
||||
return season.UserData?.Played !== true;
|
||||
});
|
||||
|
||||
const episode = await getNextEpisode(
|
||||
api,
|
||||
userId,
|
||||
item.Id,
|
||||
currentSeason?.IndexNumber ?? 0,
|
||||
);
|
||||
if (episode) {
|
||||
return { Items: [episode] };
|
||||
}
|
||||
return { Items: [] };
|
||||
},
|
||||
enabled: itemType === BaseItemKind.Series,
|
||||
});
|
||||
|
||||
if (iconOnly) {
|
||||
return (
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
<Fab
|
||||
color="primary"
|
||||
aria-label="Play"
|
||||
className={className}
|
||||
onClick={(e) =>
|
||||
item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e)
|
||||
}
|
||||
onClick={(e) => {
|
||||
if (item.Type === "Episode") {
|
||||
handleClick(e, item.Id);
|
||||
} else if (itemType === BaseItemKind.Series) {
|
||||
handleClick(e, currentEpisode.data?.Items?.[0]?.Id);
|
||||
} else {
|
||||
handleClick(e);
|
||||
}
|
||||
}}
|
||||
sx={sx}
|
||||
size={size}
|
||||
disabled={
|
||||
itemType === BaseItemKind.Series &&
|
||||
(!currentEpisode.data ||
|
||||
!currentEpisode.data.Items ||
|
||||
currentEpisode.data.Items.length === 0)
|
||||
}
|
||||
{...buttonProps}
|
||||
>
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded em-4 fill"
|
||||
style={{
|
||||
fontSize: "3em",
|
||||
}}
|
||||
>
|
||||
play_arrow
|
||||
</div>
|
||||
</span>
|
||||
</Fab>
|
||||
);
|
||||
}
|
||||
|
||||
if (itemType === BaseItemKind.Series) {
|
||||
const currentEpisode = useQuery({
|
||||
queryKey: ["playButton", "currentEpisode", item?.Id],
|
||||
queryFn: async () => {
|
||||
if (!api) {
|
||||
throw new Error("API is not available");
|
||||
}
|
||||
if (!userId) {
|
||||
throw new Error("User ID is not available");
|
||||
}
|
||||
if (!item.Id) {
|
||||
throw new Error("Item ID is not available");
|
||||
}
|
||||
let data: BaseItemDtoQueryResult | null = null;
|
||||
const continueWatching = await getItemsApi(api).getResumeItems({
|
||||
userId: userId,
|
||||
limit: 1,
|
||||
mediaTypes: ["Video"],
|
||||
parentId: item.Id,
|
||||
enableUserData: true,
|
||||
fields: [ItemFields.MediaStreams, ItemFields.MediaSources],
|
||||
});
|
||||
const nextUp = await getTvShowsApi(api).getNextUp({
|
||||
userId: userId,
|
||||
parentId: item.Id,
|
||||
limit: 1,
|
||||
});
|
||||
if ((continueWatching.data.Items?.length ?? 0) > 0) {
|
||||
data = continueWatching.data;
|
||||
} else if ((nextUp.data.Items?.length ?? 0) > 0) {
|
||||
data = nextUp.data;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return data;
|
||||
},
|
||||
// enabled: itemType === BaseItemKind.Series,
|
||||
});
|
||||
return (
|
||||
<div
|
||||
className="play-button"
|
||||
@@ -642,13 +284,18 @@ const PlayButton = ({
|
||||
position: "relative",
|
||||
}}
|
||||
>
|
||||
<LoadingButton
|
||||
<Button
|
||||
loading={currentEpisode.isPending}
|
||||
className={className ?? "play-button"}
|
||||
variant="contained"
|
||||
onClick={(e) => handleClick(e, currentEpisode.data?.Items?.[0]?.Id)}
|
||||
onClick={(e) => {
|
||||
const episodeId = currentEpisode.data?.Items?.[0]?.Id;
|
||||
if (episodeId) {
|
||||
handleClick(e, episodeId);
|
||||
}
|
||||
}}
|
||||
startIcon={
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
zIndex: 1,
|
||||
@@ -656,33 +303,50 @@ const PlayButton = ({
|
||||
}}
|
||||
>
|
||||
play_arrow
|
||||
</div>
|
||||
</span>
|
||||
}
|
||||
{...buttonProps}
|
||||
sx={{
|
||||
position: "relative",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
//@ts-ignore - white color is a custom color in the theme which mui's types don't know about
|
||||
//@ts-expect-error - white color is a custom color in the theme which mui's types don't know about
|
||||
color="white"
|
||||
size={size}
|
||||
disabled={
|
||||
currentEpisode.isPending ||
|
||||
!currentEpisode.data ||
|
||||
!currentEpisode.data.Items ||
|
||||
currentEpisode.data.Items.length === 0 ||
|
||||
!currentEpisode.data.Items[0].Id
|
||||
}
|
||||
>
|
||||
Watch S{currentEpisode.data?.Items?.[0].ParentIndexNumber ?? 1}E
|
||||
{currentEpisode.data?.Items?.[0]?.IndexNumber ?? 1}
|
||||
<MemoizedLinearProgress
|
||||
//@ts-ignore
|
||||
value={
|
||||
100 >
|
||||
(currentEpisode.data?.Items?.[0].UserData?.PlayedPercentage ??
|
||||
100) &&
|
||||
(currentEpisode.data?.Items?.[0].UserData?.PlayedPercentage ??
|
||||
0) > 0
|
||||
? currentEpisode.data?.Items?.[0].UserData?.PlayedPercentage
|
||||
: 0
|
||||
}
|
||||
/>
|
||||
</LoadingButton>
|
||||
{(currentEpisode.data?.Items?.[0].UserData?.PlaybackPositionTicks ??
|
||||
{currentEpisode.isPending ? (
|
||||
"Loading..."
|
||||
) : !currentEpisode.data ||
|
||||
!currentEpisode.data.Items ||
|
||||
currentEpisode.data.Items.length === 0 ? (
|
||||
"No episodes to watch found"
|
||||
) : (
|
||||
<>
|
||||
Watch S{currentEpisode.data.Items[0].ParentIndexNumber ?? 1}E
|
||||
{currentEpisode.data.Items[0]?.IndexNumber ?? 1}
|
||||
<MemoizedLinearProgress
|
||||
//@ts-expect-error
|
||||
value={
|
||||
100 >
|
||||
(currentEpisode.data.Items[0].UserData?.PlayedPercentage ??
|
||||
100) &&
|
||||
(currentEpisode.data.Items[0].UserData?.PlayedPercentage ??
|
||||
0) > 0
|
||||
? currentEpisode.data.Items[0].UserData?.PlayedPercentage
|
||||
: 0
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
{(currentEpisode.data?.Items?.[0]?.UserData?.PlaybackPositionTicks ??
|
||||
0) > 0 && (
|
||||
<Typography
|
||||
sx={{
|
||||
@@ -695,8 +359,8 @@ const PlayButton = ({
|
||||
variant="caption"
|
||||
>
|
||||
{getRuntimeCompact(
|
||||
(currentEpisode.data?.Items?.[0].RunTimeTicks ?? 0) -
|
||||
(currentEpisode.data?.Items?.[0].UserData
|
||||
(currentEpisode.data?.Items?.[0]?.RunTimeTicks ?? 0) -
|
||||
(currentEpisode.data?.Items?.[0]?.UserData
|
||||
?.PlaybackPositionTicks ?? 0),
|
||||
)}{" "}
|
||||
left
|
||||
@@ -720,7 +384,7 @@ const PlayButton = ({
|
||||
item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e)
|
||||
}
|
||||
startIcon={
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
zIndex: 1,
|
||||
@@ -728,14 +392,14 @@ const PlayButton = ({
|
||||
}}
|
||||
>
|
||||
play_arrow
|
||||
</div>
|
||||
</span>
|
||||
}
|
||||
{...buttonProps}
|
||||
sx={{
|
||||
position: "relative",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
//@ts-ignore - white color is a custom color in the theme which mui's types don't know about
|
||||
//@ts-expect-error - white color is a custom color in the theme which mui's types don't know about
|
||||
color="white"
|
||||
size={size}
|
||||
>
|
||||
@@ -749,7 +413,7 @@ const PlayButton = ({
|
||||
? "Play Now"
|
||||
: "Watch Now"}
|
||||
<MemoizedLinearProgress
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
value={
|
||||
100 > (item.UserData?.PlayedPercentage ?? 100) &&
|
||||
(item.UserData?.PlayedPercentage ?? 0) > 0
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
$image-size: 5em;
|
||||
|
||||
.queue{
|
||||
&-item{
|
||||
--image-size: 5em;
|
||||
&.episode {
|
||||
--image-size: 8em !important;
|
||||
}
|
||||
width: 32em;
|
||||
padding: 1em;
|
||||
display: grid !important;
|
||||
opacity: 1 !important;
|
||||
gap: 1em;
|
||||
height: 5em;
|
||||
grid-template-columns: 3em $image-size 1fr;
|
||||
grid-template-columns: 3em var(--image-size) 1fr;
|
||||
justify-items: center;
|
||||
align-items: center;
|
||||
&-image{
|
||||
@@ -25,6 +27,7 @@ $image-size: 5em;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
width: var(--image-size);
|
||||
}
|
||||
&-icon {
|
||||
width: 100%;
|
||||
@@ -51,5 +54,6 @@ $image-size: 5em;
|
||||
.queue-item-image,.queue-item-image-icon{
|
||||
opacity: 0.5 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,288 +1,382 @@
|
||||
import { playItemFromQueue } from "@/utils/store/playback";
|
||||
import useQueue from "@/utils/store/queue";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import {
|
||||
Box,
|
||||
Drawer,
|
||||
IconButton,
|
||||
Menu,
|
||||
MenuItem,
|
||||
MenuList,
|
||||
List,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
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 getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
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";
|
||||
const QueueButton = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
import QueueListItem from "../queueListItem";
|
||||
|
||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||
state.tracks,
|
||||
state.currentItemIndex,
|
||||
]);
|
||||
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 user = useQuery({
|
||||
queryKey: ["user"],
|
||||
queryFn: async () => {
|
||||
if (!api) return;
|
||||
const result = await getUserApi(api).getCurrentUser();
|
||||
return result.data;
|
||||
},
|
||||
});
|
||||
const [buttonEl, setButtonEl] = useState<HTMLButtonElement | null>(null);
|
||||
|
||||
const handlePlay = useMutation({
|
||||
mutationKey: ["handlePlayIndex"],
|
||||
mutationFn: async ({ index }: { index: number }) => {
|
||||
const result = playItemFromQueue(index, user.data?.Id, api);
|
||||
return result;
|
||||
},
|
||||
onSuccess: () => {
|
||||
setButtonEl(null);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
},
|
||||
});
|
||||
const style = {
|
||||
transform: CSS.Transform.toString(transform),
|
||||
transition,
|
||||
opacity: isDragging ? 0.5 : 1,
|
||||
position: "relative" as const,
|
||||
zIndex: isDragging ? 2 : 1,
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Menu
|
||||
open={Boolean(buttonEl)}
|
||||
onClose={() => setButtonEl(null)}
|
||||
anchorEl={buttonEl}
|
||||
anchorOrigin={{
|
||||
vertical: "top",
|
||||
horizontal: "center",
|
||||
}}
|
||||
transformOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "center",
|
||||
}}
|
||||
slotProps={{
|
||||
paper: {
|
||||
style: {
|
||||
maxHeight: "30em",
|
||||
overflowX: "hidden",
|
||||
overflowY: "auto",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<MenuList
|
||||
style={{
|
||||
height: "fit-content",
|
||||
width: " 32em",
|
||||
position: "relative",
|
||||
}}
|
||||
>
|
||||
{queueItems?.[currentItemIndex]?.Id && (
|
||||
<>
|
||||
<Typography px="1em" mb={2} variant="h5" fontWeight={300}>
|
||||
Currently Playing:
|
||||
</Typography>
|
||||
<MenuItem
|
||||
className="queue-item"
|
||||
disabled
|
||||
key={queueItems[currentItemIndex].Id}
|
||||
<div ref={setNodeRef} style={style}>
|
||||
<QueueListItem
|
||||
queueItem={item}
|
||||
onDelete={onDelete}
|
||||
onPlay={onPlay}
|
||||
dragHandleProps={{ ...attributes, ...listeners }}
|
||||
isEpisode={item.Type === "Episode"}
|
||||
index={index}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const QueueButton = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||
state.tracks,
|
||||
state.currentItemIndex,
|
||||
]);
|
||||
|
||||
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 (
|
||||
<>
|
||||
<Drawer
|
||||
anchor="right"
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
PaperProps={{
|
||||
className: "glass",
|
||||
sx: {
|
||||
width: 450,
|
||||
maxWidth: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
borderLeft: "1px solid rgba(255, 255, 255, 0.08)",
|
||||
},
|
||||
}}
|
||||
ModalProps={{
|
||||
BackdropProps: {
|
||||
sx: {
|
||||
backgroundColor: "rgba(0, 0, 0, 0.2)",
|
||||
backdropFilter: "blur(4px)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
p={3}
|
||||
display="flex"
|
||||
justifyContent="space-between"
|
||||
alignItems="center"
|
||||
sx={{
|
||||
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)",
|
||||
}}
|
||||
>
|
||||
<Typography variant="subtitle2">
|
||||
{queueItems[currentItemIndex]?.Type === "Audio"
|
||||
? currentItemIndex + 1
|
||||
: queueItems[currentItemIndex].IndexNumberEnd
|
||||
? `S${queueItems[currentItemIndex].ParentIndexNumber}:E${queueItems[currentItemIndex].IndexNumber} / ${queueItems[currentItemIndex].IndexNumberEnd}`
|
||||
: `S${queueItems[currentItemIndex].ParentIndexNumber}:E${queueItems[currentItemIndex].IndexNumber}`}
|
||||
</Typography>
|
||||
<div className="queue-item-image-container">
|
||||
{queueItems[currentItemIndex].ImageTags?.Primary ? (
|
||||
<img
|
||||
className="queue-item-image"
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
queueItems[currentItemIndex]?.Id,
|
||||
"Primary",
|
||||
{
|
||||
tag: queueItems[currentItemIndex].ImageTags
|
||||
?.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
alt={queueItems[currentItemIndex].Name ?? "image"}
|
||||
/>
|
||||
) : (queueItems[currentItemIndex].AlbumPrimaryImageTag
|
||||
?.length ?? -1) > 0 ? (
|
||||
<img
|
||||
className="queue-item-image"
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
queueItems?.[currentItemIndex]?.AlbumId ?? "",
|
||||
"Primary",
|
||||
{
|
||||
tag: queueItems?.[currentItemIndex]
|
||||
.AlbumPrimaryImageTag?.[0],
|
||||
},
|
||||
)
|
||||
}
|
||||
alt={queueItems[currentItemIndex].Name ?? "image"}
|
||||
/>
|
||||
) : (
|
||||
<div className="queue-item-image-icon">
|
||||
{queueItems[currentItemIndex].Type &&
|
||||
getTypeIcon(queueItems[currentItemIndex].Type)}
|
||||
</div>
|
||||
)}
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: "50%",
|
||||
left: "50%",
|
||||
transform: "translate(-50%,-50%)",
|
||||
fontSize: "2em",
|
||||
//@ts-ignore
|
||||
"--wght": "100",
|
||||
<Box display="flex" alignItems="center" gap={1}>
|
||||
<Typography variant="h5" fontWeight="bold">
|
||||
Play Queue
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
color="text.secondary"
|
||||
sx={{
|
||||
ml: 1,
|
||||
fontWeight: 600,
|
||||
bgcolor: "rgba(255, 255, 255, 0.08)",
|
||||
px: 1,
|
||||
py: 0.5,
|
||||
borderRadius: 2,
|
||||
}}
|
||||
>
|
||||
equalizer
|
||||
</span>
|
||||
</div>
|
||||
<div className="queue-item-info">
|
||||
{queueItems[currentItemIndex].SeriesName ? (
|
||||
<>
|
||||
<Typography variant="subtitle1" width="100%">
|
||||
{queueItems[currentItemIndex].SeriesName}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
width="100%"
|
||||
style={{ opacity: 0.6 }}
|
||||
>
|
||||
{queueItems[currentItemIndex].Name}
|
||||
</Typography>
|
||||
</>
|
||||
) : (
|
||||
<Typography variant="subtitle1" width="100%">
|
||||
{queueItems[currentItemIndex].Name}
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
</MenuItem>
|
||||
</>
|
||||
)}
|
||||
{queueItems &&
|
||||
queueItems.slice(currentItemIndex + 1, queueItems.length - 1)
|
||||
.length > 0 && (
|
||||
<Typography px="1em" my={2} variant="h5" fontWeight={300}>
|
||||
Queue:
|
||||
</Typography>
|
||||
)}
|
||||
{queueItems
|
||||
?.slice(currentItemIndex + 1, queueItems.length - 1)
|
||||
.map((item, index) => {
|
||||
return (
|
||||
<MenuItem
|
||||
className="queue-item"
|
||||
onClick={() =>
|
||||
handlePlay.mutate({ index: index + currentItemIndex })
|
||||
}
|
||||
key={item.Id}
|
||||
>
|
||||
<Typography variant="subtitle2">
|
||||
{item.Type === "Audio"
|
||||
? index + 1
|
||||
: item.IndexNumberEnd
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} / ${item.IndexNumberEnd}`
|
||||
: `S${item.ParentIndexNumber}:E${item.IndexNumber}`}
|
||||
{queueItems?.length || 0}
|
||||
</Typography>
|
||||
<div className="queue-item-image-container">
|
||||
{item.ImageTags?.Primary ? (
|
||||
<img
|
||||
className="queue-item-image"
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item?.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
tag: item.ImageTags?.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
alt={item.Name ?? "image"}
|
||||
/>
|
||||
) : (item.AlbumPrimaryImageTag?.length ?? -1) > 0 ? (
|
||||
<img
|
||||
className="queue-item-image"
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item?.AlbumId ?? "",
|
||||
"Primary",
|
||||
{
|
||||
tag: item.AlbumPrimaryImageTag?.[0],
|
||||
},
|
||||
)
|
||||
}
|
||||
alt={item.Name ?? "image"}
|
||||
/>
|
||||
) : (
|
||||
<div className="queue-item-image-icon">
|
||||
{item.Type && getTypeIcon(item.Type)}
|
||||
</div>
|
||||
</Box>
|
||||
<Box 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>
|
||||
)}
|
||||
</div>
|
||||
<div className="queue-item-info">
|
||||
{item.SeriesName ? (
|
||||
|
||||
{/* Upcoming Items */}
|
||||
{upcomingItems.length > 0 && (
|
||||
<>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
width="100%"
|
||||
sx={{ overflow: "hidden", textOverflow: "ellipsis" }}
|
||||
variant="overline"
|
||||
sx={{
|
||||
display: "block",
|
||||
opacity: 0.6,
|
||||
mb: 1,
|
||||
fontWeight: 600,
|
||||
letterSpacing: 1.2,
|
||||
}}
|
||||
>
|
||||
{item.SeriesName}
|
||||
NEXT UP
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
width="100%"
|
||||
style={{ opacity: 0.6 }}
|
||||
<DndContext
|
||||
sensors={sensors}
|
||||
collisionDetection={closestCenter}
|
||||
onDragEnd={handleDragEnd}
|
||||
modifiers={[restrictToVerticalAxis]}
|
||||
>
|
||||
{item.Name}
|
||||
</Typography>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
width="100%"
|
||||
sx={{ overflow: "hidden", textOverflow: "ellipsis" }}
|
||||
>
|
||||
{item.Name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
width="100%"
|
||||
style={{ opacity: 0.6 }}
|
||||
sx={{ overflow: "hidden", textOverflow: "ellipsis" }}
|
||||
>
|
||||
{item.Artists?.join(", ")}
|
||||
</Typography>
|
||||
<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>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</MenuList>
|
||||
</Menu>
|
||||
<IconButton onClick={(e) => setButtonEl(e.currentTarget)}>
|
||||
<span className="material-symbols-rounded">playlist_play</span>
|
||||
</IconButton>
|
||||
</>
|
||||
);
|
||||
</List>
|
||||
) : (
|
||||
<Box
|
||||
p={4}
|
||||
textAlign="center"
|
||||
display="flex"
|
||||
flexDirection="column"
|
||||
alignItems="center"
|
||||
gap={2}
|
||||
sx={{ opacity: 0.5 }}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: 48 }}
|
||||
>
|
||||
queue_music
|
||||
</span>
|
||||
<Typography>Your queue is empty</Typography>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Drawer>
|
||||
<IconButton onClick={() => setOpen(true)}>
|
||||
<span className="material-symbols-rounded">playlist_play</span>
|
||||
</IconButton>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default QueueButton;
|
||||
@@ -1,6 +1,3 @@
|
||||
import useInterval from "@/utils/hooks/useInterval";
|
||||
import { saveUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { LoadingButton, type LoadingButtonProps } from "@mui/lab";
|
||||
@@ -22,6 +19,9 @@ import { useNavigate } from "@tanstack/react-router";
|
||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React, { useCallback, useState } from "react";
|
||||
import useInterval from "@/utils/hooks/useInterval";
|
||||
import { saveUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
|
||||
const Transition = React.forwardRef(function Transition(
|
||||
props: TransitionProps & {
|
||||
@@ -185,6 +185,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
||||
fullWidth
|
||||
maxWidth="xs"
|
||||
TransitionComponent={Transition}
|
||||
PaperProps={{ className: "glass", sx: { borderRadius: "24px" } }}
|
||||
>
|
||||
<DialogContent
|
||||
style={{
|
||||
|
||||
@@ -23,6 +23,7 @@ const TrailerButton = (props: TrailerButtonType) => {
|
||||
fullWidth
|
||||
open={dialog}
|
||||
PaperProps={{
|
||||
className: "glass",
|
||||
style: {
|
||||
overflow: "hidden",
|
||||
},
|
||||
|
||||
@@ -82,12 +82,13 @@
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
opacity: 0;
|
||||
transition: opacity $transition-time-default;
|
||||
transition: all $transition-time-default;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-end;
|
||||
padding: 0.5em;
|
||||
background: rgb(0 0 0 / 0.6);
|
||||
background: rgba(20, 20, 30, 0.6);
|
||||
backdrop-filter: blur(12px);
|
||||
}
|
||||
&:hover,
|
||||
&:focus,
|
||||
|
||||
@@ -1,41 +1,23 @@
|
||||
/** @format */
|
||||
|
||||
import React, { memo } from "react";
|
||||
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
type ImageType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import React, { memo, type Ref, useCallback, useState } from "react";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { useInView } from "react-intersection-observer";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
import PlayButton from "../buttons/playButton";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
import "./card.scss";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
|
||||
import { useInView } from "react-intersection-observer";
|
||||
|
||||
const CardComponent = ({
|
||||
item,
|
||||
cardTitle,
|
||||
cardCaption,
|
||||
imageType = "Primary",
|
||||
cardType = "square",
|
||||
queryKey,
|
||||
userId,
|
||||
seriesId,
|
||||
hideText = false,
|
||||
onClick,
|
||||
disableOverlay = false,
|
||||
overrideIcon,
|
||||
}: {
|
||||
interface CardProps {
|
||||
item: BaseItemDto;
|
||||
cardTitle: string | undefined | null;
|
||||
cardCaption?: string | null | number;
|
||||
@@ -48,10 +30,32 @@ const CardComponent = ({
|
||||
onClick?: () => void;
|
||||
disableOverlay?: boolean;
|
||||
overrideIcon?: any;
|
||||
skipInView?: boolean;
|
||||
}
|
||||
|
||||
const CardContent = ({
|
||||
item,
|
||||
cardTitle,
|
||||
cardCaption,
|
||||
imageType = "Primary",
|
||||
cardType = "square",
|
||||
queryKey,
|
||||
userId,
|
||||
seriesId,
|
||||
hideText = false,
|
||||
onClick,
|
||||
disableOverlay = false,
|
||||
overrideIcon,
|
||||
inView,
|
||||
forwardedRef,
|
||||
}: CardProps & {
|
||||
inView: boolean;
|
||||
forwardedRef?: Ref<HTMLDivElement>;
|
||||
}) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const navigate = useNavigate();
|
||||
const defaultOnClick = () => {
|
||||
|
||||
const defaultOnClick = useCallback(() => {
|
||||
if (item?.Id) {
|
||||
switch (item?.Type) {
|
||||
case BaseItemKind.BoxSet:
|
||||
@@ -80,20 +84,16 @@ const CardComponent = ({
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const { ref, inView } = useInView({
|
||||
threshold: 0,
|
||||
});
|
||||
}, [item?.Id, item?.Type, navigate]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="card"
|
||||
ref={ref}
|
||||
onClick={onClick ? onClick : defaultOnClick}
|
||||
ref={forwardedRef}
|
||||
onClick={onClick || defaultOnClick}
|
||||
>
|
||||
<div className={`card-image-container ${cardType}`}>
|
||||
<ErrorBoundary fallback>
|
||||
<ErrorBoundary fallback={<></>}>
|
||||
<div
|
||||
className="card-indicator check"
|
||||
style={{
|
||||
@@ -108,13 +108,17 @@ const CardComponent = ({
|
||||
opacity: item.UserData?.UnplayedItemCount ? 1 : 0,
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
padding="0.1em 0.4em"
|
||||
fontWeight={400}
|
||||
<span
|
||||
style={{
|
||||
padding: "0.1em 0.4em",
|
||||
fontWeight: 400,
|
||||
fontSize: "0.875rem",
|
||||
lineHeight: 1.57,
|
||||
fontFamily: "inherit",
|
||||
}}
|
||||
>
|
||||
{item.UserData?.UnplayedItemCount}
|
||||
</Typography>
|
||||
</span>
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
<div className="card-image-icon-container">
|
||||
@@ -144,25 +148,22 @@ const CardComponent = ({
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
opacity: 0,
|
||||
display: "block",
|
||||
transition: "opacity 0.3s ease-in-out",
|
||||
}}
|
||||
loading="lazy"
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.setProperty("opacity", "1");
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
onLoadStart={(e) => console.log(e)}
|
||||
className="card-image"
|
||||
/>
|
||||
)}
|
||||
|
||||
{inView && !disableOverlay && (
|
||||
<div className="card-overlay">
|
||||
<PlayButton
|
||||
item={item}
|
||||
userId={userId}
|
||||
itemType={item.Type ?? "Movie"}
|
||||
currentAudioTrack="auto"
|
||||
currentSubTrack={-1}
|
||||
currentVideoTrack={0}
|
||||
className="card-play-button"
|
||||
iconOnly
|
||||
audio={
|
||||
@@ -203,22 +204,50 @@ const CardComponent = ({
|
||||
</div>
|
||||
<div
|
||||
className="card-text-container"
|
||||
style={{ display: hideText ? "none" : "block" }}
|
||||
style={{ display: hideText ? "none" : "block", marginLeft: "0.2em" }}
|
||||
>
|
||||
<Typography mt={1} variant="subtitle2" noWrap style={{ opacity: 0.9 }}>
|
||||
<div
|
||||
style={{
|
||||
marginTop: "8px",
|
||||
opacity: 0.9,
|
||||
fontSize: "0.875rem",
|
||||
fontWeight: 500,
|
||||
whiteSpace: "nowrap",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
}}
|
||||
>
|
||||
{cardTitle}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
noWrap
|
||||
style={{ opacity: 0.6 }}
|
||||
lineHeight="auto"
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
opacity: 0.6,
|
||||
fontSize: "0.75rem",
|
||||
whiteSpace: "nowrap",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
}}
|
||||
>
|
||||
{cardCaption}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const CardWithInView = (props: CardProps) => {
|
||||
const { ref, inView } = useInView({
|
||||
threshold: 0.1,
|
||||
});
|
||||
|
||||
return <CardContent {...props} inView={inView} forwardedRef={ref} />;
|
||||
};
|
||||
|
||||
const CardComponent = (props: CardProps) => {
|
||||
if (props.skipInView) {
|
||||
return <CardContent {...props} inView={true} />;
|
||||
}
|
||||
return <CardWithInView {...props} />;
|
||||
};
|
||||
|
||||
export const Card = memo(CardComponent);
|
||||
@@ -1,51 +1,82 @@
|
||||
@use "@/styles/variables.scss" as *;
|
||||
|
||||
.card-scroller-container {
|
||||
margin-bottom: 2.5em;
|
||||
position: relative;
|
||||
|
||||
// Ensure the container handles overflow if needed, but usually Carousel handles it
|
||||
}
|
||||
|
||||
.card-scroller {
|
||||
// height: 20em;
|
||||
// Override carousel default outline
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&-slide {
|
||||
overflow: visible;
|
||||
display: flex;
|
||||
}
|
||||
&-button {
|
||||
position: absolute !important;
|
||||
height: 100%;
|
||||
font-size: 1em !important;
|
||||
width: $page-margin;
|
||||
&.right{
|
||||
border-radius: $border-radius-default 0 0 $border-radius-default !important;
|
||||
right: -$page-margin;
|
||||
}
|
||||
&.left{
|
||||
border-radius: 0 $border-radius-default $border-radius-default 0 !important;
|
||||
left: -$page-margin;
|
||||
}
|
||||
.material-symbols-rounded{
|
||||
font-size: 3.2em;
|
||||
--wght: 200;
|
||||
--opsz: 48;
|
||||
}
|
||||
padding-right: 0.5em; // Gap between cards (handled by slide padding instead of gap for carousel)
|
||||
// With react-multi-carousel, better to rely on their gap logic or item class
|
||||
}
|
||||
|
||||
&-item {
|
||||
padding-right: 0.6em; // Consistent gap
|
||||
}
|
||||
|
||||
&-header-container {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1em;
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
&-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 0.35em;
|
||||
gap: 0.5em;
|
||||
position: relative;
|
||||
margin-bottom: 0.25em !important;
|
||||
font-weight: 600 !important;
|
||||
|
||||
&-decoration {
|
||||
width: 0.75em;
|
||||
height: 2px;
|
||||
background: white;
|
||||
width: 4px;
|
||||
height: 24px;
|
||||
background: $clr-accent-default;
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
&-container .MuiButtonGroup-outlined{
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
&-controls {
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
|
||||
.scroller-nav-btn {
|
||||
background-color: rgba(255, 255, 255, 0.05);
|
||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
transition: all 0.2s ease;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
color: #fff;
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
// Disabled state
|
||||
&.Mui-disabled {
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.hidden-decoration {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { type ReactNode } from "react";
|
||||
|
||||
import React, { type ReactNode, useRef, useState } from "react";
|
||||
import Carousel from "react-multi-carousel";
|
||||
import "react-multi-carousel/lib/styles.css";
|
||||
|
||||
@@ -8,24 +7,54 @@ import Typography from "@mui/material/Typography";
|
||||
|
||||
import "./cardScroller.scss";
|
||||
|
||||
//@ts-ignore - I don't know the prop type for react-multi-carousel's customRightArrow and customLeftArrow
|
||||
function RightButton(props) {
|
||||
const { carouselState, children, rtl, ...restProps } = props;
|
||||
// Custom Header + Button Group component
|
||||
const ScrollerHeader = ({
|
||||
onNext,
|
||||
onPrevious,
|
||||
title,
|
||||
headingProps,
|
||||
disableDecoration,
|
||||
currentSlide = 0,
|
||||
isNextDisabled = false,
|
||||
}: any) => {
|
||||
// Basic disable logic for visual feedback
|
||||
const isFirst = currentSlide === 0;
|
||||
|
||||
return (
|
||||
<IconButton className="card-scroller-button right" {...restProps}>
|
||||
<div className="material-symbols-rounded">chevron_right</div>
|
||||
</IconButton>
|
||||
<div
|
||||
className={`card-scroller-header-container ${disableDecoration ? "hidden-decoration" : ""}`}
|
||||
>
|
||||
<Typography
|
||||
variant="h5"
|
||||
color="textPrimary"
|
||||
className="card-scroller-heading"
|
||||
{...headingProps}
|
||||
>
|
||||
<div className="card-scroller-heading-decoration" />
|
||||
{title}
|
||||
</Typography>
|
||||
|
||||
<div className="card-scroller-controls">
|
||||
<IconButton
|
||||
onClick={onPrevious}
|
||||
disabled={isFirst}
|
||||
size="small"
|
||||
className="scroller-nav-btn"
|
||||
>
|
||||
<span className="material-symbols-rounded">chevron_left</span>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
onClick={onNext}
|
||||
disabled={isNextDisabled}
|
||||
size="small"
|
||||
className="scroller-nav-btn"
|
||||
>
|
||||
<span className="material-symbols-rounded">chevron_right</span>
|
||||
</IconButton>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
//@ts-ignore - I don't know the prop type for react-multi-carousel's customRightArrow and customLeftArrow
|
||||
function LeftButton(props) {
|
||||
const { carouselState, children, rtl, ...restProps } = props;
|
||||
return (
|
||||
<IconButton className="card-scroller-button left" {...restProps}>
|
||||
<div className="material-symbols-rounded">chevron_left</div>
|
||||
</IconButton>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
type CardScrollerProps = {
|
||||
children: ReactNode;
|
||||
@@ -44,9 +73,13 @@ export default function CardScroller({
|
||||
disableDecoration = false,
|
||||
boxProps,
|
||||
}: CardScrollerProps) {
|
||||
const carouselRef = useRef<any>(null);
|
||||
const [currentSlide, setCurrentSlide] = useState(0);
|
||||
const [slidesToShow, setSlidesToShow] = useState(displayCards);
|
||||
const totalItems = React.Children.count(children);
|
||||
|
||||
const responsive = {
|
||||
superLargeDesktop: {
|
||||
// the naming can be any, depends on you.
|
||||
breakpoint: { max: 4000, min: 3000 },
|
||||
items: displayCards + 1,
|
||||
slidesToSlide: displayCards + 1,
|
||||
@@ -55,62 +88,67 @@ export default function CardScroller({
|
||||
desktop: {
|
||||
breakpoint: { max: 3000, min: 925 },
|
||||
items: displayCards,
|
||||
slidesToSlide: displayCards, // optional, default to 1.
|
||||
slidesToSlide: displayCards,
|
||||
partialVisibilityGutter: 30,
|
||||
},
|
||||
tablet: {
|
||||
breakpoint: { max: 925, min: 600 },
|
||||
items: displayCards - 3,
|
||||
slidesToSlide: displayCards - 3, // optional, default to 1.
|
||||
slidesToSlide: displayCards - 3,
|
||||
partialVisibilityGutter: 20,
|
||||
},
|
||||
mobile: {
|
||||
breakpoint: { max: 600, min: 424 },
|
||||
items: displayCards - 5,
|
||||
slidesToSlide: displayCards - 5, // optional, default to 1.
|
||||
slidesToSlide: displayCards - 5,
|
||||
partialVisibilityGutter: 10,
|
||||
},
|
||||
smallScreen: {
|
||||
breakpoint: { max: 424, min: 0 },
|
||||
items: 1,
|
||||
slidesToSlide: 1, // optional, default to 1.
|
||||
slidesToSlide: 1,
|
||||
partialVisibilityGutter: 10,
|
||||
},
|
||||
};
|
||||
|
||||
const handleNext = () => {
|
||||
if (carouselRef.current) {
|
||||
carouselRef.current.next();
|
||||
}
|
||||
};
|
||||
|
||||
const handlePrevious = () => {
|
||||
if (carouselRef.current) {
|
||||
carouselRef.current.previous();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
{...boxProps}
|
||||
className="card-scroller-container"
|
||||
style={{ marginBottom: "1.2em" }}
|
||||
>
|
||||
<div
|
||||
style={{ marginBottom: "1.2em" }}
|
||||
className={
|
||||
disableDecoration
|
||||
? "card-scroller-header-container hidden-decoration"
|
||||
: "card-scroller-header-container"
|
||||
}
|
||||
>
|
||||
<Typography
|
||||
variant="h5"
|
||||
color="textPrimary"
|
||||
className="card-scroller-heading"
|
||||
{...headingProps}
|
||||
>
|
||||
<div className="card-scroller-heading-decoration" /> {title}
|
||||
</Typography>
|
||||
</div>
|
||||
<div {...boxProps} className="card-scroller-container">
|
||||
<ScrollerHeader
|
||||
title={title}
|
||||
headingProps={headingProps}
|
||||
disableDecoration={disableDecoration}
|
||||
onNext={handleNext}
|
||||
onPrevious={handlePrevious}
|
||||
currentSlide={currentSlide}
|
||||
isNextDisabled={currentSlide + slidesToShow >= totalItems}
|
||||
/>
|
||||
<Carousel
|
||||
ref={carouselRef}
|
||||
swipeable
|
||||
draggable
|
||||
responsive={responsive}
|
||||
arrows
|
||||
arrows={false}
|
||||
className="card-scroller"
|
||||
customTransition="all .6s"
|
||||
transitionDuration={600}
|
||||
customRightArrow={<RightButton />}
|
||||
customLeftArrow={<LeftButton />}
|
||||
customTransition="transform 400ms ease-in-out"
|
||||
transitionDuration={400}
|
||||
containerClass="card-scroller-track"
|
||||
itemClass="card-scroller-item"
|
||||
beforeChange={(nextSlide, state) => {
|
||||
setCurrentSlide(nextSlide);
|
||||
setSlidesToShow(state.slidesToShow);
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</Carousel>
|
||||
|
||||
@@ -1,15 +1,38 @@
|
||||
.carousel {
|
||||
position: relative;
|
||||
height: 64vh;
|
||||
width: calc(100% + 2*$page-margin);
|
||||
left: -$page-margin;
|
||||
margin-bottom: 3.2em;
|
||||
.slider {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
max-width: 35%;
|
||||
right: $page-margin;
|
||||
overflow: visible;
|
||||
height: 65vh;
|
||||
margin-bottom: 3em;
|
||||
display: grid;
|
||||
grid-template-areas: "main sidebar";
|
||||
grid-template-columns: 1fr 340px;
|
||||
gap: 1.5em;
|
||||
|
||||
&-sidebar {
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
@include glass-effect($bg-color: rgba(10, 10, 14, 0.4));
|
||||
border-radius: 24px;
|
||||
grid-area: sidebar;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 12px;
|
||||
gap: 8px;
|
||||
|
||||
// Ensure programmatic scroll respects padding
|
||||
scroll-padding-block: 24px;
|
||||
|
||||
// Hide scrollbar but keep functionality
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
&::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&-button {
|
||||
position: absolute !important;
|
||||
top: 50%;
|
||||
@@ -25,14 +48,102 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-ticker{
|
||||
overflow: hidden;
|
||||
height: 72px;
|
||||
display: flex;
|
||||
padding: 8px;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
position: relative;
|
||||
border-radius: 12px; // Slightly smaller radius to work with the bar
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: rgba(255, 255, 255, 0.08); // Subtle background
|
||||
|
||||
// Vertical Progress Bar
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 4px;
|
||||
background-color: var(--mui-palette-primary-main, #fff);
|
||||
height: 0%;
|
||||
animation: ticker-v-progress 8s linear;
|
||||
}
|
||||
}
|
||||
|
||||
&-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;
|
||||
overflow: hidden;
|
||||
border-radius: 2px;
|
||||
padding: 2px;
|
||||
transition: opacity $transition-time-fast;
|
||||
opacity: 0.5;
|
||||
width: auto;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
opacity: 0.8;
|
||||
@@ -44,29 +155,33 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
&-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
&-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgb(155 155 155 / 0.4);
|
||||
border-radius: 4px;
|
||||
}
|
||||
&-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
&-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgb(155 155 155 / 0.4);
|
||||
border-radius: 4px;
|
||||
}
|
||||
&.active {
|
||||
opacity: 1;
|
||||
|
||||
.material-symbols-rounded {
|
||||
|
||||
--fill: 1;
|
||||
}
|
||||
.material-symbols-rounded {
|
||||
|
||||
--fill: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.carousel-ticker-wrapper {
|
||||
scroll-margin-block: 24px;
|
||||
}
|
||||
|
||||
+110
-119
@@ -1,29 +1,20 @@
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import type { PanInfo } from "framer-motion";
|
||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
||||
import type { MouseEvent, PointerEvent } from "react";
|
||||
import { AnimatePresence } from "motion/react";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { useCarouselStore } from "../../utils/store/carousel";
|
||||
import "./carousel.scss";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import CarouselSlide from "../carouselSlide";
|
||||
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import Slider from "../Slider";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
const swipeConfidenceThreshold = 8000;
|
||||
const swipePower = (offset: number, velocity: number) => {
|
||||
return Math.abs(offset) * velocity;
|
||||
};
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import CarouselSlide from "../carouselSlide";
|
||||
import CarouselTickers from "./tickers";
|
||||
|
||||
// Memoize CarouselSlide to prevent unnecessary re-renders
|
||||
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
||||
|
||||
// Memoize Slider to prevent unnecessary re-renders
|
||||
const MemoizedSlider = React.memo(Slider);
|
||||
|
||||
const Carousel = ({
|
||||
content,
|
||||
onChange,
|
||||
@@ -32,121 +23,121 @@ const Carousel = ({
|
||||
onChange: (currentSlide: number) => void;
|
||||
}) => {
|
||||
const [currentSlide, setCurrentSlide] = useState(0);
|
||||
const [isPaused, setIsPaused] = useState(false);
|
||||
const sidebarRef = React.useRef<HTMLDivElement>(null);
|
||||
const tickerRefs = React.useRef<(HTMLDivElement | null)[]>([]);
|
||||
const currentSlideRef = React.useRef(currentSlide);
|
||||
|
||||
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
||||
|
||||
useEffect(() => {
|
||||
currentSlideRef.current = currentSlide;
|
||||
}, [currentSlide]);
|
||||
|
||||
useEffect(() => {
|
||||
onChange(currentSlide);
|
||||
}, [content[currentSlide]?.Id]);
|
||||
|
||||
// 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);
|
||||
|
||||
// Memoize the content mapping
|
||||
const sliderContent = useMemo(() => {
|
||||
return content.map((item, index) => {
|
||||
return (
|
||||
<motion.div
|
||||
className={
|
||||
currentSlide === index
|
||||
? "carousel-indicator active"
|
||||
: "carousel-indicator"
|
||||
}
|
||||
layout
|
||||
initial={{
|
||||
height: "4.6em",
|
||||
}}
|
||||
whileHover={{
|
||||
height: "5.5em",
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.05,
|
||||
}}
|
||||
key={item.Id}
|
||||
onClick={() => {
|
||||
if (currentSlide > index) {
|
||||
setDirection("left");
|
||||
} else if (currentSlide <= index) {
|
||||
setDirection("right");
|
||||
}
|
||||
setCurrentSlide(index);
|
||||
}}
|
||||
>
|
||||
{item.ImageTags?.Thumb ? (
|
||||
<img
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.Id ?? "",
|
||||
"Thumb",
|
||||
{
|
||||
tag: item.ImageTags.Primary,
|
||||
fillWidth: 300,
|
||||
},
|
||||
)
|
||||
}
|
||||
alt={item.Name ?? "item-image"}
|
||||
className="carousel-indicator-image"
|
||||
/>
|
||||
) : (
|
||||
<div className="carousel-indicator-icon">
|
||||
{getTypeIcon(item.Type ?? "Movie")}
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
);
|
||||
});
|
||||
}, [content, currentSlide, api, setDirection]);
|
||||
|
||||
const handleDragEnd = useCallback(
|
||||
(
|
||||
_: MouseEvent | TouchEvent | PointerEvent,
|
||||
{ offset, velocity }: PanInfo,
|
||||
) => {
|
||||
const swipe = swipePower(offset.x, velocity.x);
|
||||
if (
|
||||
currentSlide !== content.length - 1 &&
|
||||
swipe < -swipeConfidenceThreshold
|
||||
) {
|
||||
setDirection("right");
|
||||
setCurrentSlide((init) => init + 1);
|
||||
} else if (currentSlide !== 0 && swipe > swipeConfidenceThreshold) {
|
||||
setDirection("left");
|
||||
setCurrentSlide((init) => init - 1);
|
||||
}
|
||||
const handleTickerClick = useCallback(
|
||||
(index: number) => {
|
||||
if (index === currentSlideRef.current) return;
|
||||
setDirection(index > currentSlideRef.current ? "right" : "left");
|
||||
setCurrentSlide(index);
|
||||
},
|
||||
[currentSlide, content.length, setDirection],
|
||||
[setDirection],
|
||||
);
|
||||
|
||||
if (!api) return null;
|
||||
|
||||
return (
|
||||
<div className="carousel">
|
||||
<div
|
||||
className={`carousel ${isPaused ? "paused" : ""}`}
|
||||
onMouseEnter={() => setIsPaused(true)}
|
||||
onMouseLeave={() => setIsPaused(false)}
|
||||
>
|
||||
<AnimatePresence mode="sync">
|
||||
<motion.div
|
||||
key={currentSlide}
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
ease: "linear",
|
||||
}}
|
||||
drag={"x"}
|
||||
dragConstraints={{ left: 0, right: 0 }}
|
||||
dragElastic={1}
|
||||
//@ts-ignore
|
||||
onDragEnd={handleDragEnd}
|
||||
style={{
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
position: "absolute",
|
||||
}}
|
||||
>
|
||||
<MemoizedCarouselSlide
|
||||
item={content[currentSlide]}
|
||||
key={content[currentSlide].Id}
|
||||
/>
|
||||
</motion.div>
|
||||
<MemoizedCarouselSlide
|
||||
item={content[currentSlide]}
|
||||
key={content[currentSlide].Id}
|
||||
/>
|
||||
</AnimatePresence>
|
||||
<MemoizedSlider currentSlide={currentSlide} content={sliderContent} />
|
||||
<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>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
@@ -1,29 +1,47 @@
|
||||
import React from "react";
|
||||
|
||||
import { motion } from "framer-motion";
|
||||
|
||||
import Button from "@mui/material/Button";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { yellow } from "@mui/material/colors";
|
||||
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import { green, red } from "@mui/material/colors";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCarouselStore } from "@/utils/store/carousel";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import Button from "@mui/material/Button";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import { green, red, yellow } from "@mui/material/colors";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { motion } from "motion/react";
|
||||
import React from "react";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCarouselStore } from "@/utils/store/carousel";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
import PlayButton from "../buttons/playButton";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
const textVariants = {
|
||||
initial: (direction: string) => ({
|
||||
x: direction === "right" ? 40 : -40,
|
||||
opacity: 0,
|
||||
}),
|
||||
animate: {
|
||||
x: 0,
|
||||
opacity: 1,
|
||||
transition: {
|
||||
duration: 0.35,
|
||||
ease: [0.2, 0, 0, 1],
|
||||
},
|
||||
},
|
||||
exit: (direction: string) => ({
|
||||
x: direction === "right" ? -40 : 40,
|
||||
opacity: 0,
|
||||
transition: {
|
||||
duration: 0.2,
|
||||
ease: "easeInOut",
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
@@ -66,7 +84,13 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
|
||||
return (
|
||||
<div className="hero-carousel-slide">
|
||||
<div className="hero-carousel-background-container">
|
||||
<motion.div
|
||||
className="hero-carousel-background-container"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{ duration: 0.4, ease: "easeInOut" }}
|
||||
>
|
||||
{item.BackdropImageTags?.length ? (
|
||||
<img
|
||||
alt={item.Name ?? "item"}
|
||||
@@ -89,39 +113,39 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
{getTypeIcon(item.Type ?? "Movie")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="hero-carousel-detail">
|
||||
</motion.div>
|
||||
<motion.div
|
||||
className="hero-carousel-detail"
|
||||
initial="initial"
|
||||
animate="animate"
|
||||
exit="exit"
|
||||
variants={{
|
||||
animate: {
|
||||
transition: {
|
||||
staggerChildren: 0.05,
|
||||
delayChildren: 0.05,
|
||||
},
|
||||
},
|
||||
exit: {
|
||||
transition: {
|
||||
staggerChildren: 0.02,
|
||||
staggerDirection: -1,
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
{/* @ts-ignore */}
|
||||
<Typography
|
||||
component={motion.div}
|
||||
initial={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(60px)"
|
||||
: "translateX(-60px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
transform: "translateX(0px)",
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(-60px)"
|
||||
: "translateX(60px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
key={item.Id}
|
||||
variant="h2"
|
||||
className="hero-carousel-text"
|
||||
sx={{
|
||||
mb: "5px",
|
||||
}}
|
||||
fontWeight={200}
|
||||
fontWeight={600}
|
||||
overflow="visible"
|
||||
>
|
||||
{!item.ImageTags?.Logo ? (
|
||||
@@ -142,31 +166,11 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
/>
|
||||
)}
|
||||
</Typography>
|
||||
{/* @ts-ignore */}
|
||||
<Stack
|
||||
component={motion.div}
|
||||
initial={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(20px)"
|
||||
: "translateX(-20px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
transform: "translateX(0px)",
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(-20px)"
|
||||
: "translateX(20px)",
|
||||
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
direction="row"
|
||||
gap={2}
|
||||
className="hero-carousel-info"
|
||||
@@ -176,7 +180,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
>
|
||||
{item.PremiereDate && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.ProductionYear}
|
||||
{item.ProductionYear ?? ""}
|
||||
</Typography>
|
||||
)}
|
||||
{item.OfficialRating && (
|
||||
@@ -239,82 +243,49 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{item.RunTimeTicks ? (
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{getRuntime(item.RunTimeTicks)}
|
||||
</Typography>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
{item.RunTimeTicks ? (
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{endsAt(
|
||||
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
||||
)}
|
||||
</Typography>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{item.Genres?.slice(0, 4).join(" / ")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
{/* @ts-ignore */}
|
||||
<Typography
|
||||
component={motion.div}
|
||||
initial={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(20px)"
|
||||
: "translateX(-20px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
transform: "translateX(0px)",
|
||||
opacity: 1,
|
||||
}}
|
||||
exit={{
|
||||
transform:
|
||||
animationDirection === "right"
|
||||
? "translateX(-20px)"
|
||||
: "translateX(20px)",
|
||||
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="hero-carousel-text"
|
||||
sx={{
|
||||
display: "-webkit-box",
|
||||
maxWidth: "70%",
|
||||
maxHeight: "50%",
|
||||
textOverflow: "ellipsis",
|
||||
overflow: "hidden",
|
||||
WebkitLineClamp: "4",
|
||||
WebkitBoxOrient: "vertical",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
className="hero-carousel-overview"
|
||||
variant="body1"
|
||||
fontWeight={400}
|
||||
>
|
||||
{item.Overview}
|
||||
</Typography>
|
||||
|
||||
{/* @ts-ignore */}
|
||||
<Stack
|
||||
mt={3}
|
||||
direction="row"
|
||||
gap={3}
|
||||
gap={2}
|
||||
width="100%"
|
||||
className="hero-carousel-button-container"
|
||||
alignItems="center"
|
||||
component={motion.div}
|
||||
custom={animationDirection}
|
||||
variants={textVariants}
|
||||
>
|
||||
<PlayButton
|
||||
item={item}
|
||||
userId={user?.Id}
|
||||
itemType={item.Type ?? "Movie"}
|
||||
currentAudioTrack={0}
|
||||
currentSubTrack={0}
|
||||
currentVideoTrack={0}
|
||||
buttonProps={{
|
||||
size: "large",
|
||||
}}
|
||||
@@ -330,7 +301,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
|
||||
<Button
|
||||
size="large"
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
color="white"
|
||||
variant="outlined"
|
||||
endIcon={
|
||||
@@ -364,7 +335,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Write a react component that included an MUI circluar progress element utilizing NProgrss
|
||||
|
||||
import { CircularProgress } from "@mui/material";
|
||||
import { useNProgress } from "@tanem/react-nprogress";
|
||||
import React from "react";
|
||||
|
||||
const CircularPageLoadingAnimation = () => {
|
||||
const { progress } = useNProgress({
|
||||
isAnimating: true,
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
pointerEvents: "none",
|
||||
position: "absolute",
|
||||
top: "50%",
|
||||
left: "50%",
|
||||
transform: "translate(-50%, -50%)",
|
||||
zIndex: "10001",
|
||||
}}
|
||||
>
|
||||
<CircularProgress
|
||||
// variant="indeterminate"
|
||||
sx={{
|
||||
transitionDuration: "0.3s",
|
||||
transform: `scale(${progress})`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CircularPageLoadingAnimation;
|
||||
@@ -0,0 +1,527 @@
|
||||
import { getGenresApi } from "@jellyfin/sdk/lib/utils/api/genres-api";
|
||||
import { getMusicGenresApi } from "@jellyfin/sdk/lib/utils/api/music-genres-api";
|
||||
import {
|
||||
Accordion,
|
||||
AccordionDetails,
|
||||
AccordionSummary,
|
||||
Button,
|
||||
Checkbox,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
FormControlLabel,
|
||||
FormGroup,
|
||||
IconButton,
|
||||
Stack,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { getRouteApi } from "@tanstack/react-router";
|
||||
import React, { useMemo, useRef, useState } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import type { FILTERS } from "@/utils/constants/library";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
|
||||
const route = getRouteApi("/_api/library/$id");
|
||||
|
||||
const FILTER_LABELS: Record<FILTERS, string> = {
|
||||
isPlayed: "Played",
|
||||
isUnPlayed: "Unplayed",
|
||||
isResumable: "Resumable",
|
||||
isFavorite: "Favorite",
|
||||
hasSubtitles: "Has Subtitles",
|
||||
hasTrailer: "Has Trailer",
|
||||
hasSpecialFeature: "Special Feature",
|
||||
hasThemeSong: "Theme Song",
|
||||
hasThemeVideo: "Theme Video",
|
||||
isSD: "SD",
|
||||
isHD: "HD",
|
||||
is4K: "4K",
|
||||
is3D: "3D",
|
||||
};
|
||||
|
||||
interface FiltersDialogProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
||||
({ open, onClose }) => {
|
||||
const { id: currentLibraryId } = route.useParams();
|
||||
const { api, user } = route.useRouteContext();
|
||||
const { routeFilters, routeVideoTypes, routeGenreIds } =
|
||||
useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const slice = s.libraries[currentLibraryId || ""];
|
||||
return {
|
||||
routeFilters: slice?.filters,
|
||||
routeVideoTypes: slice?.videoTypesState,
|
||||
routeGenreIds: slice?.genreIds,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||
const initial = useMemo(
|
||||
() => ({ ...(routeFilters || {}) }),
|
||||
[routeFilters],
|
||||
);
|
||||
const [localFilters, setLocalFilters] =
|
||||
useState<Record<string, boolean | undefined>>(initial);
|
||||
const initialVideo = useMemo(
|
||||
() => ({ ...(routeVideoTypes || {}) }),
|
||||
[routeVideoTypes],
|
||||
);
|
||||
const [localVideoTypes, setLocalVideoTypes] =
|
||||
useState<Record<string, boolean>>(initialVideo);
|
||||
const initialGenres = useMemo(
|
||||
() => [...(routeGenreIds || [])] as string[],
|
||||
[routeGenreIds],
|
||||
);
|
||||
const [localGenreIds, setLocalGenreIds] = useState<string[]>(initialGenres);
|
||||
const dirty = useMemo(
|
||||
() =>
|
||||
JSON.stringify(initial) !== JSON.stringify(localFilters) ||
|
||||
JSON.stringify(initialVideo) !== JSON.stringify(localVideoTypes) ||
|
||||
JSON.stringify(initialGenres) !== JSON.stringify(localGenreIds),
|
||||
[
|
||||
initial,
|
||||
localFilters,
|
||||
initialVideo,
|
||||
localVideoTypes,
|
||||
initialGenres,
|
||||
localGenreIds,
|
||||
],
|
||||
);
|
||||
const debounceRef = useRef<number | null>(null);
|
||||
const currentLibrary = useSuspenseQuery(
|
||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||
);
|
||||
const collectionType = currentLibrary.data.CollectionType;
|
||||
const isVideoCollection = ["movies", "tvshows", "boxsets"].includes(
|
||||
String(collectionType || "").toLowerCase(),
|
||||
);
|
||||
|
||||
// Fetch genres for this library (music uses music-genres API)
|
||||
const { data: genresData } = useQuery({
|
||||
queryKey: ["library", "genres", currentLibraryId, collectionType],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id || !currentLibraryId) return { Items: [] } as any;
|
||||
if (String(collectionType || "").toLowerCase() === "music") {
|
||||
const res = await getMusicGenresApi(api).getMusicGenres({
|
||||
parentId: currentLibraryId,
|
||||
userId: user.Id,
|
||||
});
|
||||
return res.data;
|
||||
}
|
||||
const res = await getGenresApi(api).getGenres({
|
||||
parentId: currentLibraryId,
|
||||
userId: user.Id,
|
||||
});
|
||||
return res.data;
|
||||
},
|
||||
staleTime: 10 * 60 * 1000,
|
||||
enabled: !!open && !!api && !!user?.Id && !!currentLibraryId,
|
||||
});
|
||||
|
||||
const handleToggle = (key: FILTERS) => {
|
||||
setLocalFilters((prev) => {
|
||||
const next = { ...prev };
|
||||
// isHD special: undefined if unchecked instead of false
|
||||
if (key === "isHD") {
|
||||
if (next[key]) delete next[key];
|
||||
else next[key] = true;
|
||||
} else {
|
||||
next[key] = !next[key];
|
||||
}
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const apply = () => {
|
||||
if (!currentLibraryId) return;
|
||||
if (debounceRef.current) window.clearTimeout(debounceRef.current);
|
||||
debounceRef.current = window.setTimeout(() => {
|
||||
updateLibrary(currentLibraryId, {
|
||||
filters: localFilters as any,
|
||||
videoTypesState: localVideoTypes as any,
|
||||
genreIds: localGenreIds as any,
|
||||
});
|
||||
onClose();
|
||||
}, 40);
|
||||
};
|
||||
|
||||
const clearAll = () => {
|
||||
setLocalFilters({});
|
||||
setLocalVideoTypes({});
|
||||
setLocalGenreIds([]);
|
||||
};
|
||||
|
||||
const restore = () => setLocalFilters(initial);
|
||||
const restoreVideo = () => setLocalVideoTypes(initialVideo);
|
||||
const restoreGenres = () => setLocalGenreIds(initialGenres);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
fullWidth
|
||||
maxWidth="sm"
|
||||
keepMounted
|
||||
PaperProps={{ className: "glass-dialog-paper" }}
|
||||
>
|
||||
<DialogTitle>Filters</DialogTitle>
|
||||
<DialogContent
|
||||
dividers
|
||||
sx={{ borderColor: "rgba(255, 255, 255, 0.1)" }}
|
||||
>
|
||||
<Stack spacing={1.25}>
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
"&:not(:last-of-type)": {
|
||||
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<span className="material-symbols-rounded">expand_more</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">General</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(
|
||||
[
|
||||
"isPlayed",
|
||||
"isUnPlayed",
|
||||
"isResumable",
|
||||
"isFavorite",
|
||||
] as FILTERS[]
|
||||
).map((k) => (
|
||||
<FormControlLabel
|
||||
key={k}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={!!localFilters[k]}
|
||||
onChange={() => handleToggle(k)}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={FILTER_LABELS[k]}
|
||||
/>
|
||||
))}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
|
||||
{isVideoCollection && (
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
"&:not(:last-of-type)": {
|
||||
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<span className="material-symbols-rounded">
|
||||
expand_more
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Video features</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(
|
||||
[
|
||||
"hasSubtitles",
|
||||
"hasTrailer",
|
||||
"hasSpecialFeature",
|
||||
"hasThemeSong",
|
||||
"hasThemeVideo",
|
||||
] as FILTERS[]
|
||||
).map((k) => (
|
||||
<FormControlLabel
|
||||
key={k}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={!!localFilters[k]}
|
||||
onChange={() => handleToggle(k)}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={FILTER_LABELS[k]}
|
||||
/>
|
||||
))}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
|
||||
{isVideoCollection && (
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
"&:not(:last-of-type)": {
|
||||
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<span className="material-symbols-rounded">
|
||||
expand_more
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Resolution</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(["isSD", "isHD", "is4K", "is3D"] as FILTERS[]).map(
|
||||
(k) => (
|
||||
<FormControlLabel
|
||||
key={k}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={!!localFilters[k]}
|
||||
onChange={() => handleToggle(k)}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={FILTER_LABELS[k]}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
|
||||
{isVideoCollection && (
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
"&:not(:last-of-type)": {
|
||||
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<span className="material-symbols-rounded">
|
||||
expand_more
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Media type</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(["BluRay", "Dvd", "Iso", "VideoFile"] as const).map(
|
||||
(k) => (
|
||||
<FormControlLabel
|
||||
key={k}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={!!(localVideoTypes as any)[k]}
|
||||
onChange={() =>
|
||||
setLocalVideoTypes((prev) => ({
|
||||
...(prev || {}),
|
||||
[k]: !(prev as any)?.[k],
|
||||
}))
|
||||
}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={k}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
|
||||
{/* Genres (all collection types) */}
|
||||
{(genresData?.Items?.length || 0) > 0 && (
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<span className="material-symbols-rounded">
|
||||
expand_more
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Genres</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(genresData?.Items || []).map((g: any) => (
|
||||
<FormControlLabel
|
||||
key={g.Id}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={localGenreIds.includes(g.Id)}
|
||||
onChange={() =>
|
||||
setLocalGenreIds((prev) =>
|
||||
prev.includes(g.Id)
|
||||
? prev.filter((id) => id !== g.Id)
|
||||
: [...prev, g.Id],
|
||||
)
|
||||
}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={g.Name}
|
||||
/>
|
||||
))}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={clearAll}
|
||||
color="inherit"
|
||||
disabled={Object.keys(localFilters).length === 0}
|
||||
>
|
||||
Clear
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
restore();
|
||||
restoreVideo();
|
||||
restoreGenres();
|
||||
}}
|
||||
color="inherit"
|
||||
disabled={!dirty}
|
||||
>
|
||||
Reset
|
||||
</Button>
|
||||
<Button onClick={onClose}>Cancel</Button>
|
||||
<Button onClick={apply} disabled={!dirty} variant="contained">
|
||||
Apply
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
},
|
||||
);
|
||||
(FiltersDialog as any).displayName = "FiltersDialog";
|
||||
|
||||
export const FiltersDialogTrigger: React.FC = () => {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const { id: currentLibraryId } = route.useParams();
|
||||
const { filters, videoTypesState, genreIds } = useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const slice = s.libraries[currentLibraryId || ""];
|
||||
return {
|
||||
filters: slice?.filters,
|
||||
videoTypesState: slice?.videoTypesState,
|
||||
genreIds: slice?.genreIds,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const activeCount = useMemo(() => {
|
||||
const a = Object.values(filters || {}).filter((v) => v === true).length;
|
||||
const b = Object.values(videoTypesState || {}).filter(
|
||||
(v) => v === true,
|
||||
).length;
|
||||
const c = (genreIds || []).length;
|
||||
return a + b + c;
|
||||
}, [filters, videoTypesState, genreIds]);
|
||||
return (
|
||||
<>
|
||||
<Tooltip
|
||||
title={activeCount ? `${activeCount} active filters` : "Filters"}
|
||||
>
|
||||
<IconButton
|
||||
onClick={() => setOpen(true)}
|
||||
aria-label="Open filters dialog"
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ position: "relative" }}
|
||||
>
|
||||
filter_list
|
||||
{activeCount > 0 && (
|
||||
<span
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: -2,
|
||||
right: -4,
|
||||
background: "#ff4081",
|
||||
color: "#fff",
|
||||
fontSize: 10,
|
||||
borderRadius: 8,
|
||||
lineHeight: 1,
|
||||
padding: "2px 4px",
|
||||
fontFamily: "Plus Jakarta Sans Variable",
|
||||
}}
|
||||
>
|
||||
{activeCount}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<FiltersDialog open={open} onClose={() => setOpen(false)} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default FiltersDialog;
|
||||
@@ -0,0 +1,140 @@
|
||||
import {
|
||||
AnimatePresence,
|
||||
type HTMLMotionProps,
|
||||
motion,
|
||||
useScroll,
|
||||
useTransform,
|
||||
} from "motion/react";
|
||||
import React, { type RefObject, useEffect, useState } from "react";
|
||||
|
||||
interface ItemBackdropProps {
|
||||
targetRef: RefObject<HTMLElement | null>;
|
||||
backdropSrc?: string;
|
||||
fallbackSrc: string;
|
||||
alt: string;
|
||||
distance?: number; // parallax distance
|
||||
className?: string;
|
||||
onLoad?: (e: React.SyntheticEvent<HTMLImageElement>) => void;
|
||||
motionProps?: HTMLMotionProps<"img">;
|
||||
}
|
||||
|
||||
const MotionImg = motion.img;
|
||||
|
||||
const animationProps = {
|
||||
initial: { opacity: 0 },
|
||||
animate: { opacity: 1 },
|
||||
exit: { opacity: 0 },
|
||||
transition: { duration: 0.5 },
|
||||
};
|
||||
|
||||
/**
|
||||
* ItemBackdrop delays applying motion-driven parallax until after mount
|
||||
* to avoid hydration timing errors ("Target ref is defined but not hydrated").
|
||||
* It accepts a scroll container ref from the parent; if the ref is not yet
|
||||
* attached, it renders a static img to prevent motion from touching an
|
||||
* unhydrated DOM node.
|
||||
*/
|
||||
const ItemBackdropContent = React.memo(function ItemBackdropContent({
|
||||
targetRef,
|
||||
src,
|
||||
alt,
|
||||
distance,
|
||||
className,
|
||||
onLoad,
|
||||
motionProps,
|
||||
}: {
|
||||
targetRef: RefObject<HTMLElement | null>;
|
||||
src: string;
|
||||
alt: string;
|
||||
distance: number;
|
||||
className?: string;
|
||||
onLoad?: (e: React.SyntheticEvent<HTMLImageElement>) => void;
|
||||
motionProps?: HTMLMotionProps<"img">;
|
||||
}) {
|
||||
const { scrollYProgress } = useScroll({
|
||||
target: targetRef,
|
||||
offset: ["start start", "60vh start"],
|
||||
});
|
||||
const y = useTransform(scrollYProgress, [0, 1], [-distance, distance]);
|
||||
return (
|
||||
<MotionImg
|
||||
alt={alt}
|
||||
src={src}
|
||||
className={className ?? "item-hero-backdrop"}
|
||||
onLoad={(e) => {
|
||||
onLoad?.(e);
|
||||
}}
|
||||
style={{ y }}
|
||||
{...motionProps}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export function ItemBackdrop({
|
||||
targetRef,
|
||||
backdropSrc,
|
||||
fallbackSrc,
|
||||
alt,
|
||||
distance = 50,
|
||||
className,
|
||||
onLoad,
|
||||
motionProps,
|
||||
}: ItemBackdropProps) {
|
||||
const src = backdropSrc || fallbackSrc;
|
||||
const [ready, setReady] = useState(false);
|
||||
// Poll a few animation frames until the target ref hydrates to avoid premature motion initialization.
|
||||
useEffect(() => {
|
||||
if (ready) return;
|
||||
let frame = 0;
|
||||
let raf: number;
|
||||
const tick = () => {
|
||||
if (targetRef.current || frame > 5) {
|
||||
setReady(true);
|
||||
return;
|
||||
}
|
||||
frame++;
|
||||
raf = requestAnimationFrame(tick);
|
||||
};
|
||||
tick();
|
||||
return () => cancelAnimationFrame(raf);
|
||||
}, [targetRef, ready]);
|
||||
|
||||
const finalMotionProps = React.useMemo(
|
||||
() => ({
|
||||
...animationProps,
|
||||
...motionProps,
|
||||
}),
|
||||
[motionProps],
|
||||
);
|
||||
|
||||
if (!ready) {
|
||||
return (
|
||||
<img
|
||||
alt={alt}
|
||||
src={src}
|
||||
className={className ?? "item-hero-backdrop"}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
onLoad?.(e);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
<ItemBackdropContent
|
||||
key={src}
|
||||
targetRef={targetRef}
|
||||
src={src}
|
||||
alt={alt}
|
||||
distance={distance}
|
||||
className={className}
|
||||
onLoad={onLoad}
|
||||
motionProps={finalMotionProps}
|
||||
/>
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
|
||||
export default ItemBackdrop;
|
||||
@@ -0,0 +1,366 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import { green, red, yellow } from "@mui/material/colors";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import React, { type ReactNode, type RefObject } from "react";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import ultraHdIcon from "@/assets/icons/4k.svg";
|
||||
import dolbyAtmosIcon from "@/assets/icons/dolby-atmos.svg";
|
||||
import dolbyDigitalIcon from "@/assets/icons/dolby-digital.svg";
|
||||
import dolbyTrueHDIcon from "@/assets/icons/dolby-truehd.svg";
|
||||
import dolbyVisionIcon from "@/assets/icons/dolby-vision.svg";
|
||||
import dolbyVisionAtmosIcon from "@/assets/icons/dolby-vision-atmos.png";
|
||||
import dtsIcon from "@/assets/icons/dts.svg";
|
||||
import dtsHdMaIcon from "@/assets/icons/dts-hd-ma.svg";
|
||||
import hdIcon from "@/assets/icons/hd.svg";
|
||||
import hdrIcon from "@/assets/icons/hdr.svg";
|
||||
import hdr10Icon from "@/assets/icons/hdr10.svg";
|
||||
import hdr10PlusIcon from "@/assets/icons/hdr10-plus.svg";
|
||||
import sdIcon from "@/assets/icons/sd.svg";
|
||||
import sdrIcon from "@/assets/icons/sdr.svg";
|
||||
import ItemBackdrop from "@/components/itemBackdrop";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||
import "./itemHeader.scss";
|
||||
|
||||
interface ItemHeaderProps {
|
||||
item: BaseItemDto;
|
||||
api: Api | undefined;
|
||||
mediaQualityInfo?: MediaQualityInfo;
|
||||
scrollTargetRef?: RefObject<HTMLDivElement | null>;
|
||||
children?: ReactNode;
|
||||
backdropSrc?: string | null;
|
||||
}
|
||||
|
||||
const ItemHeader = ({
|
||||
item,
|
||||
api,
|
||||
mediaQualityInfo,
|
||||
scrollTargetRef,
|
||||
children,
|
||||
backdropSrc,
|
||||
}: ItemHeaderProps) => {
|
||||
const isEpisode = item.Type === "Episode";
|
||||
const backdropTag =
|
||||
isEpisode && item.ParentBackdropImageTags?.length
|
||||
? item.ParentBackdropImageTags[0]
|
||||
: item.BackdropImageTags?.[0];
|
||||
const backdropId =
|
||||
isEpisode && item.ParentBackdropImageTags?.length
|
||||
? (item.ParentBackdropItemId ?? item.Id)
|
||||
: item.Id;
|
||||
|
||||
const parentLogoImageTag =
|
||||
(item as any).ParentLogoImageTag || (item as any).ParentLogoImageTags?.[0];
|
||||
const logoTag =
|
||||
isEpisode && parentLogoImageTag ? parentLogoImageTag : item.ImageTags?.Logo;
|
||||
const logoId =
|
||||
isEpisode && parentLogoImageTag ? (item.SeriesId ?? item.Id) : item.Id;
|
||||
|
||||
const logo =
|
||||
logoTag ? (
|
||||
<img
|
||||
alt={item.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(logoId ?? "", "Logo", {
|
||||
quality: 90,
|
||||
fillWidth: 592,
|
||||
fillHeight: 592,
|
||||
tag: logoTag,
|
||||
})
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-logo"
|
||||
/>
|
||||
) : (
|
||||
<Typography mb={2} fontWeight={200} variant="h2">
|
||||
{isEpisode ? item.SeriesName : item.Name}
|
||||
</Typography>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="item-hero">
|
||||
<div className="item-hero-backdrop-container">
|
||||
{scrollTargetRef && (
|
||||
<ItemBackdrop
|
||||
targetRef={scrollTargetRef}
|
||||
alt={item.Name ?? ""}
|
||||
backdropSrc={
|
||||
backdropSrc ??
|
||||
(backdropTag
|
||||
? api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
backdropId ?? "",
|
||||
"Backdrop",
|
||||
{ tag: backdropTag },
|
||||
)
|
||||
: undefined)
|
||||
}
|
||||
fallbackSrc={heroBg}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className="item-hero-image-container"
|
||||
style={{
|
||||
aspectRatio: item.PrimaryImageAspectRatio ?? 1,
|
||||
}}
|
||||
>
|
||||
{item.ImageTags?.Primary ? (
|
||||
<div>
|
||||
<Blurhash
|
||||
hash={
|
||||
item.ImageBlurHashes?.Primary?.[item.ImageTags.Primary] ?? ""
|
||||
}
|
||||
className="item-hero-image-blurhash"
|
||||
/>
|
||||
<img
|
||||
alt={item.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
tag: item.ImageTags.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-image"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="item-hero-image-icon">
|
||||
{getTypeIcon(item.Type ?? "Movie")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="item-hero-detail flex flex-column">
|
||||
{isEpisode && logoId ? (
|
||||
<Link
|
||||
to="/series/$id"
|
||||
params={{ id: logoId }}
|
||||
style={{
|
||||
textDecoration: "none",
|
||||
color: "inherit",
|
||||
width: "fit-content",
|
||||
}}
|
||||
>
|
||||
{logo}
|
||||
</Link>
|
||||
) : (
|
||||
logo
|
||||
)}
|
||||
{isEpisode && (
|
||||
<Typography mb={2} fontWeight={200} variant="h4">
|
||||
{item.ParentIndexNumber !== undefined &&
|
||||
item.IndexNumber !== undefined
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - `
|
||||
: ""}
|
||||
{item.Name}
|
||||
</Typography>
|
||||
)}
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
{mediaQualityInfo?.isUHD && (
|
||||
<img
|
||||
src={ultraHdIcon}
|
||||
alt="ultra hd"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHD && (
|
||||
<img src={hdIcon} alt="hd" className="item-hero-mediaInfo badge" />
|
||||
)}
|
||||
{mediaQualityInfo?.isSD && (
|
||||
<img src={sdIcon} alt="sd" className="item-hero-mediaInfo badge" />
|
||||
)}
|
||||
{mediaQualityInfo?.isSDR && (
|
||||
<img
|
||||
src={sdrIcon}
|
||||
alt="sdr"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHDR &&
|
||||
!mediaQualityInfo?.isHDR10 &&
|
||||
!mediaQualityInfo?.isHDR10Plus && (
|
||||
<img
|
||||
src={hdrIcon}
|
||||
alt="hdr"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHDR10 && (
|
||||
<img
|
||||
src={hdr10Icon}
|
||||
alt="hdr10"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{item.PremiereDate && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.ProductionYear ?? ""}
|
||||
</Typography>
|
||||
)}
|
||||
{item.OfficialRating && (
|
||||
<Chip variant="filled" size="small" label={item.OfficialRating} />
|
||||
)}
|
||||
|
||||
{item.CommunityRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
// fontSize: "2.2em",
|
||||
color: yellow[400],
|
||||
}}
|
||||
>
|
||||
star
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{Math.round(item.CommunityRating * 10) / 10}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
{item.CriticRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
color: item.CriticRating > 50 ? green[400] : red[400],
|
||||
}}
|
||||
>
|
||||
{item.CriticRating > 50 ? "thumb_up" : "thumb_down"}
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{item.CriticRating}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{getRuntime(item.RunTimeTicks)}
|
||||
</Typography>
|
||||
)}
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{endsAt(
|
||||
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
||||
)}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{item.Genres?.slice(0, 4).join(" / ")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
{mediaQualityInfo && (
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
{mediaQualityInfo?.isHDR10Plus && (
|
||||
<img
|
||||
src={hdr10PlusIcon}
|
||||
alt="hdr10+"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDts && (
|
||||
<img src={dtsIcon} alt="dts" className="item-hero-mediaInfo" />
|
||||
)}
|
||||
{mediaQualityInfo.isDtsHDMA && (
|
||||
<img
|
||||
src={dtsHdMaIcon}
|
||||
alt="dts-hd ma"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isAtmos && mediaQualityInfo.isDolbyVision && (
|
||||
<img
|
||||
src={dolbyVisionAtmosIcon}
|
||||
alt="dolby vision atmos"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isAtmos && !mediaQualityInfo.isDolbyVision && (
|
||||
<img
|
||||
src={dolbyAtmosIcon}
|
||||
alt="dolby atmos"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDolbyVision && !mediaQualityInfo.isAtmos && (
|
||||
<img
|
||||
src={dolbyVisionIcon}
|
||||
alt="dolby vision"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isTrueHD && (
|
||||
<img
|
||||
src={dolbyTrueHDIcon}
|
||||
alt="dolby truehd"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDD && (
|
||||
<img
|
||||
src={dolbyDigitalIcon}
|
||||
alt="dolby digital"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
</Stack>
|
||||
)}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ItemHeader;
|
||||
@@ -0,0 +1,101 @@
|
||||
@import "../../styles/variables.scss";
|
||||
|
||||
$cardWidth: 18%;
|
||||
|
||||
.item-hero {
|
||||
height: 60vh;
|
||||
gap: 2em;
|
||||
row-gap: 1.2em;
|
||||
position: relative;
|
||||
align-items: flex-end;
|
||||
display: grid;
|
||||
grid-template-columns: $cardWidth 1fr;
|
||||
grid-template-rows: 1fr auto;
|
||||
&-image {
|
||||
opacity: 0;
|
||||
width: 100%;
|
||||
object-fit: contain;
|
||||
transition: opacity $transition-time-default;
|
||||
&-container {
|
||||
height: fit-content;
|
||||
max-height: 100%;
|
||||
overflow: hidden;
|
||||
border-radius: $border-radius-default;
|
||||
box-shadow: $shadow-card;
|
||||
flex-grow: 1;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
&-blurhash {
|
||||
position: absolute !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
z-index: -1;
|
||||
}
|
||||
&-icon {
|
||||
background: linear-gradient(45deg, rgb(255 255 255 / 0.05), rgb(255 255 255 / 0.15));
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.material-symbols-rounded{
|
||||
font-size: 4em;
|
||||
}
|
||||
}
|
||||
}
|
||||
&-logo {
|
||||
max-width: 34rem;
|
||||
max-height: 10rem;
|
||||
opacity: 0;
|
||||
transition: opacity $transition-time-default;
|
||||
object-position: bottom;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
&-detail {
|
||||
width: 100%;
|
||||
align-items: flex-start;
|
||||
gap: 0.2em;
|
||||
justify-content: end;
|
||||
}
|
||||
&-buttons {
|
||||
&-container {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
grid-column: 1/3;
|
||||
display: grid;
|
||||
grid-template-columns: inherit;
|
||||
gap: 2em;
|
||||
}
|
||||
}
|
||||
&-backdrop {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
object-fit: cover;
|
||||
object-position: top;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
transition: opacity $transition-time-default;
|
||||
&-container {
|
||||
filter: brightness(0.8);
|
||||
position: absolute;
|
||||
top: -4.4em;
|
||||
left: -$page-margin;
|
||||
width: 100vw;
|
||||
height: calc(64vh + 4.4em);
|
||||
z-index: -1;
|
||||
mask-image: linear-gradient(to top, transparent, black);
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to top,
|
||||
transparent,
|
||||
black
|
||||
);
|
||||
}
|
||||
}
|
||||
& .play-button {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
import type { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { ItemSortBy, SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import {
|
||||
AppBar,
|
||||
Chip,
|
||||
IconButton,
|
||||
MenuItem,
|
||||
TextField,
|
||||
Typography,
|
||||
useScrollTrigger,
|
||||
} from "@mui/material";
|
||||
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { getRouteApi, useNavigate } from "@tanstack/react-router";
|
||||
import type { ChangeEvent } from "react";
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { AVAILABLE_VIEWS, SORT_BY_OPTIONS } from "@/utils/constants/library";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
// import removed: header reads name/count from Zustand slice
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
import { NavigationDrawer } from "../appBar/navigationDrawer";
|
||||
import BackButton from "../buttons/backButton";
|
||||
import { FiltersDialogTrigger } from "../filtersDialog";
|
||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||
import "./libraryHeader.scss";
|
||||
|
||||
const route = getRouteApi("/_api/library/$id");
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
|
||||
export const LibraryHeader = () => {
|
||||
const { id: currentLibraryId } = route.useParams();
|
||||
const { api, user } = route.useRouteContext();
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
// Zustand library state (selected via shallow comparator)
|
||||
const {
|
||||
currentViewType,
|
||||
storeSortBy,
|
||||
storeSortAscending,
|
||||
filters,
|
||||
vts,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
libraryNameFromStore,
|
||||
itemsTotalCount,
|
||||
} = useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const slice = s.libraries[currentLibraryId || ""];
|
||||
return {
|
||||
currentViewType: slice?.currentViewType,
|
||||
storeSortBy: slice?.sortBy,
|
||||
storeSortAscending: slice?.sortAscending,
|
||||
filters: slice?.filters,
|
||||
vts: slice?.videoTypesState,
|
||||
nameStartsWith: slice?.nameStartsWith,
|
||||
genreIds: slice?.genreIds,
|
||||
libraryNameFromStore: slice?.libraryName,
|
||||
itemsTotalCount: slice?.itemsTotalCount,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const { initLibrary, updateLibrary } = useLibraryStateStore(
|
||||
useShallow((s) => ({
|
||||
initLibrary: s.initLibrary,
|
||||
updateLibrary: s.updateLibrary,
|
||||
})),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentLibraryId) return;
|
||||
// If the slice isn't initialized, these fields will be undefined
|
||||
if (
|
||||
currentViewType === undefined &&
|
||||
storeSortBy === undefined &&
|
||||
storeSortAscending === undefined
|
||||
) {
|
||||
initLibrary(currentLibraryId, {
|
||||
sortBy: ItemSortBy.Name,
|
||||
sortAscending: true,
|
||||
});
|
||||
}
|
||||
}, [
|
||||
currentLibraryId,
|
||||
currentViewType,
|
||||
storeSortBy,
|
||||
storeSortAscending,
|
||||
initLibrary,
|
||||
]);
|
||||
const currentLibrary = useSuspenseQuery(
|
||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||
);
|
||||
const scrollTrigger = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 20,
|
||||
});
|
||||
|
||||
const compatibleViews = useMemo(
|
||||
() =>
|
||||
AVAILABLE_VIEWS.filter((v) =>
|
||||
v.compatibleCollectionTypes.includes(
|
||||
currentLibrary.data.CollectionType as any,
|
||||
),
|
||||
),
|
||||
[currentLibrary.data.CollectionType],
|
||||
);
|
||||
// Values from store
|
||||
const sortBy = (storeSortBy ?? ItemSortBy.Name) as string;
|
||||
const sortAscending = storeSortAscending ?? true;
|
||||
const effectiveViewType = currentViewType as any;
|
||||
const effectiveSortByRaw = sortBy;
|
||||
const effectiveSortAscending = sortAscending;
|
||||
|
||||
const normalizedViewType = useMemo(() => {
|
||||
const values = compatibleViews.map((v) => v.value);
|
||||
if (effectiveViewType && values.includes(effectiveViewType as any))
|
||||
return effectiveViewType as any;
|
||||
return values[0] as BaseItemKind | "Artist";
|
||||
}, [effectiveViewType, compatibleViews]);
|
||||
|
||||
const normalizedSortBy = useMemo(() => {
|
||||
const compatibleOptions = SORT_BY_OPTIONS.filter(
|
||||
(option) =>
|
||||
option.compatibleViewTypes?.includes(normalizedViewType as any) ||
|
||||
option.compatibleCollectionTypes?.includes(
|
||||
currentLibrary.data.CollectionType as any,
|
||||
),
|
||||
);
|
||||
const compatibleValues = compatibleOptions.map((opt) =>
|
||||
Array.isArray(opt.value) ? opt.value.join(",") : String(opt.value),
|
||||
);
|
||||
const current = String(effectiveSortByRaw ?? "");
|
||||
if (current && compatibleValues.includes(current)) return current;
|
||||
return compatibleValues[0] ?? String(ItemSortBy.Name);
|
||||
}, [
|
||||
effectiveSortByRaw,
|
||||
normalizedViewType,
|
||||
currentLibrary.data.CollectionType,
|
||||
]);
|
||||
|
||||
const handleChangeViewType = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const next = e.target.value as unknown as BaseItemKind | "Artist";
|
||||
if (currentLibraryId)
|
||||
updateLibrary(currentLibraryId, { currentViewType: next });
|
||||
};
|
||||
const handleChangeSortBy = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const next = e.target.value as unknown as string;
|
||||
if (currentLibraryId) updateLibrary(currentLibraryId, { sortBy: next });
|
||||
};
|
||||
const handleSortAscendingToggle = () => {
|
||||
if (currentLibraryId)
|
||||
updateLibrary(currentLibraryId, {
|
||||
sortAscending: !effectiveSortAscending,
|
||||
});
|
||||
};
|
||||
|
||||
// (Video type multi-select temporarily removed; logic cleaned to reduce overhead.)
|
||||
|
||||
// Prefetch helpers to reduce perceived latency on sort changes
|
||||
// filters, vts, nameStartsWith, genreIds are already selected above
|
||||
// Prefetch handler will be attached on menu items below
|
||||
const prefetchItems = useCallback(
|
||||
async (sortByValue: string, asc: boolean) => {
|
||||
if (!api || !user?.Id || !currentLibraryId || !normalizedViewType) return;
|
||||
const key = [
|
||||
"library",
|
||||
"items",
|
||||
currentLibraryId,
|
||||
{
|
||||
currentViewType: normalizedViewType,
|
||||
sortAscending: asc,
|
||||
sortBy: sortByValue,
|
||||
filters,
|
||||
videoTypesState: vts,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
},
|
||||
] as const;
|
||||
await queryClient.prefetchQuery({
|
||||
queryKey: key,
|
||||
queryFn: async () => {
|
||||
const result = await getItemsApi(api).getItems({
|
||||
userId: user.Id!,
|
||||
parentId: currentLibraryId,
|
||||
recursive: true,
|
||||
includeItemTypes: [normalizedViewType as any],
|
||||
sortOrder: [asc ? SortOrder.Ascending : SortOrder.Descending],
|
||||
sortBy: String(sortByValue).split(",") as any,
|
||||
enableUserData: true,
|
||||
nameStartsWith: nameStartsWith || undefined,
|
||||
genreIds: genreIds && genreIds.length > 0 ? genreIds : undefined,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
staleTime: 5_000,
|
||||
});
|
||||
},
|
||||
[
|
||||
api,
|
||||
user?.Id,
|
||||
currentLibraryId,
|
||||
normalizedViewType,
|
||||
filters,
|
||||
vts,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
queryClient,
|
||||
],
|
||||
);
|
||||
|
||||
const disableSortOption = useMemo(
|
||||
() =>
|
||||
!normalizedViewType ||
|
||||
!SORT_BY_OPTIONS.some(
|
||||
(option) =>
|
||||
option.compatibleViewTypes?.includes(normalizedViewType as any) ||
|
||||
option.compatibleCollectionTypes?.includes(
|
||||
currentLibrary.data.CollectionType as any,
|
||||
),
|
||||
),
|
||||
[normalizedViewType, currentLibrary.data.CollectionType],
|
||||
);
|
||||
|
||||
const appBarStyling = useMemo(
|
||||
() => ({ backgroundColor: "transparent", paddingRight: "0 !important" }),
|
||||
[],
|
||||
);
|
||||
|
||||
// Read values from Zustand: name set by route, count set by grid
|
||||
const libraryName = libraryNameFromStore ?? currentLibrary.data.Name;
|
||||
const totalCount = itemsTotalCount;
|
||||
|
||||
const toggleSearchDialog = useSearchStore(
|
||||
useShallow((s) => s.toggleSearchDialog),
|
||||
);
|
||||
const handleNavigateToHome = useCallback(
|
||||
() => navigate({ to: "/home" }),
|
||||
[navigate],
|
||||
);
|
||||
const handleNavigateToFavorite = useCallback(
|
||||
() => navigate({ to: "/favorite" }),
|
||||
[navigate],
|
||||
);
|
||||
|
||||
const [showDrawer, setShowDrawer] = useState(false);
|
||||
|
||||
const handleDrawerClose = useCallback(() => {
|
||||
setShowDrawer(false);
|
||||
}, []);
|
||||
|
||||
const handleDrawerOpen = useCallback(() => {
|
||||
setShowDrawer(true);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBar
|
||||
className={
|
||||
scrollTrigger
|
||||
? "library-header scrolling flex flex-row"
|
||||
: "library-header flex flex-row"
|
||||
}
|
||||
style={appBarStyling}
|
||||
elevation={0}
|
||||
color="transparent"
|
||||
>
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton onClick={handleDrawerOpen}>
|
||||
<div className="material-symbols-rounded">menu</div>
|
||||
</IconButton>
|
||||
<MemoizeBackButton />
|
||||
<IconButton onClick={handleNavigateToHome}>
|
||||
<div
|
||||
className={
|
||||
location.pathname === "/home"
|
||||
? "material-symbols-rounded fill"
|
||||
: "material-symbols-rounded"
|
||||
}
|
||||
>
|
||||
home
|
||||
</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
<div
|
||||
className="flex flex-row library-header-center"
|
||||
style={{ gap: "0.6em" }}
|
||||
>
|
||||
<div
|
||||
className="library-title-count flex flex-row flex-align-center"
|
||||
title={`${libraryName}${typeof totalCount === "number" ? ` · ${totalCount.toLocaleString()} items` : ""}`}
|
||||
>
|
||||
<Typography variant="subtitle1" noWrap align="center">
|
||||
{libraryName}
|
||||
</Typography>
|
||||
{typeof totalCount === "number" && (
|
||||
<Chip label={totalCount} sx={{ px: 0.5, ml: 1 }} />
|
||||
)}
|
||||
</div>
|
||||
<TextField
|
||||
select
|
||||
size="small"
|
||||
value={String(normalizedViewType)}
|
||||
onChange={handleChangeViewType}
|
||||
SelectProps={{
|
||||
MenuProps: {
|
||||
PaperProps: {
|
||||
className: "glass-menu-paper",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<MenuItem disabled value="">
|
||||
<Typography variant="overline" color="textSecondary">
|
||||
View
|
||||
</Typography>
|
||||
</MenuItem>
|
||||
{compatibleViews.map((v) => (
|
||||
<MenuItem key={String(v.value)} value={String(v.value)}>
|
||||
{v.title}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
<IconButton
|
||||
onClick={handleSortAscendingToggle}
|
||||
aria-label="Toggle sort order"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
transform: sortAscending ? "rotateX(0deg)" : "rotateX(180deg)",
|
||||
}}
|
||||
>
|
||||
sort
|
||||
</div>
|
||||
</IconButton>
|
||||
<TextField
|
||||
select
|
||||
size="small"
|
||||
value={normalizedSortBy}
|
||||
onChange={handleChangeSortBy}
|
||||
disabled={disableSortOption}
|
||||
SelectProps={{
|
||||
MenuProps: {
|
||||
PaperProps: {
|
||||
className: "glass-menu-paper",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<MenuItem disabled value="">
|
||||
<Typography variant="overline" color="textSecondary">
|
||||
Sort By
|
||||
</Typography>
|
||||
</MenuItem>
|
||||
{SORT_BY_OPTIONS.map((option) => {
|
||||
const isCompatible =
|
||||
option.compatibleViewTypes?.includes(currentViewType as any) ||
|
||||
option.compatibleCollectionTypes?.includes(
|
||||
currentLibrary.data.CollectionType as any,
|
||||
);
|
||||
if (!isCompatible) return null;
|
||||
const valueStr = Array.isArray(option.value)
|
||||
? option.value.join(",")
|
||||
: option.value;
|
||||
return (
|
||||
<MenuItem
|
||||
key={
|
||||
Array.isArray(option.value)
|
||||
? option.value.join(",")
|
||||
: option.value
|
||||
}
|
||||
value={valueStr}
|
||||
onMouseEnter={() =>
|
||||
prefetchItems(String(valueStr), sortAscending)
|
||||
}
|
||||
>
|
||||
{option.title}
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</TextField>
|
||||
<FiltersDialogTrigger />
|
||||
</div>
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton onClick={toggleSearchDialog}>
|
||||
<div className="material-symbols-rounded">search</div>
|
||||
</IconButton>
|
||||
<IconButton onClick={handleNavigateToFavorite}>
|
||||
<div className="material-symbols-rounded">favorite</div>
|
||||
</IconButton>
|
||||
<UserAvatarMenu />
|
||||
</div>
|
||||
</AppBar>
|
||||
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
.library-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
inset: 1em 2em auto 2em !important;
|
||||
border-radius: 9999px;
|
||||
margin: 0 auto;
|
||||
width: fit-content;
|
||||
position: sticky;
|
||||
width: calc(100vw - 4em) !important;
|
||||
z-index: 10;
|
||||
padding: 0.25em !important;
|
||||
transition: all 0.2s ease-in-out;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: -0.35em;
|
||||
pointer-events: none;
|
||||
border-radius: inherit;
|
||||
@include glass-effect;
|
||||
opacity: 0;
|
||||
z-index: -1;
|
||||
transition: all 150ms;
|
||||
}
|
||||
&.scrolling {
|
||||
&::after {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { getRouteApi } from "@tanstack/react-router";
|
||||
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import "./libraryItemsGrid.scss";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
import { getLibraryItemsQueryOptions } from "@/utils/queries/libraryItems";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
// @ts-expect-error: Vite worker import
|
||||
import BackdropWorker from "@/utils/workers/backdrop.worker?worker";
|
||||
import { Card } from "../card/card";
|
||||
|
||||
const libraryRoute = getRouteApi("/_api/library/$id");
|
||||
|
||||
/**
|
||||
* Virtualized library items grid.
|
||||
* Virtualizes vertical scrolling only; items are arranged into responsive columns.
|
||||
* Assumptions:
|
||||
* - Card aspect ratio handled by CSS; we approximate a fixed height for virtualization.
|
||||
* - Width changes trigger re-measure via ResizeObserver.
|
||||
* Future improvements:
|
||||
* - Dynamic row height based on item type.
|
||||
* - Horizontal virtualization for extremely wide displays.
|
||||
*/
|
||||
const LibraryItemsGrid = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const { id: currentLibraryId } = libraryRoute.useParams();
|
||||
const {
|
||||
currentViewType,
|
||||
sortAscending,
|
||||
sortBy,
|
||||
filters,
|
||||
videoTypesState,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
} = useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const slice = s.libraries[currentLibraryId || ""];
|
||||
return {
|
||||
currentViewType: slice?.currentViewType,
|
||||
sortAscending: slice?.sortAscending ?? true,
|
||||
sortBy: slice?.sortBy ?? "Name",
|
||||
filters: slice?.filters,
|
||||
videoTypesState: slice?.videoTypesState,
|
||||
nameStartsWith: slice?.nameStartsWith,
|
||||
genreIds: slice?.genreIds,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||
const currentLibrary = useSuspenseQuery(
|
||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (currentLibraryId && !currentViewType && currentLibrary.data?.Type) {
|
||||
updateLibrary(currentLibraryId, {
|
||||
currentViewType: currentLibrary.data.Type as BaseItemKind,
|
||||
});
|
||||
}
|
||||
}, [
|
||||
currentLibrary.data?.Type,
|
||||
currentLibraryId,
|
||||
currentViewType,
|
||||
updateLibrary,
|
||||
]);
|
||||
|
||||
const items = useSuspenseQuery(
|
||||
getLibraryItemsQueryOptions(api, user?.Id, currentLibraryId, {
|
||||
currentViewType,
|
||||
sortAscending,
|
||||
sortBy,
|
||||
filters,
|
||||
videoTypesState,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
collectionType: currentLibrary.data.CollectionType as any,
|
||||
}),
|
||||
);
|
||||
// --- Backdrop ---
|
||||
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
|
||||
const backdropItems = useMemo<BaseItemDto[]>(() => {
|
||||
if (!items.isSuccess || !items.data?.Items) return [];
|
||||
return items.data.Items.filter(
|
||||
(item) => Object.keys(item.ImageBlurHashes?.Backdrop ?? {}).length > 0,
|
||||
);
|
||||
}, [items.isSuccess, items.data?.Items]);
|
||||
|
||||
useEffect(() => {
|
||||
const worker = new BackdropWorker();
|
||||
|
||||
worker.onmessage = (event: MessageEvent) => {
|
||||
if (event.data.type === "UPDATE_BACKDROP") {
|
||||
const schedule =
|
||||
(window as any).requestIdleCallback || window.requestAnimationFrame;
|
||||
schedule(() => setBackdrop(event.data.payload));
|
||||
}
|
||||
};
|
||||
|
||||
if (backdropItems.length > 0) {
|
||||
worker.postMessage({
|
||||
type: "SET_BACKDROP_ITEMS",
|
||||
payload: backdropItems,
|
||||
});
|
||||
worker.postMessage({ type: "START" });
|
||||
}
|
||||
|
||||
return () => {
|
||||
worker.postMessage({ type: "STOP" });
|
||||
worker.terminate();
|
||||
};
|
||||
}, [backdropItems, setBackdrop]);
|
||||
// --- Virtualization setup ---
|
||||
const parentRef = useRef<HTMLDivElement | null>(null);
|
||||
const [containerWidth, setContainerWidth] = useState<number>(0);
|
||||
|
||||
// Determine column count based on container width (simple heuristic)
|
||||
const [columns, setColumns] = useState(1);
|
||||
const measureColumns = useCallback(() => {
|
||||
if (!parentRef.current) return;
|
||||
const width = parentRef.current.clientWidth;
|
||||
setContainerWidth(width);
|
||||
// Base desired approximate card width (including gap) 180px
|
||||
const ideal = Math.max(1, Math.floor(width / 180));
|
||||
setColumns(ideal);
|
||||
}, []);
|
||||
|
||||
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;
|
||||
// Compute number of virtual rows
|
||||
const rowCount = Math.ceil(itemCount / columns);
|
||||
|
||||
// Estimated row height (depends on card type). Using 260px as base (portrait taller)
|
||||
// Compute card width minus gaps
|
||||
const cardGap = 16; // px gap between cards
|
||||
const cardWidth = useMemo(() => {
|
||||
if (columns <= 0) return 180;
|
||||
const totalGap = (columns - 1) * cardGap;
|
||||
return Math.floor((containerWidth - totalGap) / columns);
|
||||
}, [columns, containerWidth]);
|
||||
|
||||
// Approximate tallest card height (portrait ratio ~ 2:3 => height ≈ width / 0.666) + text/footer area
|
||||
// We add a small buffer (20px) for hover overlays and progress bars
|
||||
const estimatedTallCardHeight = useMemo(
|
||||
() => Math.round(cardWidth / 0.666666 + 90),
|
||||
[cardWidth],
|
||||
);
|
||||
|
||||
const estimateRowHeight = useCallback(
|
||||
() => estimatedTallCardHeight,
|
||||
[estimatedTallCardHeight],
|
||||
);
|
||||
|
||||
const virtualizer = useWindowVirtualizer({
|
||||
count: rowCount,
|
||||
estimateSize: estimateRowHeight,
|
||||
overscan: 6,
|
||||
scrollMargin: parentRef.current?.offsetTop ?? 0,
|
||||
});
|
||||
|
||||
const virtualItems = virtualizer.getVirtualItems();
|
||||
|
||||
// Update count in Zustand so header can display it without extra fetches
|
||||
useEffect(() => {
|
||||
const total = items.data?.TotalRecordCount;
|
||||
if (currentLibraryId && typeof total === "number") {
|
||||
updateLibrary(currentLibraryId, { itemsTotalCount: total });
|
||||
}
|
||||
}, [items.data?.TotalRecordCount, currentLibraryId, updateLibrary]);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={parentRef}
|
||||
className="library-items-container virtualized"
|
||||
style={{ position: "relative" }}
|
||||
>
|
||||
{items.isSuccess && itemCount === 0 ? (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
minHeight: 240,
|
||||
width: "100%",
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<div
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: 48, marginBottom: 8 }}
|
||||
>
|
||||
sentiment_dissatisfied
|
||||
</div>
|
||||
<div style={{ fontSize: 16 }}>No items to show</div>
|
||||
<div style={{ fontSize: 13, marginTop: 6 }}>
|
||||
Try adjusting filters, sort, or the A–Z selector.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
style={{
|
||||
position: "relative",
|
||||
height: virtualizer.getTotalSize(),
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{virtualItems.map((row) => {
|
||||
const startIndex = row.index * columns;
|
||||
const endIndex = Math.min(startIndex + columns, itemCount);
|
||||
return (
|
||||
<div
|
||||
key={row.key}
|
||||
style={{
|
||||
position: "absolute",
|
||||
transform: `translateY(${
|
||||
row.start - virtualizer.options.scrollMargin
|
||||
}px)`,
|
||||
left: 0,
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "flex-start",
|
||||
gap: `${cardGap}px`,
|
||||
// Allow natural height; virtualizer will update size after measurement.
|
||||
paddingBottom: "0.6em",
|
||||
}}
|
||||
data-index={row.index}
|
||||
ref={(el) => {
|
||||
if (el) virtualizer.measureElement(el);
|
||||
}}
|
||||
>
|
||||
{items.data?.Items?.slice(startIndex, endIndex).map(
|
||||
(item: BaseItemDto, localIndex: number) => {
|
||||
return (
|
||||
<div
|
||||
key={item?.Id ?? localIndex}
|
||||
style={{
|
||||
width: `${cardWidth}px`,
|
||||
flex: "0 0 auto",
|
||||
// Override default card margins to avoid compounding with gaps
|
||||
margin: 0,
|
||||
}}
|
||||
>
|
||||
<Card
|
||||
item={item}
|
||||
seriesId={item?.SeriesId}
|
||||
skipInView
|
||||
cardTitle={
|
||||
item?.Type === BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item?.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item?.Type === BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item?.Type === BaseItemKind.Series
|
||||
? `${item.ProductionYear} - ${
|
||||
item.EndDate
|
||||
? new Date(item.EndDate).toLocaleString(
|
||||
[],
|
||||
{
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
: "Present"
|
||||
}`
|
||||
: item?.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item?.Type === BaseItemKind.Person ||
|
||||
item?.Type === BaseItemKind.Genre ||
|
||||
item?.Type === BaseItemKind.MusicGenre ||
|
||||
item?.Type === BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item?.Type === BaseItemKind.MusicAlbum ||
|
||||
item?.Type === BaseItemKind.Audio ||
|
||||
item?.Type === BaseItemKind.Genre ||
|
||||
item?.Type === BaseItemKind.MusicGenre ||
|
||||
item?.Type === BaseItemKind.Studio ||
|
||||
item?.Type === BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
userId={user?.Id}
|
||||
// Inline style overrides to neutralize original margins for virtualization
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default LibraryItemsGrid;
|
||||
@@ -0,0 +1,31 @@
|
||||
// Overrides for virtualized library items layout to prevent horizontal overflow
|
||||
.library-items-container.virtualized {
|
||||
overflow-x: hidden;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
display: block !important; // override grid from route styles
|
||||
padding: 0 !important; // override padding from route styles
|
||||
position: relative; // required for absolutely positioned rows
|
||||
gap: 0 !important;
|
||||
justify-items: normal !important;
|
||||
align-content: stretch !important;
|
||||
> .card {
|
||||
max-width: none !important;
|
||||
}
|
||||
// Ensure no unintended padding expands width
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
.card {
|
||||
margin-right: 0 !important;
|
||||
margin-bottom: 0.6em !important; // keep a consistent vertical rhythm
|
||||
}
|
||||
.card-image-container {
|
||||
// Remove box shadow spread from affecting layout width calculation
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
// When page has audio-playing class, avoid extra bottom padding causing scrollbars
|
||||
.audio-playing .library-items-container.virtualized {
|
||||
padding-bottom: 8em; // mimic original intent without affecting width
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import {
|
||||
ListItem,
|
||||
ListItemButton,
|
||||
type ListItemProps,
|
||||
ListItemText,
|
||||
} from "@mui/material";
|
||||
import { createLink, Link } from "@tanstack/react-router";
|
||||
import React, { forwardRef, type ReactNode } from "react";
|
||||
|
||||
interface MUIListItemLinkProps extends ListItemProps<"a"> {
|
||||
icon?: ReactNode;
|
||||
primary: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const CreatedListItemLink = forwardRef<HTMLAnchorElement, MUIListItemLinkProps>(
|
||||
(props, ref) => (
|
||||
<ListItem component="a" ref={ref} {...props}>
|
||||
<ListItemButton
|
||||
sx={{
|
||||
color: "inherit",
|
||||
textDecoration: "none",
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">{props.icon}</div>
|
||||
<ListItemText primary={props.primary} />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
),
|
||||
);
|
||||
|
||||
const ListItemLink = createLink(CreatedListItemLink);
|
||||
|
||||
export default ListItemLink;
|
||||
|
||||
/* export default function ListItemLink(props: ListItemLinkProps) {
|
||||
const { icon, primary, to, className } = props;
|
||||
|
||||
return (
|
||||
<li>
|
||||
{/* @ts-expect-error /*}
|
||||
<ListItem
|
||||
component={Link}
|
||||
activeClassName="active"
|
||||
className={className}
|
||||
to={to}
|
||||
>
|
||||
<ListItemButton
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
color: "white",
|
||||
textDecoration: "none",
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">{icon}</div>
|
||||
<ListItemText primary={primary} />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
*/
|
||||
@@ -21,7 +21,7 @@ export default function NProgress() {
|
||||
isAnimating,
|
||||
});
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
pointerEvents: "none",
|
||||
@@ -44,8 +44,7 @@ export default function NProgress() {
|
||||
variant="determinate"
|
||||
/>
|
||||
)}
|
||||
</div>,
|
||||
document.body,
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -2,15 +2,40 @@ $image-size: 4em;
|
||||
|
||||
.audio-player {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
z-index: 10;
|
||||
bottom: 1rem;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 95%;
|
||||
max-width: 1200px;
|
||||
z-index: 100;
|
||||
display: grid;
|
||||
padding: 0.5em 1.5em;
|
||||
gap: 1em;
|
||||
box-shadow: 0 0 20px rgb(0 0 0 / 0.25);
|
||||
grid-template-columns: 30% 1fr 30%;
|
||||
background: rgb(0 0 0 / 0.8) !important;
|
||||
padding: 0.75em 1.5em;
|
||||
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;
|
||||
|
||||
@media (max-width: 900px) {
|
||||
grid-template-columns: 1fr auto;
|
||||
padding: 0.5em 1em;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
border-bottom: none;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
|
||||
.audio-player-controls {
|
||||
display: none; // Hide controls on mobile for now or adjust
|
||||
}
|
||||
}
|
||||
|
||||
#waveform {
|
||||
width: 100%;
|
||||
transform: scaleY(0);
|
||||
@@ -36,6 +61,13 @@ $image-size: 4em;
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
&-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
&-image {
|
||||
width: $image-size;
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getLyricsApi } from "@jellyfin/sdk/lib/utils/api/lyrics-api";
|
||||
import { Typography } from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { secToTicks } from "@/utils/date/time";
|
||||
|
||||
interface LyricsPanelProps {
|
||||
item: BaseItemDto | undefined | null;
|
||||
api: Api | undefined;
|
||||
currentTime: number;
|
||||
}
|
||||
|
||||
const LyricsPanel = ({ item, api, currentTime }: LyricsPanelProps) => {
|
||||
const lyricsContainer = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
const lyrics = useQuery({
|
||||
queryKey: ["player", "audio", item?.Id, "lyrics"],
|
||||
queryFn: async () => {
|
||||
if (!item?.Id || !api) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const response = await getLyricsApi(api).getLyrics({
|
||||
itemId: item?.Id,
|
||||
});
|
||||
return response.data;
|
||||
} catch (e) {
|
||||
console.error("Failed to fetch lyrics", e);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
enabled: Boolean(item?.Id) && Boolean(api),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (lyrics.data && lyricsContainer.current) {
|
||||
const currentLyric = lyricsContainer.current.querySelector(
|
||||
"[data-active-lyric='true']",
|
||||
);
|
||||
if (currentLyric) {
|
||||
currentLyric.scrollIntoView({
|
||||
block: "center",
|
||||
inline: "nearest",
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [currentTime, lyrics.data]);
|
||||
|
||||
if (lyrics.isLoading) {
|
||||
return (
|
||||
<div className="audio-lyrics-status">
|
||||
<Typography>Loading lyrics...</Typography>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (lyrics.isError || !lyrics.data || !lyrics.data.Lyrics?.length) {
|
||||
return (
|
||||
<div className="audio-lyrics-status">
|
||||
<Typography>No lyrics available</Typography>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const hasSyncedLyrics = (lyrics.data.Lyrics[0].Start ?? -1) >= 0;
|
||||
|
||||
return (
|
||||
<div className="audio-lyrics" data-has-synced-lyrics={hasSyncedLyrics}>
|
||||
<div className="audio-lyrics-container" ref={lyricsContainer}>
|
||||
{lyrics.data.Lyrics.map((lyric, index) => {
|
||||
const isActive =
|
||||
hasSyncedLyrics &&
|
||||
secToTicks(currentTime) >= (lyric.Start ?? 0) &&
|
||||
secToTicks(currentTime) <
|
||||
(lyrics.data?.Lyrics?.[index + 1]?.Start ??
|
||||
Number.POSITIVE_INFINITY);
|
||||
|
||||
return (
|
||||
<Typography
|
||||
variant="body1"
|
||||
component="p"
|
||||
className={`audio-lyrics-line ${isActive ? "active" : ""}`}
|
||||
key={`${lyric.Text}-${index}`}
|
||||
data-active-lyric={isActive}
|
||||
>
|
||||
{lyric.Text}
|
||||
</Typography>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{!hasSyncedLyrics && (
|
||||
<div className="audio-lyrics-unsynced-notice">
|
||||
<span className="material-symbols-rounded">info</span>
|
||||
<Typography variant="caption">Synced lyrics not available</Typography>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(LyricsPanel);
|
||||
@@ -0,0 +1,37 @@
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import type { ReactNode } from "react";
|
||||
import React from "react";
|
||||
import QueueButton from "@/components/buttons/queueButton";
|
||||
|
||||
interface PlayerActionsProps {
|
||||
onNavigate: () => void;
|
||||
onClose: () => void;
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
const PlayerActions = ({
|
||||
onNavigate,
|
||||
onClose,
|
||||
children,
|
||||
}: PlayerActionsProps) => {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
}}
|
||||
>
|
||||
<IconButton onClick={onNavigate}>
|
||||
<span className="material-symbols-rounded">info</span>
|
||||
</IconButton>
|
||||
<QueueButton />
|
||||
{children}
|
||||
<IconButton onClick={onClose}>
|
||||
<div className="material-symbols-rounded">close</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PlayerActions;
|
||||
@@ -0,0 +1,59 @@
|
||||
import Fab from "@mui/material/Fab";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import React from "react";
|
||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||
|
||||
interface PlayerControlsProps {
|
||||
playing: boolean;
|
||||
onPlayPause: () => void;
|
||||
size?: "small" | "medium" | "large";
|
||||
onRewind?: () => void;
|
||||
onForward?: () => void;
|
||||
}
|
||||
|
||||
const PlayerControls = ({
|
||||
playing,
|
||||
onPlayPause,
|
||||
size = "small",
|
||||
onRewind,
|
||||
onForward,
|
||||
}: PlayerControlsProps) => {
|
||||
return (
|
||||
<div style={{ display: "flex", gap: "1em", alignItems: "center" }}>
|
||||
<PlayPreviousButton />
|
||||
{onRewind && (
|
||||
<IconButton onClick={onRewind}>
|
||||
<span className="material-symbols-rounded">fast_rewind</span>
|
||||
</IconButton>
|
||||
)}
|
||||
<div
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
position: "relative",
|
||||
}}
|
||||
>
|
||||
<Fab size={size} onClick={onPlayPause}>
|
||||
<div
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
fontSize: size === "large" ? "2.4em" : "2em",
|
||||
}}
|
||||
>
|
||||
{playing ? "pause" : "play_arrow"}
|
||||
</div>
|
||||
</Fab>
|
||||
</div>
|
||||
{onForward && (
|
||||
<IconButton onClick={onForward}>
|
||||
<span className="material-symbols-rounded">fast_forward</span>
|
||||
</IconButton>
|
||||
)}
|
||||
<PlayNextButton />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(PlayerControls);
|
||||
@@ -0,0 +1,60 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import React from "react";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
|
||||
interface PlayerInfoProps {
|
||||
item: BaseItemDto | undefined | null;
|
||||
api: Api | undefined;
|
||||
trackName?: string;
|
||||
}
|
||||
|
||||
const PlayerInfo = ({ item, api, trackName }: PlayerInfoProps) => {
|
||||
if (!api || !item) return null;
|
||||
|
||||
return (
|
||||
<div className="audio-player-info">
|
||||
<div className="audio-player-image-container">
|
||||
<img
|
||||
alt={trackName ?? "track"}
|
||||
className="audio-player-image"
|
||||
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">
|
||||
music_note
|
||||
</span>
|
||||
</div>
|
||||
<div className="audio-player-info-text">
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
noWrap
|
||||
>
|
||||
{item?.Name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
style={{
|
||||
opacity: 0.5,
|
||||
}}
|
||||
noWrap
|
||||
>
|
||||
by {item?.Artists?.map((artist) => artist).join(",")}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PlayerInfo;
|
||||
@@ -0,0 +1,87 @@
|
||||
import Slider from "@mui/material/Slider";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { getRuntimeMusic } from "@/utils/date/time";
|
||||
|
||||
interface PlayerProgressProps {
|
||||
progress: number;
|
||||
duration: number;
|
||||
onSeek?: (value: number) => void;
|
||||
onSeekCommit: (value: number) => void;
|
||||
}
|
||||
|
||||
const PlayerProgress = ({
|
||||
progress,
|
||||
duration,
|
||||
onSeek,
|
||||
onSeekCommit,
|
||||
}: PlayerProgressProps) => {
|
||||
const [isScrubbing, setIsScrubbing] = useState(false);
|
||||
const [sliderValue, setSliderValue] = useState(progress);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isScrubbing) {
|
||||
setSliderValue(progress);
|
||||
}
|
||||
}, [progress, isScrubbing]);
|
||||
|
||||
const handleChange = (_: Event, value: number | number[]) => {
|
||||
setIsScrubbing(true);
|
||||
const newValue = Array.isArray(value) ? value[0] : value;
|
||||
setSliderValue(newValue);
|
||||
onSeek?.(newValue);
|
||||
};
|
||||
|
||||
const handleChangeCommitted = (_: unknown, value: number | number[]) => {
|
||||
setIsScrubbing(false);
|
||||
const newValue = Array.isArray(value) ? value[0] : value;
|
||||
onSeekCommit(newValue);
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
gap: "1em",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
style={{
|
||||
opacity: 0.8,
|
||||
minWidth: "3.5em",
|
||||
textAlign: "right",
|
||||
fontVariantNumeric: "tabular-nums",
|
||||
}}
|
||||
>
|
||||
{getRuntimeMusic(sliderValue)}
|
||||
</Typography>
|
||||
<Slider
|
||||
value={sliderValue}
|
||||
step={1}
|
||||
size="small"
|
||||
max={duration}
|
||||
onChange={handleChange}
|
||||
onChangeCommitted={handleChangeCommitted}
|
||||
/>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
style={{
|
||||
opacity: 0.8,
|
||||
minWidth: "3.5em",
|
||||
textAlign: "left",
|
||||
fontVariantNumeric: "tabular-nums",
|
||||
}}
|
||||
>
|
||||
{getRuntimeMusic(duration)}
|
||||
</Typography>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PlayerProgress;
|
||||
@@ -0,0 +1,73 @@
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Slider from "@mui/material/Slider";
|
||||
import React from "react";
|
||||
|
||||
interface PlayerVolumeProps {
|
||||
volume: number;
|
||||
isMuted: boolean;
|
||||
onVolumeChange: (value: number) => void;
|
||||
onMuteToggle: () => void;
|
||||
}
|
||||
|
||||
const PlayerVolume = ({
|
||||
volume,
|
||||
isMuted,
|
||||
onVolumeChange,
|
||||
onMuteToggle,
|
||||
}: PlayerVolumeProps) => {
|
||||
const [localVolume, setLocalVolume] = React.useState(volume * 100);
|
||||
|
||||
React.useEffect(() => {
|
||||
setLocalVolume(volume * 100);
|
||||
}, [volume]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<IconButton onClick={onMuteToggle}>
|
||||
<div className="material-symbols-rounded">
|
||||
{isMuted ? "volume_mute" : "volume_up"}
|
||||
</div>
|
||||
</IconButton>
|
||||
<Slider
|
||||
value={isMuted ? 0 : localVolume}
|
||||
step={1}
|
||||
max={100}
|
||||
onChange={(_, newVal) => {
|
||||
const newVolume = Array.isArray(newVal) ? newVal[0] : newVal;
|
||||
setLocalVolume(newVolume);
|
||||
onVolumeChange(newVolume / 100);
|
||||
}}
|
||||
valueLabelDisplay="auto"
|
||||
valueLabelFormat={(value) => Math.floor(value)}
|
||||
size="small"
|
||||
sx={{
|
||||
mr: 1,
|
||||
ml: 1,
|
||||
width: "10em",
|
||||
"& .MuiSlider-valueLabel": {
|
||||
lineHeight: 1.2,
|
||||
fontSize: 24,
|
||||
background: "rgb(0 0 0 / 0.5)",
|
||||
backdropFilter: "blur(5px)",
|
||||
padding: 1,
|
||||
borderRadius: "10px",
|
||||
border: "1px solid rgb(255 255 255 / 0.15)",
|
||||
boxShadow: "0 0 10px rgb(0 0 0 / 0.4) ",
|
||||
transform: "translatey(-120%) scale(0)",
|
||||
"&:before": {
|
||||
display: "none",
|
||||
},
|
||||
"&.MuiSlider-valueLabelOpen": {
|
||||
transform: "translateY(-120%) scale(1)",
|
||||
},
|
||||
"& > *": {
|
||||
transform: "rotate(0deg)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default PlayerVolume;
|
||||
@@ -0,0 +1,297 @@
|
||||
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" 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);
|
||||
@@ -0,0 +1,149 @@
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Box, Paper, Typography } from "@mui/material";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
interface StatsPanelProps {
|
||||
item: BaseItemDto | undefined | null;
|
||||
audioRef: React.RefObject<HTMLAudioElement> | null;
|
||||
}
|
||||
|
||||
const StatRow = ({
|
||||
label,
|
||||
value,
|
||||
}: {
|
||||
label: string;
|
||||
value: string | number | undefined | null;
|
||||
}) => (
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
mb: 1,
|
||||
borderBottom: "1px solid rgba(255,255,255,0.1)",
|
||||
pb: 0.5,
|
||||
}}
|
||||
>
|
||||
<Typography variant="body2" sx={{ opacity: 0.7, fontFamily: "monospace" }}>
|
||||
{label}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{ fontFamily: "monospace", fontWeight: 600 }}
|
||||
>
|
||||
{value || "-"}
|
||||
</Typography>
|
||||
</Box>
|
||||
);
|
||||
|
||||
const StatsPanel: React.FC<StatsPanelProps> = ({ item, audioRef }) => {
|
||||
const [buffered, setBuffered] = useState<string>("0%");
|
||||
|
||||
useEffect(() => {
|
||||
const player = audioRef?.current;
|
||||
if (!player) return;
|
||||
|
||||
const updateStats = () => {
|
||||
if (player.buffered.length > 0) {
|
||||
const bufferedEnd = player.buffered.end(player.buffered.length - 1);
|
||||
const duration = player.duration;
|
||||
if (duration > 0) {
|
||||
setBuffered(`${Math.round((bufferedEnd / duration) * 100)}%`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const interval = setInterval(updateStats, 1000);
|
||||
return () => clearInterval(interval);
|
||||
}, [audioRef]);
|
||||
|
||||
const mediaSource = item?.MediaSources?.[0];
|
||||
const mediaStream = mediaSource?.MediaStreams?.find(
|
||||
(s) => s.Type === "Audio",
|
||||
);
|
||||
|
||||
return (
|
||||
<Box sx={{ p: 2 }}>
|
||||
<Typography variant="h6" sx={{ mb: 2 }}>
|
||||
Stats for Nerds
|
||||
</Typography>
|
||||
|
||||
<Paper
|
||||
sx={{
|
||||
p: 2,
|
||||
background: "rgba(0,0,0,0.2)",
|
||||
backdropFilter: "blur(10px)",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
||||
>
|
||||
Media Source
|
||||
</Typography>
|
||||
<StatRow label="Container" value={mediaSource?.Container} />
|
||||
<StatRow
|
||||
label="Bitrate"
|
||||
value={
|
||||
mediaSource?.Bitrate
|
||||
? `${Math.round(mediaSource.Bitrate / 1000)} kbps`
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<StatRow
|
||||
label="Size"
|
||||
value={
|
||||
mediaSource?.Size
|
||||
? `${(mediaSource.Size / 1024 / 1024).toFixed(2)} MB`
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<StatRow label="Path" value={mediaSource?.Path} />
|
||||
|
||||
<Box sx={{ mt: 3 }}>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
||||
>
|
||||
Audio Stream
|
||||
</Typography>
|
||||
<StatRow label="Codec" value={mediaStream?.Codec} />
|
||||
<StatRow label="Channels" value={mediaStream?.Channels} />
|
||||
<StatRow
|
||||
label="Sample Rate"
|
||||
value={
|
||||
mediaStream?.SampleRate
|
||||
? `${mediaStream.SampleRate} Hz`
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<StatRow label="Bit Depth" value={mediaStream?.BitDepth} />
|
||||
<StatRow label="Language" value={mediaStream?.Language} />
|
||||
</Box>
|
||||
|
||||
<Box sx={{ mt: 3 }}>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
sx={{ mb: 1, opacity: 0.5, textTransform: "uppercase" }}
|
||||
>
|
||||
Player
|
||||
</Typography>
|
||||
<StatRow label="Buffered" value={buffered} />
|
||||
<StatRow
|
||||
label="Volume"
|
||||
value={
|
||||
audioRef?.current
|
||||
? `${Math.round(audioRef.current.volume * 100)}%`
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<StatRow
|
||||
label="Playback Rate"
|
||||
value={audioRef?.current?.playbackRate}
|
||||
/>
|
||||
</Box>
|
||||
</Paper>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(StatsPanel);
|
||||
@@ -1,365 +1,254 @@
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
|
||||
import { motion } from "framer-motion";
|
||||
|
||||
import Fab from "@mui/material/Fab";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Slider from "@mui/material/Slider";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { setAudioRef, useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||
import useQueue from "@/utils/store/queue";
|
||||
|
||||
import { AnimatePresence } from "framer-motion";
|
||||
import "./audioPlayer.scss";
|
||||
|
||||
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
||||
|
||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||
import QueueButton from "@/components/buttons/queueButton";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React, { type SyntheticEvent, useEffect, useRef, useState } from "react";
|
||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import {
|
||||
setAudioRef,
|
||||
setIsMuted,
|
||||
setVolume,
|
||||
useAudioPlayback,
|
||||
} from "@/utils/store/audioPlayback";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { playItemFromQueue } from "@/utils/store/playback";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import useQueue from "@/utils/store/queue";
|
||||
import PlayerActions from "./components/PlayerActions";
|
||||
import PlayerControls from "./components/PlayerControls";
|
||||
import PlayerInfo from "./components/PlayerInfo";
|
||||
import PlayerProgress from "./components/PlayerProgress";
|
||||
import PlayerVolume from "./components/PlayerVolume";
|
||||
|
||||
import "./audioPlayer.scss";
|
||||
|
||||
const AudioPlayer = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||
const [url, display, item] = useAudioPlayback((state) => [
|
||||
const [url, display, item, volume, isMuted] = useAudioPlayback((state) => [
|
||||
state.url,
|
||||
state.display,
|
||||
state.item,
|
||||
state.player.volume,
|
||||
state.player.isMuted,
|
||||
]);
|
||||
|
||||
|
||||
const [tracks, currentTrack] = useQueue((state) => [
|
||||
state.tracks,
|
||||
state.currentItemIndex,
|
||||
]);
|
||||
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
|
||||
const playing = useMemo(() => {
|
||||
if (audioRef.current?.paused) return false;
|
||||
return true;
|
||||
}, [audioRef.current?.paused]);
|
||||
const [volume, setVolume] = useState(0.8);
|
||||
const [isMuted, setIsMuted] = useState(false);
|
||||
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [isScrubbing, setIsScrubbing] = useState(false);
|
||||
const [sliderProgress, setSliderProgress] = useState(0);
|
||||
|
||||
|
||||
// Sync volume and ref
|
||||
useEffect(() => {
|
||||
if (display) {
|
||||
// const audioUrlRequest = new Request(audioRef.current?.dataset.src, {
|
||||
// method: "GET",
|
||||
// headers: {
|
||||
// Authorization: api.authorizationHeader,
|
||||
// },
|
||||
// });
|
||||
// fetch(audioUrlRequest)
|
||||
// .then((res) => res)
|
||||
// .then(async (result) => {
|
||||
// const blob = await result.blob();
|
||||
// const blobUrl = URL.createObjectURL(blob);
|
||||
// audioRef.current.src = blobUrl;
|
||||
// await audioRef.current.play();
|
||||
// setLoading(false);
|
||||
// });
|
||||
|
||||
// Set the audio ref in the store to allow for global control
|
||||
setAudioRef(audioRef);
|
||||
|
||||
if (audioRef.current) {
|
||||
audioRef.current.volume = isMuted ? 0 : volume;
|
||||
}
|
||||
}
|
||||
}, [url, tracks?.[currentTrack]?.Id]);
|
||||
}, [display, url, tracks?.[currentTrack]?.Id]);
|
||||
|
||||
// Update volume when state changes
|
||||
useEffect(() => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.volume = isMuted ? 0 : volume;
|
||||
}
|
||||
}, [volume, isMuted]);
|
||||
|
||||
// Media Session Metadata
|
||||
useEffect(() => {
|
||||
if ("mediaSession" in navigator && item) {
|
||||
const imageUrl = item.ImageTags?.Primary
|
||||
? api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(item.Id ?? "", "Primary", {
|
||||
tag: item.ImageTags.Primary,
|
||||
})
|
||||
: undefined;
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const info = useMemo(
|
||||
() =>
|
||||
api && (
|
||||
<div
|
||||
// initial={{
|
||||
// filter: "opacity(0)",
|
||||
// }}
|
||||
// animate={{
|
||||
// filter: "opacity(1)",
|
||||
// }}
|
||||
// exit={{
|
||||
// filter: "opacity(0)",
|
||||
// }}
|
||||
className="audio-player-info"
|
||||
>
|
||||
<div className="audio-player-image-container">
|
||||
<img
|
||||
alt={tracks?.[currentTrack]?.Name ?? "track"}
|
||||
className="audio-player-image"
|
||||
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">
|
||||
music_note
|
||||
</span>
|
||||
</div>
|
||||
<div className="audio-player-info-text">
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{item?.Name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
style={{
|
||||
opacity: 0.5,
|
||||
}}
|
||||
noWrap
|
||||
>
|
||||
by {item?.Artists?.map((artist) => artist).join(",")}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
[tracks?.[currentTrack]?.Id, currentTrack, api?.configuration],
|
||||
);
|
||||
|
||||
const controls = useMemo(
|
||||
() => (
|
||||
<div style={{ display: "flex", gap: "1em" }}>
|
||||
<PlayPreviousButton />
|
||||
<div
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
position: "relative",
|
||||
}}
|
||||
>
|
||||
<Fab
|
||||
size="small"
|
||||
onClick={() =>
|
||||
audioRef.current?.paused
|
||||
? audioRef.current.play()
|
||||
: audioRef.current?.pause()
|
||||
}
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
fontSize: "2em",
|
||||
}}
|
||||
>
|
||||
{playing ? "pause" : "play_arrow"}
|
||||
</div>
|
||||
</Fab>
|
||||
</div>
|
||||
<PlayNextButton />
|
||||
</div>
|
||||
),
|
||||
[tracks?.[currentTrack]?.Id, playing, tracks?.length],
|
||||
);
|
||||
|
||||
const buttons = useMemo(
|
||||
() => (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
}}
|
||||
>
|
||||
<IconButton onClick={() => navigate({ to: "/player/audio" })}>
|
||||
<span className="material-symbols-rounded">info</span>
|
||||
</IconButton>
|
||||
<QueueButton />
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
setIsMuted(!isMuted);
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">
|
||||
{isMuted ? "volume_mute" : "volume_up"}
|
||||
</div>
|
||||
</IconButton>
|
||||
<Slider
|
||||
value={isMuted ? 0 : volume * 100}
|
||||
step={1}
|
||||
max={100}
|
||||
onChange={(_, newVal) => {
|
||||
if (!audioRef.current) {
|
||||
console.error("Audio ref not found");
|
||||
return;
|
||||
}
|
||||
Array.isArray(newVal)
|
||||
? setVolume(newVal[0] / 100)
|
||||
: setVolume(newVal / 100);
|
||||
if (Array.isArray(newVal)) {
|
||||
audioRef.current.volume = newVal[0] / 100;
|
||||
} else {
|
||||
audioRef.current.volume = newVal / 100;
|
||||
}
|
||||
}}
|
||||
valueLabelDisplay="auto"
|
||||
valueLabelFormat={(value) => Math.floor(value)}
|
||||
size="small"
|
||||
sx={{
|
||||
mr: 1,
|
||||
ml: 1,
|
||||
width: "10em",
|
||||
"& .MuiSlider-valueLabel": {
|
||||
lineHeight: 1.2,
|
||||
fontSize: 24,
|
||||
background: "rgb(0 0 0 / 0.5)",
|
||||
backdropFilter: "blur(5px)",
|
||||
padding: 1,
|
||||
borderRadius: "10px",
|
||||
border: "1px solid rgb(255 255 255 / 0.15)",
|
||||
boxShadow: "0 0 10px rgb(0 0 0 / 0.4) ",
|
||||
transform: "translatey(-120%) scale(0)",
|
||||
"&:before": {
|
||||
display: "none",
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: item.Name ?? "Unknown Title",
|
||||
artist: item.Artists?.join(", ") ?? "Unknown Artist",
|
||||
album: item.Album ?? "Unknown Album",
|
||||
artwork: imageUrl
|
||||
? [
|
||||
{
|
||||
src: imageUrl,
|
||||
sizes: "512x512",
|
||||
type: "image/jpeg",
|
||||
},
|
||||
"&.MuiSlider-valueLabelOpen": {
|
||||
transform: "translateY(-120%) scale(1)",
|
||||
},
|
||||
"& > *": {
|
||||
transform: "rotate(0deg)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
useAudioPlayback.setState(useAudioPlayback.getInitialState());
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">close</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
),
|
||||
[volume, isMuted, currentTrack],
|
||||
);
|
||||
|
||||
// if (audioRef.current) {
|
||||
// audioRef.current.addEventListener("change", () => {
|
||||
// console.log("Audio Player changed state : ", currentTrack);
|
||||
// });
|
||||
// audioRef.current.addEventListener("ended", () => {
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
]
|
||||
: [],
|
||||
});
|
||||
}
|
||||
}, [item, api]);
|
||||
|
||||
// Media Session Action Handlers
|
||||
useEffect(() => {
|
||||
if ("mediaSession" in navigator) {
|
||||
navigator.mediaSession.setActionHandler("play", () => {
|
||||
audioRef.current?.play();
|
||||
});
|
||||
navigator.mediaSession.setActionHandler("pause", () => {
|
||||
audioRef.current?.pause();
|
||||
});
|
||||
navigator.mediaSession.setActionHandler("previoustrack", () => {
|
||||
if (user?.Id && api) {
|
||||
playItemFromQueue("previous", user.Id, api);
|
||||
}
|
||||
});
|
||||
navigator.mediaSession.setActionHandler("nexttrack", () => {
|
||||
if (user?.Id && api) {
|
||||
playItemFromQueue("next", user.Id, api);
|
||||
}
|
||||
});
|
||||
navigator.mediaSession.setActionHandler("seekto", (details) => {
|
||||
if (audioRef.current && details.seekTime !== undefined) {
|
||||
audioRef.current.currentTime = details.seekTime;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [api, user?.Id]);
|
||||
|
||||
const updatePositionState = () => {
|
||||
if (
|
||||
"mediaSession" in navigator &&
|
||||
audioRef.current &&
|
||||
!Number.isNaN(audioRef.current.duration)
|
||||
) {
|
||||
try {
|
||||
navigator.mediaSession.setPositionState({
|
||||
duration: audioRef.current.duration,
|
||||
playbackRate: audioRef.current.playbackRate,
|
||||
position: audioRef.current.currentTime,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error updating media session position state:", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handlePlayPause = () => {
|
||||
if (audioRef.current) {
|
||||
if (audioRef.current.paused) {
|
||||
audioRef.current.play();
|
||||
setPlaying(true);
|
||||
} else {
|
||||
audioRef.current.pause();
|
||||
setPlaying(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleTimeUpdate = (e: SyntheticEvent<HTMLAudioElement>) => {
|
||||
setProgress(secToTicks(e.currentTarget.currentTime));
|
||||
};
|
||||
|
||||
const handleEnded = () => {
|
||||
setPlaying(false);
|
||||
if (tracks?.[currentTrack + 1]?.Id && api && user?.Id) {
|
||||
playItemFromQueue("next", user.Id, api);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSeekCommit = (value: number) => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.currentTime = ticksToSec(value);
|
||||
setProgress(value);
|
||||
}
|
||||
};
|
||||
|
||||
const handleVolumeChange = (newVolume: number) => {
|
||||
setVolume(newVolume);
|
||||
};
|
||||
|
||||
const handleMuteToggle = () => {
|
||||
setIsMuted(!isMuted);
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
useAudioPlayback.setState(useAudioPlayback.getInitialState());
|
||||
};
|
||||
|
||||
const handleNavigate = () => {
|
||||
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 = () => {
|
||||
setPlaying(true);
|
||||
updatePositionState();
|
||||
if ("mediaSession" in navigator) {
|
||||
navigator.mediaSession.playbackState = "playing";
|
||||
}
|
||||
};
|
||||
const onPause = () => {
|
||||
setPlaying(false);
|
||||
updatePositionState();
|
||||
if ("mediaSession" in navigator) {
|
||||
navigator.mediaSession.playbackState = "paused";
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<AnimatePresence mode="sync">
|
||||
{display && (
|
||||
<motion.div
|
||||
initial={{
|
||||
transform: "translateY(100%)",
|
||||
}}
|
||||
initial={{ transform: "translate(-50%, 150%)" }}
|
||||
animate={{
|
||||
transform:
|
||||
location.pathname === "/player/audio"
|
||||
? "translateY(100%)"
|
||||
: "translateY(0%)",
|
||||
}}
|
||||
exit={{
|
||||
transform: "translateY(100%)",
|
||||
}}
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.2,
|
||||
ease: "easeInOut",
|
||||
? "translate(-50%, 150%)"
|
||||
: "translate(-50%, 0%)",
|
||||
}}
|
||||
exit={{ transform: "translate(-50%, 150%)" }}
|
||||
transition={{ duration: 0.3, ease: "circOut" }}
|
||||
className="audio-player glass"
|
||||
>
|
||||
{info}
|
||||
<PlayerInfo
|
||||
item={item}
|
||||
api={api}
|
||||
trackName={tracks?.[currentTrack]?.Name ?? "Unknown Track"}
|
||||
/>
|
||||
|
||||
<audio
|
||||
autoPlay
|
||||
src={url}
|
||||
ref={audioRef}
|
||||
key={item?.Id ?? "noItem"}
|
||||
onTimeUpdate={(e) =>
|
||||
setProgress(secToTicks(e.currentTarget.currentTime))
|
||||
}
|
||||
onEnded={() => {
|
||||
if (tracks?.[currentTrack + 1]?.Id && api && user?.Id) {
|
||||
playItemFromQueue("next", user.Id, api);
|
||||
}
|
||||
}}
|
||||
onTimeUpdate={handleTimeUpdate}
|
||||
onEnded={handleEnded}
|
||||
onPlay={onPlay}
|
||||
onPause={onPause}
|
||||
onSeeked={updatePositionState}
|
||||
onLoadedMetadata={updatePositionState}
|
||||
id="audio-player"
|
||||
/>
|
||||
|
||||
<div className="audio-player-controls">
|
||||
{controls}
|
||||
<div
|
||||
style={{
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
gap: "1em",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
style={{
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
{getRuntimeMusic(progress)}
|
||||
</Typography>
|
||||
<Slider
|
||||
value={isScrubbing ? sliderProgress : progress}
|
||||
step={1}
|
||||
size="small"
|
||||
max={item?.RunTimeTicks ?? 1}
|
||||
onChange={(_, value) => {
|
||||
setIsScrubbing(true);
|
||||
Array.isArray(value)
|
||||
? setSliderProgress(value[0])
|
||||
: setSliderProgress(value);
|
||||
}}
|
||||
onChangeCommitted={(_, value) => {
|
||||
if (!audioRef.current) {
|
||||
console.error("Audio ref not found");
|
||||
return;
|
||||
}
|
||||
setIsScrubbing(false);
|
||||
// console.log(ticksToSec(value * item.RunTimeTicks));
|
||||
Array.isArray(value)
|
||||
? setProgress(value[0])
|
||||
: setProgress(value);
|
||||
if (Array.isArray(value)) {
|
||||
audioRef.current.currentTime = ticksToSec(value[0]);
|
||||
} else {
|
||||
audioRef.current.currentTime = ticksToSec(value);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
fontWeight={300}
|
||||
style={{
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
{getRuntimeMusic(item?.RunTimeTicks ?? 0)}
|
||||
</Typography>
|
||||
</div>
|
||||
<PlayerControls playing={playing} onPlayPause={handlePlayPause} />
|
||||
<PlayerProgress
|
||||
progress={progress}
|
||||
duration={item?.RunTimeTicks ?? 1}
|
||||
onSeekCommit={handleSeekCommit}
|
||||
/>
|
||||
</div>
|
||||
{buttons}
|
||||
|
||||
<PlayerActions onNavigate={handleNavigate} onClose={handleClose}>
|
||||
<PlayerVolume
|
||||
volume={volume}
|
||||
isMuted={isMuted}
|
||||
onVolumeChange={handleVolumeChange}
|
||||
onMuteToggle={handleMuteToggle}
|
||||
/>
|
||||
</PlayerActions>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { endsAt } from "@/utils/date/time";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const EndsAtDisplay = () => {
|
||||
const { currentTime, itemDuration } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
currentTime: state.playerState.currentTime,
|
||||
itemDuration:
|
||||
state.metadata.itemDuration ?? state.metadata.item?.RunTimeTicks,
|
||||
})),
|
||||
);
|
||||
|
||||
if (!itemDuration) return <Typography variant="subtitle1">--:--</Typography>;
|
||||
|
||||
const remaining = itemDuration - (currentTime ?? 0);
|
||||
|
||||
return (
|
||||
<Typography variant="subtitle1">
|
||||
{endsAt(remaining)}
|
||||
</Typography>
|
||||
);
|
||||
};
|
||||
|
||||
export default EndsAtDisplay;
|
||||
@@ -0,0 +1,53 @@
|
||||
import { Button, Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
|
||||
interface ErrorDisplayProps {
|
||||
error: any;
|
||||
onRetry?: () => void;
|
||||
onExit?: () => void;
|
||||
}
|
||||
|
||||
const ErrorDisplay = ({ error, onRetry, onExit }: ErrorDisplayProps) => {
|
||||
if (!error) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
backgroundColor: "rgba(0, 0, 0, 0.8)",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
zIndex: 100,
|
||||
color: "white",
|
||||
gap: "1rem",
|
||||
}}
|
||||
>
|
||||
<Typography variant="h5" color="error">
|
||||
Playback Error
|
||||
</Typography>
|
||||
<Typography variant="body1">
|
||||
{error.message || "An unknown error occurred during playback."}
|
||||
</Typography>
|
||||
<div style={{ display: "flex", gap: "1rem" }}>
|
||||
{onRetry && (
|
||||
<Button variant="contained" color="primary" onClick={onRetry}>
|
||||
Retry
|
||||
</Button>
|
||||
)}
|
||||
{onExit && (
|
||||
<Button variant="outlined" color="secondary" onClick={onExit}>
|
||||
Exit
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ErrorDisplay;
|
||||
@@ -0,0 +1,34 @@
|
||||
import { CircularProgress } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const LoadingIndicator = () => {
|
||||
const { isBuffering } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
isBuffering: state.playerState.isBuffering,
|
||||
})),
|
||||
);
|
||||
if (!isBuffering) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
zIndex: 2,
|
||||
position: "absolute",
|
||||
height: "100vh",
|
||||
width: "100vw",
|
||||
top: 0,
|
||||
left: 0,
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<CircularProgress size={72} thickness={1.4} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default LoadingIndicator;
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import ticksDisplay from "@/utils/methods/ticksDisplay";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const ProgressDisplay = () => {
|
||||
const { currentTime, itemDuration, isUserSeeking, seekValue } =
|
||||
usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
currentTime: state.playerState.currentTime,
|
||||
itemDuration:
|
||||
state.metadata.itemDuration ?? state.metadata.item?.RunTimeTicks,
|
||||
isUserSeeking: state.playerState.isUserSeeking,
|
||||
seekValue: state.playerState.seekValue,
|
||||
})),
|
||||
);
|
||||
return (
|
||||
<div className="video-player-osd-controls-timeline-text">
|
||||
<Typography>
|
||||
{ticksDisplay(isUserSeeking ? (seekValue ?? 0) : (currentTime ?? 0))}
|
||||
</Typography>
|
||||
<Typography>{ticksDisplay(itemDuration ?? 0)}</Typography>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProgressDisplay;
|
||||
@@ -0,0 +1,165 @@
|
||||
import { IconButton, Paper, Typography } from "@mui/material";
|
||||
import React, { type RefObject, useEffect, useState } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
interface StatsForNerdsProps {
|
||||
playerRef: RefObject<HTMLVideoElement>;
|
||||
}
|
||||
|
||||
const StatsForNerds = ({ playerRef }: StatsForNerdsProps) => {
|
||||
const {
|
||||
showStatsForNerds,
|
||||
toggleShowStatsForNerds,
|
||||
itemId,
|
||||
mediaSourceId,
|
||||
playsessionId,
|
||||
volume,
|
||||
isBuffering,
|
||||
playbackStream,
|
||||
mediaSource,
|
||||
} = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
showStatsForNerds: state.playerState.showStatsForNerds,
|
||||
toggleShowStatsForNerds: state.toggleShowStatsForNerds,
|
||||
itemId: state.metadata.item?.Id,
|
||||
mediaSourceId: state.mediaSource.id,
|
||||
playsessionId: state.playsessionId,
|
||||
volume: state.playerState.volume,
|
||||
isBuffering: state.playerState.isBuffering,
|
||||
playbackStream: state.playbackStream,
|
||||
mediaSource: state.mediaSource,
|
||||
})),
|
||||
);
|
||||
|
||||
const [videoStats, setVideoStats] = useState<{
|
||||
resolution: string;
|
||||
droppedFrames: number;
|
||||
totalFrames: number;
|
||||
buffered: string;
|
||||
}>({
|
||||
resolution: "-",
|
||||
droppedFrames: 0,
|
||||
totalFrames: 0,
|
||||
buffered: "-",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!showStatsForNerds) return;
|
||||
|
||||
const interval = setInterval(() => {
|
||||
if (playerRef.current) {
|
||||
const internalPlayer = playerRef.current as HTMLVideoElement;
|
||||
if (internalPlayer) {
|
||||
const quality = internalPlayer.getVideoPlaybackQuality?.();
|
||||
|
||||
let bufferedEnd = 0;
|
||||
if (internalPlayer.buffered.length > 0) {
|
||||
// Find the buffered range that covers the current time
|
||||
for (let i = 0; i < internalPlayer.buffered.length; i++) {
|
||||
if (
|
||||
internalPlayer.buffered.start(i) <=
|
||||
internalPlayer.currentTime &&
|
||||
internalPlayer.buffered.end(i) >= internalPlayer.currentTime
|
||||
) {
|
||||
bufferedEnd = internalPlayer.buffered.end(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setVideoStats({
|
||||
resolution:
|
||||
internalPlayer.videoWidth && internalPlayer.videoHeight
|
||||
? `${internalPlayer.videoWidth}x${internalPlayer.videoHeight}`
|
||||
: "-",
|
||||
droppedFrames: quality?.droppedVideoFrames ?? 0,
|
||||
totalFrames: quality?.totalVideoFrames ?? 0,
|
||||
buffered: `${(bufferedEnd - internalPlayer.currentTime).toFixed(2)}s`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [showStatsForNerds, playerRef]);
|
||||
|
||||
if (!showStatsForNerds) return null;
|
||||
|
||||
return (
|
||||
<Paper
|
||||
className="glass"
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: "2em",
|
||||
left: "2em",
|
||||
padding: "1em",
|
||||
color: "white",
|
||||
zIndex: 100,
|
||||
maxWidth: "400px",
|
||||
fontSize: "0.8rem",
|
||||
fontFamily: "monospace",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
marginBottom: "0.5em",
|
||||
}}
|
||||
>
|
||||
<Typography variant="subtitle2" fontWeight="bold">
|
||||
Stats for Nerds
|
||||
</Typography>
|
||||
<IconButton
|
||||
size="small"
|
||||
onClick={toggleShowStatsForNerds}
|
||||
sx={{ color: "white" }}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: "1.2rem" }}
|
||||
>
|
||||
close
|
||||
</span>
|
||||
</IconButton>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: "grid",
|
||||
gridTemplateColumns: "auto 1fr",
|
||||
gap: "0.5em 1em",
|
||||
}}
|
||||
>
|
||||
<span>Video ID:</span> <span>{itemId}</span>
|
||||
<span>Media Source ID:</span> <span>{mediaSourceId}</span>
|
||||
<span>Play Session ID:</span> <span>{playsessionId}</span>
|
||||
<span>Playback Method:</span>{" "}
|
||||
<span>{mediaSource.playMethod}</span>
|
||||
<span>Container:</span> <span>{mediaSource.container}</span>
|
||||
<span>Video Codec:</span> <span>{mediaSource.videoCodec}</span>
|
||||
<span>Audio Codec:</span> <span>{mediaSource.audioCodec}</span>
|
||||
<span>Bitrate:</span>{" "}
|
||||
<span>
|
||||
{mediaSource.bitrate
|
||||
? `${(mediaSource.bitrate / 1000000).toFixed(2)} Mbps`
|
||||
: "-"}
|
||||
</span>
|
||||
<span>Stream URL:</span>{" "}
|
||||
<span style={{ wordBreak: "break-all" }}>{playbackStream}</span>
|
||||
<span>Resolution:</span> <span>{videoStats.resolution}</span>
|
||||
<span>Volume:</span> <span>{Math.round(volume * 100)}%</span>
|
||||
<span>Buffer Health:</span> <span>{videoStats.buffered}</span>
|
||||
<span>Dropped Frames:</span>{" "}
|
||||
<span>
|
||||
{videoStats.droppedFrames} / {videoStats.totalFrames}
|
||||
</span>
|
||||
<span>Is Buffering:</span> <span>{isBuffering ? "Yes" : "No"}</span>
|
||||
</div>
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
|
||||
export default StatsForNerds;
|
||||
@@ -0,0 +1,36 @@
|
||||
import { LinearProgress } from "@mui/material";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const VolumeChangeOverlay = () => {
|
||||
const { playerVolume, showVolumeIndicator } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
playerVolume: state.playerState.volume,
|
||||
showVolumeIndicator: state.isVolumeInidcatorVisible,
|
||||
})),
|
||||
);
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{showVolumeIndicator && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
className="video-volume-indicator glass"
|
||||
>
|
||||
<div className="material-symbols-rounded">
|
||||
{playerVolume > 0.7 ? "volume_up" : "volume_down"}
|
||||
</div>
|
||||
<LinearProgress
|
||||
style={{ width: "100%" }}
|
||||
value={playerVolume * 100}
|
||||
variant="determinate"
|
||||
/>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
);
|
||||
};
|
||||
export default VolumeChangeOverlay;
|
||||
@@ -0,0 +1,351 @@
|
||||
import type { TrickplayInfo } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Slider, Tooltip, Typography } from "@mui/material";
|
||||
import type { Instance } from "@popperjs/core";
|
||||
import React, {
|
||||
type MouseEvent,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { ticksToMs } from "@/utils/date/time";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const ticksDisplay = (ticks: number) => {
|
||||
const time = Math.round(ticks / 10000);
|
||||
let formatedTime = "";
|
||||
let timeSec = Math.floor(time / 1000);
|
||||
let timeMin = Math.floor(timeSec / 60);
|
||||
timeSec -= timeMin * 60;
|
||||
timeSec = timeSec === 0 ? 0o0 : timeSec;
|
||||
const timeHr = Math.floor(timeMin / 60);
|
||||
timeMin -= timeHr * 60;
|
||||
formatedTime = `${timeHr.toLocaleString([], {
|
||||
minimumIntegerDigits: 2,
|
||||
useGrouping: false,
|
||||
})}:${timeMin.toLocaleString([], {
|
||||
minimumIntegerDigits: 2,
|
||||
useGrouping: false,
|
||||
})}:${timeSec.toLocaleString([], {
|
||||
minimumIntegerDigits: 2,
|
||||
useGrouping: false,
|
||||
})}`;
|
||||
return formatedTime;
|
||||
};
|
||||
|
||||
const BubbleSlider = () => {
|
||||
const api = useApiInContext((state) => state.api);
|
||||
const {
|
||||
seekValue,
|
||||
currentTime,
|
||||
isUserSeeking,
|
||||
// setIsUserSeeking,
|
||||
// setSeekValue,
|
||||
// seekTo,
|
||||
itemDuration,
|
||||
itemChapters,
|
||||
mediaSource,
|
||||
itemTrickplay,
|
||||
itemId,
|
||||
handleStartSeek,
|
||||
handleStopSeek,
|
||||
} = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekValue: state.playerState.seekValue,
|
||||
currentTime: state.playerState.currentTime,
|
||||
isUserSeeking: state.playerState.isUserSeeking,
|
||||
// setIsUserSeeking: state.setIsUserSeeking,
|
||||
// setSeekValue: state.setSeekValue,
|
||||
// seekTo: state.seekTo,
|
||||
itemDuration: state.metadata.item.RunTimeTicks,
|
||||
itemChapters: state.metadata.item.Chapters,
|
||||
mediaSource: state.mediaSource,
|
||||
itemTrickplay: state.metadata.item.Trickplay,
|
||||
itemId: state.metadata.item.Id,
|
||||
handleStartSeek: state.handleStartSeek,
|
||||
handleStopSeek: state.handleStopSeek,
|
||||
})),
|
||||
);
|
||||
|
||||
const positionRef = useRef<{ x: number; y: number }>({
|
||||
x: 0,
|
||||
y: 0,
|
||||
});
|
||||
const popperRef = useRef<Instance>(null);
|
||||
const areaRef = useRef<HTMLDivElement>(null);
|
||||
const rafRef = useRef<number | null>(null);
|
||||
|
||||
const [hoverProgress, setHoverProgress] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (rafRef.current) {
|
||||
cancelAnimationFrame(rafRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleSliderHover = useCallback(
|
||||
(event: MouseEvent) => {
|
||||
const clientX = event.clientX;
|
||||
const clientY = event.clientY;
|
||||
|
||||
if (
|
||||
positionRef.current.x === clientX &&
|
||||
positionRef.current.y === clientY
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
positionRef.current = { x: clientX, y: clientY };
|
||||
|
||||
if (rafRef.current) return;
|
||||
|
||||
rafRef.current = requestAnimationFrame(() => {
|
||||
if (areaRef.current) {
|
||||
const rect = areaRef.current.getBoundingClientRect();
|
||||
const width = rect.width;
|
||||
const distX = clientX - rect.left;
|
||||
const percentageCovered = distX / width;
|
||||
setHoverProgress(percentageCovered * (itemDuration ?? 0));
|
||||
if (popperRef.current != null) {
|
||||
popperRef.current.update();
|
||||
}
|
||||
}
|
||||
rafRef.current = null;
|
||||
});
|
||||
},
|
||||
[itemDuration],
|
||||
);
|
||||
|
||||
const chapterMarks = useMemo(() => {
|
||||
const marks: { value: number }[] = [];
|
||||
itemChapters?.forEach((val) => {
|
||||
marks.push({ value: val.StartPositionTicks ?? 0 });
|
||||
});
|
||||
return marks;
|
||||
}, [itemChapters]);
|
||||
|
||||
const sliderDisplayFormat = (value: number) => {
|
||||
const currentChapter = itemChapters?.filter((chapter, index) => {
|
||||
if (index + 1 === itemChapters?.length) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
(itemChapters?.[index + 1]?.StartPositionTicks ?? value) - value >= 0 &&
|
||||
(chapter.StartPositionTicks ?? value) - value < 0
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
let trickplayResolution: TrickplayInfo | undefined;
|
||||
const trickplayResolutions = mediaSource.id
|
||||
? itemTrickplay?.[mediaSource.id]
|
||||
: null;
|
||||
if (trickplayResolutions) {
|
||||
let bestWidth: number | undefined;
|
||||
const maxWidth = window.screen.width * window.devicePixelRatio * 0.2;
|
||||
for (const [_, trickInfo] of Object.entries(trickplayResolutions)) {
|
||||
if (
|
||||
!bestWidth ||
|
||||
(trickInfo.Width &&
|
||||
((trickInfo.Width < bestWidth && bestWidth > maxWidth) ||
|
||||
(trickInfo.Width > bestWidth && bestWidth <= maxWidth)))
|
||||
) {
|
||||
bestWidth = trickInfo.Width;
|
||||
}
|
||||
}
|
||||
if (bestWidth) {
|
||||
trickplayResolution = trickplayResolutions[bestWidth];
|
||||
}
|
||||
}
|
||||
let trickplayStyle: React.CSSProperties | undefined;
|
||||
|
||||
if (
|
||||
trickplayResolution?.TileWidth &&
|
||||
trickplayResolution.TileHeight &&
|
||||
trickplayResolution.Width &&
|
||||
trickplayResolution.Height
|
||||
) {
|
||||
const currentTrickplayImage = trickplayResolution?.Interval
|
||||
? Math.floor(ticksToMs(value) / trickplayResolution?.Interval)
|
||||
: 0;
|
||||
const trickplayImageSize =
|
||||
trickplayResolution?.TileWidth * trickplayResolution?.TileHeight; // this gives the area of a single tile
|
||||
|
||||
const trickplayImageOffset = currentTrickplayImage % trickplayImageSize; // this gives the tile index inside a trickplay image
|
||||
const index = Math.floor(currentTrickplayImage / trickplayImageSize); // this gives the index of trickplay image
|
||||
|
||||
const imageOffsetX =
|
||||
trickplayImageOffset % trickplayResolution?.TileWidth; // this gives the x coordinate of tile in trickplay image
|
||||
const imageOffsetY = Math.floor(
|
||||
trickplayImageOffset / trickplayResolution?.TileWidth,
|
||||
); // this gives the y coordinate of tile in trickplay image
|
||||
const backgroundOffsetX = -(imageOffsetX * trickplayResolution?.Width);
|
||||
const backgroundOffsetY = -(imageOffsetY * trickplayResolution?.Height);
|
||||
|
||||
const imgUrlParamsObject: Record<string, string> = {
|
||||
api_key: String(api?.accessToken),
|
||||
MediaSourceId: mediaSource.id ?? "",
|
||||
};
|
||||
const imgUrlParams = new URLSearchParams(imgUrlParamsObject).toString();
|
||||
|
||||
const _imageAspectRatio =
|
||||
trickplayResolution.Width / trickplayResolution.Height;
|
||||
|
||||
trickplayStyle = {
|
||||
backgroundImage: `url(${api?.basePath}/Videos/${itemId}/Trickplay/${trickplayResolution.Width}/${index}.jpg?${imgUrlParams})`,
|
||||
backgroundPositionX: `${backgroundOffsetX}px`,
|
||||
backgroundPositionY: `${backgroundOffsetY}px`,
|
||||
width: `${trickplayResolution.Width}px`,
|
||||
height: `${trickplayResolution.Height}px`,
|
||||
borderBottom: "1px solid rgba(255,255,255,0.1)",
|
||||
borderRadius: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const chapterName = currentChapter?.[0]?.Name;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex flex-column video-osb-bubble"
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{trickplayStyle && (
|
||||
<div className="video-osd-trickplayBubble" style={trickplayStyle} />
|
||||
)}
|
||||
<div
|
||||
style={{
|
||||
padding: "8px 12px",
|
||||
textAlign: "center",
|
||||
width: "100%",
|
||||
boxSizing: "border-box",
|
||||
}}
|
||||
>
|
||||
{chapterName && (
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
sx={{
|
||||
fontWeight: "bold",
|
||||
mb: 0.5,
|
||||
color: "white",
|
||||
textShadow: "0 2px 4px rgba(0,0,0,0.5)",
|
||||
}}
|
||||
>
|
||||
{chapterName}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
color: "rgba(255,255,255,0.9)",
|
||||
fontVariantNumeric: "tabular-nums",
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
{ticksDisplay(value)}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const virtualAnchorEl = useMemo(() => {
|
||||
return {
|
||||
getBoundingClientRect: () => {
|
||||
return new DOMRect(
|
||||
positionRef.current.x,
|
||||
areaRef.current?.getBoundingClientRect().y ?? 0,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
},
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
// title={sliderDisplayFormat(
|
||||
// positionRef.current.x - areaRef.current!.getBoundingClientRect().x,
|
||||
// )}
|
||||
title={sliderDisplayFormat(hoverProgress)}
|
||||
placement="top"
|
||||
slotProps={{
|
||||
popper: {
|
||||
popperRef,
|
||||
anchorEl: virtualAnchorEl,
|
||||
// disablePortal: true,
|
||||
},
|
||||
tooltip: {
|
||||
className: "glass",
|
||||
style: {
|
||||
width: "auto",
|
||||
maxWidth: "none",
|
||||
overflow: "hidden",
|
||||
padding: "0",
|
||||
borderRadius: "12px",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Slider
|
||||
value={isUserSeeking ? seekValue : currentTime}
|
||||
max={itemDuration ?? 0}
|
||||
step={1}
|
||||
onChange={(_, newValue) => {
|
||||
// setIsUserSeeking(true);
|
||||
Array.isArray(newValue)
|
||||
? handleStartSeek(newValue[0])
|
||||
: handleStartSeek(newValue);
|
||||
}}
|
||||
onChangeCommitted={(_, newValue) => {
|
||||
// setIsUserSeeking(false);
|
||||
// Array.isArray(newValue)
|
||||
// ? setSeekValue(newValue[0])
|
||||
// : setSeekValue(newValue);
|
||||
if (Array.isArray(newValue)) {
|
||||
handleStopSeek(newValue[0]);
|
||||
} else {
|
||||
handleStopSeek(newValue);
|
||||
}
|
||||
}}
|
||||
sx={{
|
||||
"& .MuiSlider-thumb": {
|
||||
width: 14,
|
||||
height: 14,
|
||||
transition: "0.1s ease-in-out",
|
||||
opacity: 0,
|
||||
"&.Mui-active": {
|
||||
width: 20,
|
||||
height: 20,
|
||||
opacity: 1,
|
||||
},
|
||||
},
|
||||
"&:hover .MuiSlider-thumb": {
|
||||
opacity: 1,
|
||||
},
|
||||
"& .MuiSlider-rail": {
|
||||
opacity: 0.28,
|
||||
background: "white",
|
||||
},
|
||||
}}
|
||||
marks={chapterMarks}
|
||||
valueLabelDisplay="off"
|
||||
ref={areaRef}
|
||||
onMouseMove={handleSliderHover}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
export default BubbleSlider;
|
||||
@@ -0,0 +1,25 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React, { useTransition } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { toggleSubtitleTrack, usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const CaptionsButton = () => {
|
||||
const { subtitle } = usePlaybackStore(
|
||||
useShallow((state) => ({ subtitle: state.mediaSource.subtitle })),
|
||||
);
|
||||
|
||||
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
||||
|
||||
return (
|
||||
<IconButton
|
||||
disabled={subtitle?.allTracks?.length === 0 || subtitleIsChanging}
|
||||
onClick={() => startSubtitleChange(toggleSubtitleTrack)}
|
||||
>
|
||||
<span className={"material-symbols-rounded"}>
|
||||
{subtitle?.enable ? "closed_caption" : "closed_caption_disabled"}
|
||||
</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default CaptionsButton;
|
||||
@@ -0,0 +1,58 @@
|
||||
import { IconButton, Menu, MenuItem } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { ticksToSec } from "@/utils/date/time";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const ChaptersListButton = () => {
|
||||
const { itemChapters, seekTo } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
itemChapters: state.metadata.item?.Chapters,
|
||||
seekTo: state.seekTo,
|
||||
})),
|
||||
);
|
||||
const [showChapterList, setShowChapterList] =
|
||||
React.useState<null | HTMLElement>(null);
|
||||
const handleShowChapterList = (event: React.MouseEvent<HTMLElement>) => {
|
||||
setShowChapterList(event.currentTarget);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<IconButton
|
||||
disabled={itemChapters?.length === 0}
|
||||
onClick={handleShowChapterList}
|
||||
>
|
||||
<span className="material-symbols-rounded">list</span>
|
||||
</IconButton>
|
||||
<Menu
|
||||
open={Boolean(showChapterList)}
|
||||
anchorEl={showChapterList}
|
||||
onClose={() => setShowChapterList(null)}
|
||||
anchorOrigin={{
|
||||
vertical: "top",
|
||||
horizontal: "center",
|
||||
}}
|
||||
transformOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "center",
|
||||
}}
|
||||
>
|
||||
{itemChapters?.length &&
|
||||
itemChapters?.map((chapter) => (
|
||||
<MenuItem
|
||||
key={chapter.Name}
|
||||
onClick={() => {
|
||||
seekTo(ticksToSec(chapter.StartPositionTicks ?? 0));
|
||||
setShowChapterList(null); // Close the chapter list menu
|
||||
}}
|
||||
>
|
||||
{chapter.Name}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Menu>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChaptersListButton;
|
||||
@@ -0,0 +1,30 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React, { useEffect } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const ForwardButton = () => {
|
||||
const { seekForward } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekForward: state.seekForward,
|
||||
})),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
navigator.mediaSession.setActionHandler("seekforward", (details) => {
|
||||
if (details.seekOffset) {
|
||||
seekForward(details.seekOffset);
|
||||
} else {
|
||||
seekForward(10); // Default to 10 seconds
|
||||
}
|
||||
});
|
||||
}, [seekForward]);
|
||||
|
||||
return (
|
||||
<IconButton onClick={() => seekForward(15)}>
|
||||
<span className="material-symbols-rounded fill">fast_forward</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default ForwardButton;
|
||||
@@ -0,0 +1,23 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const FullscreenButton = () => {
|
||||
const { isPlayerFullscreen, toggleIsPlayerFullscreen } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
isPlayerFullscreen: state.playerState.isPlayerFullscreen,
|
||||
toggleIsPlayerFullscreen: state.toggleIsPlayerFullscreen,
|
||||
})),
|
||||
);
|
||||
|
||||
return (
|
||||
<IconButton onClick={toggleIsPlayerFullscreen}>
|
||||
<span className="material-symbols-rounded fill">
|
||||
{isPlayerFullscreen ? "fullscreen_exit" : "fullscreen"}
|
||||
</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default FullscreenButton;
|
||||
@@ -0,0 +1,19 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const NextChapterButton = () => {
|
||||
const { seekToNextChapter } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekToNextChapter: state.seekToNextChapter,
|
||||
})),
|
||||
);
|
||||
return (
|
||||
<IconButton onClick={() => seekToNextChapter()}>
|
||||
<span className="material-symbols-rounded fill">last_page</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default NextChapterButton;
|
||||
@@ -0,0 +1,22 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const PlayPauseButton = () => {
|
||||
const { isPlayerPlaying, toggleIsPlaying } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
isPlayerPlaying: state.playerState.isPlayerPlaying,
|
||||
toggleIsPlaying: state.toggleIsPlaying,
|
||||
})),
|
||||
);
|
||||
return (
|
||||
<IconButton onClick={toggleIsPlaying}>
|
||||
<span className="material-symbols-rounded fill">
|
||||
{isPlayerPlaying ? "pause" : "play_arrow"}
|
||||
</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default PlayPauseButton;
|
||||
@@ -0,0 +1,20 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const PrevChapterButton = () => {
|
||||
const { seekToPrevChapter } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekToPrevChapter: state.seekToPrevChapter,
|
||||
})),
|
||||
);
|
||||
|
||||
return (
|
||||
<IconButton onClick={seekToPrevChapter}>
|
||||
<span className="material-symbols-rounded fill">first_page</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default PrevChapterButton;
|
||||
@@ -0,0 +1,34 @@
|
||||
import { IconButton } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const RewindButton = () => {
|
||||
const { seekBackward } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
seekBackward: state.seekBackward,
|
||||
})),
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
navigator.mediaSession.setActionHandler("seekbackward", (details) => {
|
||||
if (details.seekOffset) {
|
||||
seekBackward(details.seekOffset);
|
||||
} else {
|
||||
seekBackward(10); // Default to 10 seconds
|
||||
}
|
||||
});
|
||||
}, [seekBackward]);
|
||||
|
||||
return (
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
seekBackward(15);
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded fill">fast_rewind</span>
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default RewindButton;
|
||||
@@ -0,0 +1,94 @@
|
||||
import { Box, Button } from "@mui/material";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const SkipSegmentButton = () => {
|
||||
const {
|
||||
mediaSegments,
|
||||
currentSegmentIndex,
|
||||
skipSegment,
|
||||
activeSegmentId,
|
||||
isUserHovering,
|
||||
isPlayerPlaying,
|
||||
isUserSeeking,
|
||||
} = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
mediaSegments: state.metadata.mediaSegments,
|
||||
currentSegmentIndex: state.nextSegmentIndex - 1,
|
||||
skipSegment: state.skipSegment,
|
||||
activeSegmentId: state.activeSegmentId,
|
||||
isUserHovering: state.playerState.isUserHovering,
|
||||
isPlayerPlaying: state.playerState.isPlayerPlaying,
|
||||
isUserSeeking: state.playerState.isUserSeeking,
|
||||
})),
|
||||
);
|
||||
|
||||
const shouldShow =
|
||||
mediaSegments?.Items?.length &&
|
||||
currentSegmentIndex >= 0 &&
|
||||
activeSegmentId &&
|
||||
mediaSegments?.Items?.[currentSegmentIndex].Type !== "Outro";
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{shouldShow && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, x: 20, scale: 0.9 }}
|
||||
animate={{ opacity: 1, x: 0, scale: 1 }}
|
||||
exit={{ opacity: 0, x: 20, scale: 0.9 }}
|
||||
transition={{
|
||||
type: "spring",
|
||||
stiffness: 300,
|
||||
damping: 30,
|
||||
}}
|
||||
style={{
|
||||
position: "absolute",
|
||||
right: "3em",
|
||||
zIndex: 10000,
|
||||
bottom:
|
||||
isUserHovering || !isPlayerPlaying || isUserSeeking ? "20vh" : "6em",
|
||||
transition: "bottom 0.3s ease-in-out",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
onClick={skipSegment}
|
||||
variant="contained"
|
||||
startIcon={
|
||||
<span className="material-symbols-rounded">skip_next</span>
|
||||
}
|
||||
sx={{
|
||||
bgcolor: "rgba(20, 20, 20, 0.6)",
|
||||
backdropFilter: "blur(16px) saturate(180%)",
|
||||
color: "white",
|
||||
border: "1px solid rgba(255, 255, 255, 0.1)",
|
||||
borderRadius: "12px",
|
||||
padding: "12px 24px",
|
||||
textTransform: "none",
|
||||
fontSize: "1rem",
|
||||
fontWeight: 600,
|
||||
boxShadow: "0 8px 32px 0 rgba(0, 0, 0, 0.2)",
|
||||
transition: "all 0.2s ease",
|
||||
"&:hover": {
|
||||
bgcolor: "rgba(255, 255, 255, 0.1)",
|
||||
transform: "scale(1.02)",
|
||||
boxShadow: "0 8px 32px 0 rgba(0, 0, 0, 0.3)",
|
||||
border: "1px solid rgba(255, 255, 255, 0.2)",
|
||||
},
|
||||
"&:active": {
|
||||
transform: "scale(0.98)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
Skip {mediaSegments?.Items?.[currentSegmentIndex].Type}
|
||||
</Button>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
);
|
||||
};
|
||||
|
||||
const SkipSegmentButtonMemo = React.memo(SkipSegmentButton);
|
||||
|
||||
export default SkipSegmentButtonMemo;
|
||||
@@ -0,0 +1,73 @@
|
||||
.video-player {
|
||||
background: black;
|
||||
position: absolute;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
top: 0;
|
||||
left: 0;
|
||||
&-osd {
|
||||
position: absolute;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
top: 0;
|
||||
left: 0;
|
||||
cursor: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-self: stretch;
|
||||
justify-content: space-between;
|
||||
padding: 2em 3em;
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
rgba(0, 0, 0, 0.8) 0%,
|
||||
rgba(0, 0, 0, 0) 25%,
|
||||
rgba(0, 0, 0, 0) 75%,
|
||||
rgba(0, 0, 0, 0.9) 100%
|
||||
);
|
||||
&.hovering {
|
||||
cursor: default;
|
||||
}
|
||||
&-controls {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
|
||||
&-timeline-text {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: space-between;
|
||||
margin-top: 0.5em;
|
||||
font-weight: 500;
|
||||
opacity: 0.9;
|
||||
}
|
||||
&-progress {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2em;
|
||||
align-items: stretch;
|
||||
justify-content: center;
|
||||
margin-bottom: 0.5em;
|
||||
&-bubble {
|
||||
width: 14em;
|
||||
top: 0;
|
||||
left: 0;
|
||||
transform-origin: bottom center;
|
||||
transform: translate(var(--left, 0), var(--top, 0));
|
||||
position: fixed;
|
||||
}
|
||||
}
|
||||
&-buttons {
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
.MuiSlider-valueLabel {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
overflow: hidden;
|
||||
border-radius: $border-radius-default;
|
||||
border: 1.2px solid rgb(255 255 255 / 0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||
import { IconButton, Slider, Typography } from "@mui/material";
|
||||
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React, {
|
||||
type MouseEvent,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||
import QueueButton from "@/components/buttons/queueButton";
|
||||
import BubbleSlider from "@/components/playback/videoPlayer/bubbleSlider";
|
||||
import { secToTicks } from "@/utils/date/time";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
import CaptionsButton from "./buttons/CaptionsButton";
|
||||
import ChaptersListButton from "./buttons/ChaptersListButton";
|
||||
import ForwardButton from "./buttons/ForwardButton";
|
||||
import FullscreenButton from "./buttons/FullscreenButton";
|
||||
import NextChapterButton from "./buttons/NextChapterButton";
|
||||
import PlayPauseButton from "./buttons/PlayPauseButton";
|
||||
import PrevChapterButton from "./buttons/PrevChapterButton";
|
||||
import RewindButton from "./buttons/RewindButton";
|
||||
import EndsAtDisplay from "./EndsAtDisplay";
|
||||
import VideoPlayerSettingsMenu from "./settingsMenu";
|
||||
|
||||
import "./controls.scss";
|
||||
import { clearQueue } from "@/utils/store/queue";
|
||||
import ProgressDisplay from "./ProgressDisplay";
|
||||
|
||||
/**
|
||||
* Constant for the volume change interval when using the mouse wheel.
|
||||
* This value determines how much the volume will change with each scroll step.
|
||||
*/
|
||||
const VOLUME_SCROLL_INTERVAL = 0.02;
|
||||
|
||||
type VideoPlayerControlsProps = {
|
||||
// isVisible: boolean;
|
||||
onHover?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||
onLeave?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||
};
|
||||
|
||||
const VideoPlayerControls = ({
|
||||
// isVisible,
|
||||
onHover,
|
||||
onLeave,
|
||||
}: VideoPlayerControlsProps) => {
|
||||
const playerOSDRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const api = useApiInContext((state) => state.api);
|
||||
const {
|
||||
mediaSourceId,
|
||||
itemId,
|
||||
itemName,
|
||||
episodeTitle,
|
||||
playsessionId,
|
||||
isPlayerPlaying,
|
||||
toggleIsPlaying,
|
||||
toggleIsPlayerFullscreen,
|
||||
isUserSeeking,
|
||||
// seekValue,
|
||||
isPlayerMuted,
|
||||
volume,
|
||||
setVolume,
|
||||
toggleIsPlayerMuted,
|
||||
increaseVolumeByStep,
|
||||
decreaseVolumeByStep,
|
||||
getCurrentTime,
|
||||
isUserHovering,
|
||||
} = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
mediaSourceId: state.mediaSource.id,
|
||||
itemChapters: state.metadata.item.Chapters,
|
||||
itemId: state.metadata.item.Id,
|
||||
itemName: state.metadata.itemName,
|
||||
episodeTitle: state.metadata.episodeTitle,
|
||||
// mediaSegments: state.metadata.mediaSegments,
|
||||
isPlayerPlaying: state.playerState.isPlayerPlaying,
|
||||
playsessionId: state.playsessionId,
|
||||
toggleIsPlaying: state.toggleIsPlaying,
|
||||
toggleIsPlayerFullscreen: state.toggleIsPlayerFullscreen,
|
||||
isUserSeeking: state.playerState.isUserSeeking,
|
||||
seekValue: state.playerState.seekValue,
|
||||
isPlayerMuted: state.playerState.isPlayerMuted,
|
||||
volume: state.playerState.volume,
|
||||
setVolume: state.setVolume,
|
||||
toggleIsPlayerMuted: state.toggleIsPlayerMuted,
|
||||
increaseVolumeByStep: state.increaseVolumeByStep,
|
||||
decreaseVolumeByStep: state.decreaseVolumeByStep,
|
||||
getCurrentTime: state.getCurrentTime,
|
||||
isUserHovering: state.playerState.isUserHovering,
|
||||
})),
|
||||
);
|
||||
|
||||
// Volume control with mouse wheel
|
||||
useEffect(() => {
|
||||
const handleMouseWheel = (event: WheelEvent) => {
|
||||
if (event.deltaY < 0) {
|
||||
increaseVolumeByStep(VOLUME_SCROLL_INTERVAL);
|
||||
} else if (event.deltaY > 0) {
|
||||
decreaseVolumeByStep(VOLUME_SCROLL_INTERVAL);
|
||||
}
|
||||
};
|
||||
|
||||
const currentRef = playerOSDRef.current;
|
||||
// attach the event listener
|
||||
currentRef?.addEventListener("wheel", handleMouseWheel);
|
||||
|
||||
// remove the event listener
|
||||
return () => {
|
||||
currentRef?.removeEventListener("wheel", handleMouseWheel);
|
||||
};
|
||||
}, [increaseVolumeByStep, decreaseVolumeByStep]);
|
||||
|
||||
const [clickTimeout, setClickTimeout] = useState<NodeJS.Timeout | null>(null);
|
||||
const [showVolumeControl, setShowVolumeControl] = useState(false);
|
||||
|
||||
const [settingsMenuRef, setSettingsMenuRef] =
|
||||
useState<HTMLButtonElement | null>(null);
|
||||
|
||||
// const creditInfo = mediaSegments?.Items?.find(
|
||||
// (segment) => segment.Type === "Outro",
|
||||
// );
|
||||
|
||||
// Credits and Next Episode Card
|
||||
// const [forceShowCredits, setForceShowCredits] = useState(false);
|
||||
// const showUpNextCard = useMemo(() => {
|
||||
// if (queue?.[currentQueueItemIndex]?.Id === queue?.[queue.length - 1]?.Id) {
|
||||
// return false; // Check if the current playing episode is last episode in queue
|
||||
// }
|
||||
// if (creditInfo) {
|
||||
// if (
|
||||
// currentTime >= (creditInfo.StartTicks ?? currentTime + 1) &&
|
||||
// currentTime < (creditInfo.EndTicks ?? 0)
|
||||
// )
|
||||
// return true;
|
||||
// }
|
||||
// if (
|
||||
// Math.ceil(ticksToSec(itemDuration) - ticksToSec(currentTime)) <= 30 &&
|
||||
// Math.ceil(ticksToSec(itemDuration) - ticksToSec(currentTime)) > 0
|
||||
// ) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }, [currentTime, creditInfo, itemDuration, queue, currentQueueItemIndex]);
|
||||
|
||||
const handleExitPlayer = useCallback(async () => {
|
||||
appWindow.getCurrent().setFullscreen(false);
|
||||
|
||||
history.back();
|
||||
if (!api) {
|
||||
throw Error("API is not available, cannot report playback stopped.");
|
||||
}
|
||||
// Report Jellyfin server: Playback has ended/stopped
|
||||
getPlaystateApi(api).reportPlaybackStopped({
|
||||
playbackStopInfo: {
|
||||
Failed: false,
|
||||
ItemId: itemId,
|
||||
MediaSourceId: mediaSourceId,
|
||||
PlaySessionId: playsessionId,
|
||||
PositionTicks: secToTicks(getCurrentTime() ?? 0),
|
||||
},
|
||||
});
|
||||
usePlaybackStore.setState(usePlaybackStore.getInitialState());
|
||||
clearQueue();
|
||||
}, [api, mediaSourceId, playsessionId, itemId]);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className={
|
||||
isUserHovering || isUserSeeking || !isPlayerPlaying
|
||||
? "video-player-osd hovering"
|
||||
: "video-player-osd"
|
||||
}
|
||||
onMouseEnter={onHover}
|
||||
onMouseLeave={onLeave}
|
||||
ref={playerOSDRef}
|
||||
initial={{
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
opacity: isUserHovering || isUserSeeking || !isPlayerPlaying ? 1 : 0,
|
||||
}}
|
||||
style={{
|
||||
zIndex: 2,
|
||||
}}
|
||||
onClick={(event) => {
|
||||
if (event.currentTarget !== event.target) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.detail === 1) {
|
||||
setClickTimeout(
|
||||
setTimeout(() => {
|
||||
toggleIsPlaying();
|
||||
}, 200),
|
||||
);
|
||||
} else if (event.detail === 2 && clickTimeout) {
|
||||
clearTimeout(clickTimeout);
|
||||
toggleIsPlayerFullscreen();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="video-player-osd-header flex flex-justify-spaced-between flex-align-center">
|
||||
<IconButton onClick={handleExitPlayer}>
|
||||
<span className="material-symbols-rounded">arrow_back</span>
|
||||
</IconButton>
|
||||
<IconButton onClick={(e) => setSettingsMenuRef(e.currentTarget)}>
|
||||
<span className="material-symbols-rounded">settings</span>
|
||||
</IconButton>
|
||||
<VideoPlayerSettingsMenu
|
||||
settingsMenuRef={settingsMenuRef}
|
||||
handleClose={() => setSettingsMenuRef(null)}
|
||||
/>
|
||||
</div>
|
||||
<div className="video-player-osd-info">
|
||||
<div>
|
||||
<Typography variant="h4" fontWeight={500} mb={2}>
|
||||
{String(itemName)}
|
||||
</Typography>
|
||||
{episodeTitle && (
|
||||
<Typography variant="h6" fontWeight={300} mt={1}>
|
||||
{String(episodeTitle)}
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
<div className="video-player-osd-controls">
|
||||
<div className="video-player-osd-controls-timeline">
|
||||
<BubbleSlider />
|
||||
<ProgressDisplay />
|
||||
</div>
|
||||
<div className="flex flex-row flex-justify-spaced-between">
|
||||
<div className="video-player-osd-controls-buttons">
|
||||
<PlayPreviousButton />
|
||||
<RewindButton />
|
||||
<PrevChapterButton />
|
||||
|
||||
<PlayPauseButton />
|
||||
|
||||
<NextChapterButton />
|
||||
|
||||
<ForwardButton />
|
||||
<PlayNextButton />
|
||||
|
||||
<EndsAtDisplay />
|
||||
</div>
|
||||
<div
|
||||
className="video-player-osd-controls-buttons"
|
||||
onMouseLeave={() => setShowVolumeControl(false)}
|
||||
>
|
||||
<AnimatePresence>
|
||||
{showVolumeControl && (
|
||||
<motion.div
|
||||
initial={{ width: 0, opacity: 0, marginRight: 0 }}
|
||||
animate={{ width: 100, opacity: 1, marginRight: 10 }}
|
||||
exit={{ width: 0, opacity: 0, marginRight: 0 }}
|
||||
style={{
|
||||
overflow: "hidden",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Slider
|
||||
size="small"
|
||||
value={isPlayerMuted ? 0 : volume}
|
||||
max={1}
|
||||
step={0.01}
|
||||
onChange={(_, newValue) => {
|
||||
const val = Array.isArray(newValue)
|
||||
? newValue[0]
|
||||
: newValue;
|
||||
setVolume(val);
|
||||
}}
|
||||
sx={{ width: 100, color: "white" }}
|
||||
/>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
<IconButton
|
||||
onClick={toggleIsPlayerMuted}
|
||||
onMouseEnter={() => setShowVolumeControl(true)}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
{isPlayerMuted
|
||||
? "volume_off"
|
||||
: volume < 0.4
|
||||
? "volume_down"
|
||||
: "volume_up"}
|
||||
</span>
|
||||
</IconButton>
|
||||
<QueueButton />
|
||||
|
||||
<ChaptersListButton />
|
||||
|
||||
<CaptionsButton />
|
||||
<FullscreenButton />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoPlayerControls;
|
||||
@@ -0,0 +1,155 @@
|
||||
import {
|
||||
MenuItem,
|
||||
Popover,
|
||||
Switch,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { toNumber } from "lodash";
|
||||
import React, {
|
||||
type ChangeEventHandler,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useTransition,
|
||||
} from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import {
|
||||
changeAudioTrack,
|
||||
changeSubtitleTrack,
|
||||
usePlaybackStore,
|
||||
} from "@/utils/store/playback";
|
||||
|
||||
type VideoPlayerSettingsMenuProps = {
|
||||
settingsMenuRef: HTMLButtonElement | null;
|
||||
handleClose: () => void;
|
||||
};
|
||||
|
||||
const VideoPlayerSettingsMenu = ({
|
||||
settingsMenuRef,
|
||||
handleClose,
|
||||
}: VideoPlayerSettingsMenuProps) => {
|
||||
const settingsMenuOpen = useMemo(() => {
|
||||
return Boolean(settingsMenuRef);
|
||||
}, [settingsMenuRef]);
|
||||
|
||||
const api = useApiInContext((state) => state.api);
|
||||
|
||||
const {
|
||||
mediaSource,
|
||||
setIsBuffering,
|
||||
showStatsForNerds,
|
||||
toggleShowStatsForNerds,
|
||||
} = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
mediaSource: state.mediaSource,
|
||||
setIsBuffering: state.setIsBuffering,
|
||||
showStatsForNerds: state.playerState.showStatsForNerds,
|
||||
toggleShowStatsForNerds: state.toggleShowStatsForNerds,
|
||||
})),
|
||||
);
|
||||
|
||||
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
||||
const handleSubtitleChange: ChangeEventHandler<
|
||||
HTMLInputElement | HTMLTextAreaElement
|
||||
> = useCallback(
|
||||
(e) => {
|
||||
startSubtitleChange(() => {
|
||||
if (mediaSource.subtitle.allTracks) {
|
||||
changeSubtitleTrack(
|
||||
toNumber(e.target.value),
|
||||
mediaSource.subtitle.allTracks,
|
||||
);
|
||||
handleClose();
|
||||
}
|
||||
});
|
||||
},
|
||||
[mediaSource.subtitle?.allTracks],
|
||||
);
|
||||
|
||||
const [audioTackIsChanging, startAudioTrackChange] = useTransition();
|
||||
const handleAudioTrackChange: ChangeEventHandler<
|
||||
HTMLInputElement | HTMLTextAreaElement
|
||||
> = (e) => {
|
||||
// setPlaying(false);
|
||||
startAudioTrackChange(() => {
|
||||
if (api && mediaSource.audio.allTracks) {
|
||||
changeAudioTrack(toNumber(e.target.value), api);
|
||||
handleClose();
|
||||
setIsBuffering(true);
|
||||
}
|
||||
});
|
||||
|
||||
// setPlaying(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover
|
||||
anchorEl={settingsMenuRef}
|
||||
open={settingsMenuOpen}
|
||||
onClose={handleClose}
|
||||
slotProps={{
|
||||
paper: {
|
||||
style: {
|
||||
maxHeight: "20em",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "1em",
|
||||
width: "24em",
|
||||
padding: "1em",
|
||||
borderRadius: "12px",
|
||||
},
|
||||
className: "glass",
|
||||
},
|
||||
}}
|
||||
anchorOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "right",
|
||||
}}
|
||||
transformOrigin={{
|
||||
vertical: "top",
|
||||
horizontal: "right",
|
||||
}}
|
||||
>
|
||||
<TextField
|
||||
select
|
||||
label="Audio"
|
||||
variant="outlined"
|
||||
value={mediaSource.audio?.track}
|
||||
onChange={handleAudioTrackChange}
|
||||
fullWidth
|
||||
disabled={audioTackIsChanging}
|
||||
>
|
||||
{mediaSource.audio?.allTracks?.map((sub) => (
|
||||
<MenuItem key={sub.Index} value={sub.Index}>
|
||||
{sub.DisplayTitle}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
<TextField
|
||||
select
|
||||
label="Subtitles"
|
||||
variant="outlined"
|
||||
value={mediaSource.subtitle?.track}
|
||||
onChange={handleSubtitleChange}
|
||||
fullWidth
|
||||
disabled={mediaSource.subtitle?.track === -2 || subtitleIsChanging}
|
||||
>
|
||||
<MenuItem key={-1} value={-1}>
|
||||
No Subtitle
|
||||
</MenuItem>
|
||||
{mediaSource.subtitle?.allTracks?.map((sub) => (
|
||||
<MenuItem key={sub.Index} value={sub.Index}>
|
||||
{sub.DisplayTitle}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
<MenuItem onClick={toggleShowStatsForNerds}>
|
||||
<Typography flexGrow={1}>Stats for Nerds</Typography>
|
||||
<Switch checked={showStatsForNerds} />
|
||||
</MenuItem>
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoPlayerSettingsMenu;
|
||||
@@ -0,0 +1,41 @@
|
||||
.video-player-up_next_flyout {
|
||||
position: absolute;
|
||||
bottom: 2em;
|
||||
right: 2em;
|
||||
width: 42em;
|
||||
height: fit-content;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: stretch;
|
||||
justify-content: center;
|
||||
background-color: rgba(60, 60, 60,1);
|
||||
padding: 10px;
|
||||
border-radius: $border-radius-default + 10px;
|
||||
z-index: 10;
|
||||
transition: bottom 0.3s ease-in-out;
|
||||
|
||||
&.floating {
|
||||
bottom: 18vh
|
||||
}
|
||||
|
||||
&-thumbnail {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: 15em;
|
||||
object-fit: cover;
|
||||
border-radius: $border-radius-default;
|
||||
}
|
||||
&-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
overflow: hidden;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-start;
|
||||
// height: 100%;
|
||||
}
|
||||
&-button{
|
||||
// justify-self: flex-end;
|
||||
margin-top: auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
import { Box, Button, IconButton, Typography } from "@mui/material";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
import useQueue from "@/utils/store/queue";
|
||||
|
||||
import "./upNextFlyout.scss";
|
||||
|
||||
const UpNextFlyout = () => {
|
||||
const {
|
||||
activeSegmentId,
|
||||
currentSegmemtIndex,
|
||||
mediaSegments,
|
||||
skipSegment,
|
||||
isUserHovering,
|
||||
isUserSeeking,
|
||||
isPlayerPlaying,
|
||||
} = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
activeSegmentId: state.activeSegmentId,
|
||||
currentSegmemtIndex: state.nextSegmentIndex - 1,
|
||||
mediaSegments: state.metadata.mediaSegments,
|
||||
skipSegment: state.skipSegment,
|
||||
isUserHovering: state.playerState.isUserHovering,
|
||||
isUserSeeking: state.playerState.isUserSeeking,
|
||||
isPlayerPlaying: state.playerState.isPlayerPlaying,
|
||||
})),
|
||||
);
|
||||
|
||||
const { nextItemIndex, tracks } = useQueue(
|
||||
useShallow((state) => ({
|
||||
nextItemIndex: state.currentItemIndex + 1,
|
||||
tracks: state.tracks,
|
||||
})),
|
||||
);
|
||||
|
||||
const [isHidden, setIsHidden] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setIsHidden(false);
|
||||
}, [activeSegmentId]);
|
||||
|
||||
const areControlsVisible = useMemo(() => {
|
||||
return isUserHovering || isUserSeeking || !isPlayerPlaying;
|
||||
}, [isUserHovering, isUserSeeking, isPlayerPlaying]);
|
||||
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
if (
|
||||
!api ||
|
||||
!activeSegmentId ||
|
||||
mediaSegments?.Items?.[currentSegmemtIndex].Type !== "Outro" ||
|
||||
isHidden
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const item = tracks?.[nextItemIndex];
|
||||
if (!item || !item.Id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
<motion.div
|
||||
className={
|
||||
areControlsVisible
|
||||
? "video-player-up_next_flyout floating"
|
||||
: "video-player-up_next_flyout"
|
||||
}
|
||||
initial={{ opacity: 0, y: 50, scale: 0.95 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
exit={{ opacity: 0, y: 20, scale: 0.95 }}
|
||||
transition={{ duration: 0.4, ease: [0.4, 0, 0.2, 1] }}
|
||||
style={{
|
||||
background: "rgba(20, 20, 20, 0.6)",
|
||||
backdropFilter: "blur(16px) saturate(180%)",
|
||||
border: "1px solid rgba(255, 255, 255, 0.1)",
|
||||
boxShadow: "0 8px 32px 0 rgba(0, 0, 0, 0.3)",
|
||||
borderRadius: "24px",
|
||||
padding: "16px",
|
||||
display: "flex",
|
||||
gap: "16px",
|
||||
maxWidth: "500px",
|
||||
width: "100%",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
position: "relative",
|
||||
width: "160px",
|
||||
minWidth: "160px",
|
||||
borderRadius: "8px",
|
||||
overflow: "hidden",
|
||||
aspectRatio: "16/9",
|
||||
boxShadow: "0 4px 12px rgba(0,0,0,0.3)",
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
|
||||
tag: item.ImageTags?.Primary,
|
||||
quality: 90,
|
||||
fillWidth: 320,
|
||||
})}
|
||||
alt="next item thumbnail"
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
objectFit: "cover",
|
||||
}}
|
||||
/>
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute",
|
||||
inset: 0,
|
||||
background:
|
||||
"linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%)",
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="overline"
|
||||
sx={{
|
||||
color: "primary.main",
|
||||
fontWeight: 700,
|
||||
lineHeight: 1,
|
||||
mb: 0.5,
|
||||
letterSpacing: 1.2,
|
||||
}}
|
||||
>
|
||||
UP NEXT
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="h6"
|
||||
sx={{
|
||||
fontWeight: 600,
|
||||
lineHeight: 1.2,
|
||||
mb: 0.5,
|
||||
fontSize: "1.1rem",
|
||||
}}
|
||||
noWrap
|
||||
>
|
||||
{item.SeriesName || item.Name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
color="text.secondary"
|
||||
sx={{
|
||||
mb: 2,
|
||||
display: "-webkit-box",
|
||||
WebkitLineClamp: 1,
|
||||
WebkitBoxOrient: "vertical",
|
||||
overflow: "hidden",
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
{item.SeriesName
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item.Overview || ""}
|
||||
</Typography>
|
||||
|
||||
<Box sx={{ display: "flex", gap: 1, mt: "auto" }}>
|
||||
<Button
|
||||
onClick={skipSegment}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
startIcon={
|
||||
<span className="material-symbols-rounded fill">
|
||||
play_arrow
|
||||
</span>
|
||||
}
|
||||
sx={{
|
||||
borderRadius: "8px",
|
||||
textTransform: "none",
|
||||
fontWeight: 600,
|
||||
boxShadow:
|
||||
"0 4px 12px rgba(var(--mui-palette-primary-mainChannel), 0.3)",
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
Play Now
|
||||
</Button>
|
||||
<IconButton
|
||||
onClick={() => setIsHidden(true)}
|
||||
sx={{
|
||||
borderRadius: "8px",
|
||||
border: "1px solid rgba(255,255,255,0.1)",
|
||||
color: "text.secondary",
|
||||
"&:hover": {
|
||||
bgcolor: "rgba(255,255,255,0.1)",
|
||||
color: "white",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">close</span>
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
);
|
||||
};
|
||||
|
||||
export default UpNextFlyout;
|
||||
@@ -0,0 +1,237 @@
|
||||
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",
|
||||
fontWeight: active ? 700 : 500,
|
||||
sx: { mb: 0.5 },
|
||||
},
|
||||
secondary: {
|
||||
noWrap: true,
|
||||
variant: "caption",
|
||||
sx: { opacity: 0.7 },
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
);
|
||||
};
|
||||
|
||||
export default QueueListItem;
|
||||
@@ -1,21 +1,18 @@
|
||||
import { getRuntimeMusic } from "@/utils/date/time";
|
||||
import useQueue from "@/utils/store/queue";
|
||||
|
||||
import { useSortable } from "@dnd-kit/sortable";
|
||||
import { CSS } from "@dnd-kit/utilities";
|
||||
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Typography } from "@mui/material";
|
||||
import { IconButton, Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
|
||||
|
||||
import { getRuntimeMusic } from "@/utils/date/time";
|
||||
import useQueue from "@/utils/store/queue";
|
||||
|
||||
type Props = {
|
||||
track: BaseItemDto;
|
||||
index: number;
|
||||
onRemove?: () => void;
|
||||
};
|
||||
const QueueTrack = (props: Props) => {
|
||||
const { track, index } = props;
|
||||
const { track, index, onRemove } = props;
|
||||
const [currentItemIndex] = useQueue((s) => [s.currentItemIndex]);
|
||||
|
||||
const { attributes, listeners, setNodeRef, transform, transition } =
|
||||
@@ -50,9 +47,21 @@ const QueueTrack = (props: Props) => {
|
||||
{track.Artists?.join(", ")}
|
||||
</Typography>
|
||||
</div>
|
||||
<Typography className="opacity-07">
|
||||
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
||||
</Typography>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "0.5em" }}>
|
||||
<Typography className="opacity-07">
|
||||
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
||||
</Typography>
|
||||
{onRemove && (
|
||||
<IconButton size="small" onClick={onRemove}>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: "1.2em" }}
|
||||
>
|
||||
close
|
||||
</span>
|
||||
</IconButton>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,420 @@
|
||||
import { ItemSortBy } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Dialog,
|
||||
Grow,
|
||||
IconButton,
|
||||
InputBase,
|
||||
LinearProgress,
|
||||
Stack,
|
||||
Typography,
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
import type { TransitionProps } from "@mui/material/transitions";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { register } from "@tauri-apps/plugin-global-shortcut";
|
||||
import React, {
|
||||
type ChangeEvent,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import useDebounce from "@/utils/hooks/useDebounce";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
import SearchItem from "./item";
|
||||
|
||||
const Transition = React.forwardRef(function Transition(
|
||||
props: TransitionProps & {
|
||||
children: React.ReactElement<any, any>;
|
||||
},
|
||||
ref: React.Ref<unknown>,
|
||||
) {
|
||||
return <Grow ref={ref} {...props} />;
|
||||
});
|
||||
|
||||
const Search = () => {
|
||||
const theme = useTheme();
|
||||
const { isOpen, handleClose, toggleSearchDialog } = useSearchStore(
|
||||
useShallow((s) => ({
|
||||
isOpen: s.showSearchDialog,
|
||||
handleClose: s.toggleSearchDialog,
|
||||
toggleSearchDialog: s.toggleSearchDialog,
|
||||
})),
|
||||
);
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const userId = useCentralStore((s) => s.currentUser?.Id || "");
|
||||
const suggestions = useQuery({
|
||||
queryKey: ["search", "suggestions"],
|
||||
queryFn: async () =>
|
||||
api &&
|
||||
(
|
||||
await getItemsApi(api).getItems({
|
||||
userId: userId,
|
||||
limit: 5,
|
||||
sortBy: [ItemSortBy.IsFavoriteOrLiked, ItemSortBy.Random],
|
||||
includeItemTypes: ["Movie", "Series", "MusicArtist"],
|
||||
enableImages: true,
|
||||
recursive: true,
|
||||
})
|
||||
).data,
|
||||
});
|
||||
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const debouncedSearchTerm = useDebounce(searchTerm, 300);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setTimeout(() => {
|
||||
inputRef.current?.focus();
|
||||
}, 100);
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
const handleSearchChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
setSearchTerm(e.target.value);
|
||||
};
|
||||
|
||||
const searchResults = useQuery({
|
||||
queryKey: ["search", debouncedSearchTerm],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
if (debouncedSearchTerm.trim() === "") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
await getSearchApi(api).getSearchHints({
|
||||
searchTerm: debouncedSearchTerm,
|
||||
userId: userId,
|
||||
limit: 10,
|
||||
includeItemTypes: [
|
||||
"Movie",
|
||||
"Series",
|
||||
"MusicAlbum",
|
||||
"Person",
|
||||
"Audio",
|
||||
"Photo",
|
||||
"PhotoAlbum",
|
||||
"Playlist",
|
||||
],
|
||||
// enableImages: true,
|
||||
})
|
||||
).data;
|
||||
},
|
||||
});
|
||||
|
||||
const showSuggestions = useMemo(
|
||||
() =>
|
||||
(debouncedSearchTerm.length === 0 || searchResults.isLoading) &&
|
||||
(suggestions.data?.Items?.length ?? 0) > 0,
|
||||
[
|
||||
debouncedSearchTerm.length,
|
||||
searchResults.isLoading,
|
||||
suggestions.data?.Items?.length,
|
||||
],
|
||||
);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const handleClearSearch = useCallback(() => {
|
||||
setSearchTerm("");
|
||||
}, []);
|
||||
const handleAdvancedSearch = useCallback(() => {
|
||||
navigate({ to: "/search", search: { query: debouncedSearchTerm } });
|
||||
toggleSearchDialog();
|
||||
}, [navigate, toggleSearchDialog, debouncedSearchTerm]);
|
||||
|
||||
useEffect(() => {
|
||||
async function registerglobalShortcut() {
|
||||
await register("CommandOrControl+K", (e) => {
|
||||
if (e.state === "Pressed") {
|
||||
toggleSearchDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
registerglobalShortcut();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
slotProps={{
|
||||
transition: Transition,
|
||||
paper: {
|
||||
className: "glass-panel",
|
||||
sx: {
|
||||
willChange: "opacity, transform, backdrop-filter",
|
||||
borderRadius: 4,
|
||||
overflow: "hidden",
|
||||
},
|
||||
},
|
||||
}}
|
||||
onClose={handleClose}
|
||||
fullWidth
|
||||
maxWidth="sm"
|
||||
>
|
||||
<Box sx={{ position: "relative" }}>
|
||||
<Stack
|
||||
direction="row"
|
||||
alignItems="center"
|
||||
spacing={1.5}
|
||||
sx={{
|
||||
p: "16px 24px",
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
color: "var(--mui-palette-text-secondary)",
|
||||
fontSize: "1.75rem",
|
||||
opacity: 0.7,
|
||||
}}
|
||||
>
|
||||
search
|
||||
</span>
|
||||
<InputBase
|
||||
inputRef={inputRef}
|
||||
placeholder="Search movies, shows, and more..."
|
||||
onChange={handleSearchChange}
|
||||
value={searchTerm}
|
||||
fullWidth
|
||||
autoFocus
|
||||
sx={{
|
||||
fontSize: "1.25rem",
|
||||
fontWeight: 400,
|
||||
color: "text.primary",
|
||||
"& input::placeholder": {
|
||||
color: "text.disabled",
|
||||
opacity: 1,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
{searchTerm && (
|
||||
<IconButton
|
||||
onClick={handleClearSearch}
|
||||
size="small"
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
bgcolor: "rgba(255,255,255,0.05)",
|
||||
"&:hover": {
|
||||
bgcolor: "rgba(255,255,255,0.15)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: "1.25rem" }}
|
||||
>
|
||||
close
|
||||
</span>
|
||||
</IconButton>
|
||||
)}
|
||||
</Stack>
|
||||
{searchResults.isLoading && (
|
||||
<LinearProgress
|
||||
sx={{
|
||||
height: 2,
|
||||
backgroundColor: "transparent",
|
||||
"& .MuiLinearProgress-bar": {
|
||||
backgroundImage: `linear-gradient(90deg, ${theme.palette.primary.main}, ${theme.palette.secondary.main})`,
|
||||
},
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Box
|
||||
sx={{
|
||||
height: "1px",
|
||||
bgcolor: "divider",
|
||||
opacity: 0.1,
|
||||
mx: 2,
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Stack
|
||||
spacing={1}
|
||||
sx={{
|
||||
p: 1,
|
||||
maxHeight: "55vh",
|
||||
overflowY: "auto",
|
||||
minHeight:
|
||||
showSuggestions ||
|
||||
(debouncedSearchTerm &&
|
||||
searchResults.data?.SearchHints?.length !== 0)
|
||||
? "auto"
|
||||
: "150px",
|
||||
"&::-webkit-scrollbar": {
|
||||
width: "8px",
|
||||
},
|
||||
"&::-webkit-scrollbar-thumb": {
|
||||
background: "rgba(255,255,255,0.1)",
|
||||
borderRadius: "4px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
{debouncedSearchTerm.length > 0 &&
|
||||
searchResults.data?.SearchHints &&
|
||||
searchResults.data.SearchHints.length > 0 && (
|
||||
<Box>
|
||||
<Typography
|
||||
variant="caption"
|
||||
fontWeight={600}
|
||||
sx={{
|
||||
px: 2,
|
||||
py: 1.5,
|
||||
color: "text.secondary",
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: "0.05em",
|
||||
display: "block",
|
||||
}}
|
||||
>
|
||||
Results
|
||||
</Typography>
|
||||
<Stack spacing={0.5} sx={{ px: 1 }}>
|
||||
{searchResults.data.SearchHints.map((item) => (
|
||||
<SearchItem
|
||||
key={item.Id}
|
||||
itemName={item.Name || "Untitled"}
|
||||
imageUrl={
|
||||
api &&
|
||||
item.PrimaryImageTag &&
|
||||
getImageUrlsApi(api).getItemImageUrl(item, "Primary", {
|
||||
maxWidth: 90,
|
||||
maxHeight: 140,
|
||||
tag: item.PrimaryImageTag,
|
||||
})
|
||||
}
|
||||
itemYear={
|
||||
item.Type === "Series"
|
||||
? `${item.ProductionYear?.toString()} - ${new Date(item.EndDate ?? "").getFullYear().toString()}`
|
||||
: item.ProductionYear?.toString()
|
||||
}
|
||||
itemType={item.Type}
|
||||
itemId={item.Id ?? ""}
|
||||
/>
|
||||
))}
|
||||
</Stack>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{showSuggestions && (
|
||||
<Box>
|
||||
<Typography
|
||||
variant="caption"
|
||||
fontWeight={600}
|
||||
sx={{
|
||||
px: 2,
|
||||
py: 1.5,
|
||||
color: "text.secondary",
|
||||
textTransform: "uppercase",
|
||||
letterSpacing: "0.05em",
|
||||
display: "block",
|
||||
}}
|
||||
>
|
||||
Suggestions
|
||||
</Typography>
|
||||
<Stack spacing={0.5} sx={{ px: 1 }}>
|
||||
{suggestions.data?.Items?.map((item) => (
|
||||
<SearchItem
|
||||
key={item.Id}
|
||||
itemName={item.Name || "Untitled"}
|
||||
imageUrl={
|
||||
api &&
|
||||
item.ImageTags?.Primary &&
|
||||
getImageUrlsApi(api).getItemImageUrl(item, "Primary", {
|
||||
maxWidth: 90,
|
||||
maxHeight: 140,
|
||||
})
|
||||
}
|
||||
itemYear={
|
||||
item.Type === "Series"
|
||||
? `${item.ProductionYear?.toString()} - ${new Date(item.EndDate ?? "").getFullYear().toString()}`
|
||||
: item.ProductionYear?.toString()
|
||||
}
|
||||
itemType={item.Type}
|
||||
itemId={item.Id ?? ""}
|
||||
/>
|
||||
))}
|
||||
</Stack>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{searchResults.isSuccess &&
|
||||
searchResults.data?.SearchHints?.length === 0 && (
|
||||
<Stack
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
sx={{
|
||||
height: "100%",
|
||||
minHeight: "200px",
|
||||
color: "text.secondary",
|
||||
gap: 2,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: "48px", opacity: 0.2 }}
|
||||
>
|
||||
search_off
|
||||
</span>
|
||||
<Typography variant="body1">
|
||||
No results found for "{debouncedSearchTerm}"
|
||||
</Typography>
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
<Stack
|
||||
direction="row"
|
||||
justifyContent="flex-end"
|
||||
sx={{
|
||||
p: 1.5,
|
||||
mt: 1,
|
||||
backgroundImage:
|
||||
"linear-gradient(to top, rgba(0,0,0,0.2), transparent)",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
onClick={handleAdvancedSearch}
|
||||
endIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: "1.25rem" }}
|
||||
>
|
||||
arrow_forward
|
||||
</span>
|
||||
}
|
||||
sx={{
|
||||
color: "text.secondary",
|
||||
textTransform: "none",
|
||||
fontWeight: 500,
|
||||
padding: "6px 16px",
|
||||
borderRadius: "8px",
|
||||
"&:hover": {
|
||||
color: "primary.main",
|
||||
backgroundColor: "rgba(255,255,255,0.05)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
Advanced Search
|
||||
</Button>
|
||||
</Stack>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default Search;
|
||||
@@ -0,0 +1,132 @@
|
||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Box, Button, Stack, Typography } from "@mui/material";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/react/shallow";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
type SearchItemProps = {
|
||||
itemName: string;
|
||||
imageUrl?: string | null;
|
||||
itemYear?: string;
|
||||
itemType?: BaseItemKind;
|
||||
itemId: string;
|
||||
};
|
||||
|
||||
const SearchItem = (props: SearchItemProps) => {
|
||||
const { itemName, imageUrl, itemYear, itemType, itemId } = props;
|
||||
const toggleSearchDialog = useSearchStore(
|
||||
useShallow((s) => s.toggleSearchDialog),
|
||||
);
|
||||
const navigate = useNavigate();
|
||||
const handleOnClick = () => {
|
||||
toggleSearchDialog();
|
||||
switch (itemType) {
|
||||
case BaseItemKind.BoxSet:
|
||||
navigate({ to: "/boxset/$id", params: { id: itemId } });
|
||||
break;
|
||||
case BaseItemKind.Episode:
|
||||
navigate({ to: "/episode/$id", params: { id: itemId } });
|
||||
break;
|
||||
case BaseItemKind.MusicAlbum:
|
||||
navigate({ to: "/album/$id", params: { id: itemId } });
|
||||
break;
|
||||
case BaseItemKind.MusicArtist:
|
||||
navigate({ to: "/artist/$id", params: { id: itemId } });
|
||||
break;
|
||||
case BaseItemKind.Person:
|
||||
navigate({ to: "/person/$id", params: { id: itemId } });
|
||||
break;
|
||||
case BaseItemKind.Series:
|
||||
navigate({ to: "/series/$id", params: { id: itemId } });
|
||||
break;
|
||||
case BaseItemKind.Playlist:
|
||||
navigate({ to: "/playlist/$id", params: { id: itemId } });
|
||||
break;
|
||||
default:
|
||||
navigate({ to: "/item/$id", params: { id: itemId } });
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Button
|
||||
onClick={handleOnClick}
|
||||
fullWidth
|
||||
sx={{
|
||||
justifyContent: "flex-start",
|
||||
textAlign: "left",
|
||||
p: 1,
|
||||
borderRadius: 2,
|
||||
textTransform: "none",
|
||||
color: "text.primary",
|
||||
"&:hover": {
|
||||
bgcolor: "action.hover",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
width: 50,
|
||||
height: 75,
|
||||
mr: 2,
|
||||
borderRadius: 1,
|
||||
overflow: "hidden",
|
||||
bgcolor: "action.selected",
|
||||
flexShrink: 0,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
{imageUrl ? (
|
||||
<Box
|
||||
component="img"
|
||||
src={imageUrl}
|
||||
alt={itemName}
|
||||
sx={{
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
objectFit: "cover",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
fontSize: "2rem",
|
||||
color: "var(--mui-palette-text-secondary)",
|
||||
}}
|
||||
>
|
||||
{getTypeIcon(itemType ?? "unknown")}
|
||||
</span>
|
||||
)}
|
||||
</Box>
|
||||
<Stack sx={{ minWidth: 0, flex: 1 }}>
|
||||
<Typography variant="body1" noWrap fontWeight={500}>
|
||||
{itemName}
|
||||
</Typography>
|
||||
<Stack direction="row" spacing={1} alignItems="center">
|
||||
{itemYear && (
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
{itemYear}
|
||||
</Typography>
|
||||
)}
|
||||
{itemYear && itemType && (
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
•
|
||||
</Typography>
|
||||
)}
|
||||
{itemType && (
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
{itemType}
|
||||
</Typography>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default SearchItem;
|
||||
@@ -0,0 +1,59 @@
|
||||
import type { CultureDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import {
|
||||
FormControlLabel,
|
||||
MenuItem,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
|
||||
const SettingOptionSelect = ({
|
||||
setting,
|
||||
options,
|
||||
userValue,
|
||||
}: {
|
||||
setting: { name: string; description: string };
|
||||
options: CultureDto[];
|
||||
userValue: string | null;
|
||||
}) => {
|
||||
const [value, setValue] = useState(
|
||||
userValue === "" ? "anyLanguage" : userValue,
|
||||
);
|
||||
return (
|
||||
<FormControlLabel
|
||||
value={value}
|
||||
control={
|
||||
<TextField select onChange={(e) => setValue(e.target.value)}>
|
||||
<MenuItem key={"anyLanguage"} value={"anyLanguage"}>
|
||||
Any Language
|
||||
</MenuItem>
|
||||
{options.map((option) => (
|
||||
<MenuItem
|
||||
key={option.ThreeLetterISOLanguageName}
|
||||
value={option.ThreeLetterISOLanguageName ?? "none"}
|
||||
>
|
||||
{option.DisplayName}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="subtitle1" fontWeight={400}>
|
||||
{setting.name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
className="settings-option-info-caption"
|
||||
>
|
||||
{setting.description}
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingOptionSelect;
|
||||
@@ -1,652 +0,0 @@
|
||||
import useSettingsStore, {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
import {
|
||||
Button,
|
||||
Chip,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
Fab,
|
||||
IconButton,
|
||||
Link,
|
||||
Skeleton,
|
||||
Tab,
|
||||
Tabs,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import React, { useState, useMemo, useCallback } from "react";
|
||||
|
||||
import logo from "@/assets/logo.png";
|
||||
|
||||
import { jellyfin, useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import "./settings.scss";
|
||||
|
||||
import {
|
||||
delServer,
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
setDefaultServer,
|
||||
setServer,
|
||||
} from "@/utils/storage/servers";
|
||||
import { allSettings } from "@/utils/storage/settings";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import type { RecommendedServerInfo } from "@jellyfin/sdk";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import { red } from "@mui/material/colors";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { relaunch } from "@tauri-apps/plugin-process";
|
||||
import { check } from "@tauri-apps/plugin-updater";
|
||||
import { useSnackbar } from "notistack";
|
||||
import SettingOption from "../settingOption";
|
||||
|
||||
const motionConfig = {
|
||||
initial: {
|
||||
opacity: 0,
|
||||
},
|
||||
visible: {
|
||||
opacity: 1,
|
||||
},
|
||||
};
|
||||
|
||||
const Settings = () => {
|
||||
const [open, tabValue] = useSettingsStore((state) => [
|
||||
state.dialogOpen,
|
||||
state.tabValue,
|
||||
]);
|
||||
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
|
||||
const systemInfo = useQuery({
|
||||
queryKey: ["about", "systemInfo"],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const result = await getSystemApi(api).getSystemInfo();
|
||||
return result.data;
|
||||
},
|
||||
enabled: Boolean(api) && open,
|
||||
});
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const [applicationVersion] = useCentralStore((state) => [state.clientVersion]);
|
||||
|
||||
const serversOnDisk = useQuery({
|
||||
queryKey: ["settings", "serversOnDisk"],
|
||||
queryFn: async () => await getAllServers(),
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
const updateInfo = useQuery({
|
||||
queryKey: ["about", "updater"],
|
||||
queryFn: async () => await check(),
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
const defaultServer = useQuery({
|
||||
queryKey: ["settings", "default-server"],
|
||||
queryFn: async () => await getDefaultServer(),
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const [updating, setUpdating] = useState(false);
|
||||
const [addServerDialog, setAddServerDialog] = useState(false);
|
||||
const [serverIp, setServerIp] = useState("");
|
||||
|
||||
const handleServerChange = useMutation({
|
||||
mutationFn: async (server: RecommendedServerInfo) => {
|
||||
await delUser();
|
||||
await setDefaultServer(server.systemInfo?.Id ?? "");
|
||||
await defaultServer.refetch();
|
||||
createApi(server.address, undefined);
|
||||
queryClient.removeQueries();
|
||||
},
|
||||
onSuccess: async () => {
|
||||
setSettingsDialogOpen(false);
|
||||
navigate({ to: "/login" });
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
enqueueSnackbar("Error changing the server", {
|
||||
variant: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const handleDelete = useMutation({
|
||||
mutationKey: ["server-delete"],
|
||||
mutationFn: async (server: RecommendedServerInfo) => {
|
||||
await delServer(server.systemInfo?.Id ?? "");
|
||||
|
||||
if (server.systemInfo?.Id === defaultServer.data) {
|
||||
await delUser();
|
||||
await serversOnDisk.refetch();
|
||||
|
||||
if (serversOnDisk.data?.length) {
|
||||
setDefaultServer(serversOnDisk.data[0].id);
|
||||
createApi(serversOnDisk.data[0].address, undefined);
|
||||
} else {
|
||||
// TODO: Reset api in context
|
||||
// useApi.setState(useApi.getInitialState());
|
||||
}
|
||||
setSettingsDialogOpen(false);
|
||||
await queryClient.removeQueries();
|
||||
navigate({ to: "/" });
|
||||
}
|
||||
enqueueSnackbar("Server deleted successfully!", { variant: "success" });
|
||||
await serversOnDisk.refetch();
|
||||
await defaultServer.refetch();
|
||||
},
|
||||
});
|
||||
|
||||
const addServer = useMutation({
|
||||
mutationFn: async () => {
|
||||
const servers =
|
||||
await jellyfin.discovery.getRecommendedServerCandidates(serverIp);
|
||||
const bestServer = jellyfin.discovery.findBestServer(servers);
|
||||
return bestServer;
|
||||
},
|
||||
onSuccess: async (bestServer) => {
|
||||
if (bestServer) {
|
||||
await setServer(bestServer.systemInfo?.Id ?? "", bestServer);
|
||||
setAddServerDialog(false);
|
||||
enqueueSnackbar(
|
||||
"Client added successfully. You might need to refresh client list.",
|
||||
{
|
||||
variant: "success",
|
||||
},
|
||||
);
|
||||
await serversOnDisk.refetch();
|
||||
}
|
||||
},
|
||||
onError: (err) => {
|
||||
console.error(err);
|
||||
enqueueSnackbar(`${err}`, { variant: "error" });
|
||||
enqueueSnackbar("Something went wrong", { variant: "error" });
|
||||
},
|
||||
onSettled: async (bestServer) => {
|
||||
if (!bestServer) {
|
||||
enqueueSnackbar("Provided server address is not a Jellyfin server.", {
|
||||
variant: "error",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Memoize PaperProps to prevent unnecessary re-renders
|
||||
const paperProps = useMemo(
|
||||
() => ({
|
||||
className: "settings glass",
|
||||
elevation: 10,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
// Memoize onClose function to prevent unnecessary re-renders
|
||||
const handleClose = useCallback(() => {
|
||||
setSettingsDialogOpen(false);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
fullWidth
|
||||
maxWidth="md"
|
||||
PaperProps={paperProps}
|
||||
hideBackdrop
|
||||
onClose={handleClose}
|
||||
>
|
||||
<Tabs
|
||||
orientation="vertical"
|
||||
value={tabValue}
|
||||
onChange={(_, newValue) => {
|
||||
setSettingsTabValue(newValue);
|
||||
}}
|
||||
style={{
|
||||
background: "rgb(0 0 0 / 0.4)",
|
||||
}}
|
||||
>
|
||||
<Tab
|
||||
icon={<span className="material-symbols-rounded">settings</span>}
|
||||
iconPosition="start"
|
||||
value={1}
|
||||
label="General"
|
||||
className="settings-tab"
|
||||
sx={{
|
||||
minHeight: "48px",
|
||||
height: "48px",
|
||||
}}
|
||||
/>
|
||||
<Tab
|
||||
icon={<span className="material-symbols-rounded">dns</span>}
|
||||
iconPosition="start"
|
||||
value={2}
|
||||
label="Servers"
|
||||
className="settings-tab"
|
||||
sx={{
|
||||
minHeight: "48px",
|
||||
height: "48px",
|
||||
}}
|
||||
/>
|
||||
<Tab
|
||||
icon={<span className="material-symbols-rounded">info</span>}
|
||||
iconPosition="start"
|
||||
value={10}
|
||||
label="About"
|
||||
className="settings-tab"
|
||||
sx={{
|
||||
minHeight: "48px",
|
||||
height: "48px",
|
||||
marginTop: "auto",
|
||||
}}
|
||||
/>
|
||||
</Tabs>
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.div
|
||||
variants={motionConfig}
|
||||
initial="initial"
|
||||
animate="visible"
|
||||
exit="initial"
|
||||
key={tabValue}
|
||||
transition={{
|
||||
duration: 0.25,
|
||||
}}
|
||||
className="settings-scroll "
|
||||
>
|
||||
{/* General */}
|
||||
{tabValue === 1 && (
|
||||
<div className="settings-container">
|
||||
{allSettings.general.map((setting) => (
|
||||
<SettingOption key={setting.key} setting={setting} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Server */}
|
||||
{tabValue === 2 && (
|
||||
<motion.div
|
||||
layoutScroll
|
||||
className="settings-container settings-server-container"
|
||||
>
|
||||
{serversOnDisk.isSuccess &&
|
||||
serversOnDisk.data.map((server, index) => {
|
||||
return (
|
||||
<motion.div
|
||||
key={server.id}
|
||||
className="settings-server"
|
||||
initial={{
|
||||
transform: "translateY(10px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{ transform: "translateY(0px)", opacity: 1 }}
|
||||
exit={{ transform: "translateY(-10px)", opacity: 0 }}
|
||||
transition={{
|
||||
delay: 0.1 * index,
|
||||
duration: 0.15,
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded settings-server-icon">
|
||||
hard_drive
|
||||
</span>
|
||||
<div className="settings-server-info">
|
||||
<Typography
|
||||
variant="h5"
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
{server.systemInfo?.ServerName}
|
||||
{systemInfo.data?.Id === server.id && (
|
||||
<Chip
|
||||
label={
|
||||
<Typography
|
||||
variant="caption"
|
||||
fontWeight={600}
|
||||
fontFamily="JetBrains Mono Variable"
|
||||
>
|
||||
Current
|
||||
</Typography>
|
||||
}
|
||||
color="info"
|
||||
sx={{
|
||||
ml: 2,
|
||||
width: "5.4em",
|
||||
}}
|
||||
size="medium"
|
||||
/>
|
||||
)}
|
||||
</Typography>
|
||||
<Typography variant="subtitle1">
|
||||
{server.address}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
className="settings-server-info-version"
|
||||
>
|
||||
Version:{" "}
|
||||
<Typography
|
||||
className="gradient-text"
|
||||
variant="subtitle2"
|
||||
fontWeight={700}
|
||||
>
|
||||
{server.systemInfo?.Version}
|
||||
</Typography>
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-buttons">
|
||||
<IconButton
|
||||
style={{
|
||||
fontSize: "1.64em",
|
||||
}}
|
||||
onClick={() => {
|
||||
handleServerChange.mutate(server);
|
||||
}}
|
||||
disabled={handleServerChange.isPending}
|
||||
>
|
||||
<div className="material-symbols-rounded">start</div>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
style={{
|
||||
fontSize: "1.64em",
|
||||
|
||||
color: red[400],
|
||||
}}
|
||||
disabled={handleServerChange.isPending}
|
||||
onClick={() => {
|
||||
handleDelete.mutate(server);
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">
|
||||
delete_forever
|
||||
</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
})}
|
||||
<div className="settings-server-fab-container">
|
||||
<Fab
|
||||
onClick={() => serversOnDisk.refetch()}
|
||||
size="medium"
|
||||
color="info"
|
||||
disabled={serversOnDisk.isFetching}
|
||||
>
|
||||
<span
|
||||
className={
|
||||
serversOnDisk.isFetching
|
||||
? "material-symbols-rounded animate-rotate"
|
||||
: "material-symbols-rounded"
|
||||
}
|
||||
>
|
||||
autorenew
|
||||
</span>
|
||||
</Fab>
|
||||
<Fab
|
||||
variant="extended"
|
||||
onClick={() => setAddServerDialog(true)}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
}}
|
||||
>
|
||||
add_circle
|
||||
</span>
|
||||
Add server
|
||||
</Fab>
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
|
||||
{/* About */}
|
||||
{tabValue === 10 && (
|
||||
<div className="settings-container settings-about">
|
||||
<img src={logo} className="settings-logo" alt="Blink" />
|
||||
<div className="settings-grid">
|
||||
<div className="settings-info-container">
|
||||
<div className="settings-info">
|
||||
<Typography variant="subtitle2">Client Version:</Typography>
|
||||
<Chip
|
||||
icon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
// style={{ "--wght": 500 }}
|
||||
>
|
||||
{updateInfo.data?.available
|
||||
? "release_alert"
|
||||
: "new_releases"}
|
||||
</span>
|
||||
}
|
||||
label={
|
||||
<Typography variant="subtitle2">
|
||||
{applicationVersion}
|
||||
</Typography>
|
||||
}
|
||||
color={updateInfo.data?.available ? "error" : "success"}
|
||||
size="small"
|
||||
style={{
|
||||
width: "fit-content !important",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="settings-info">
|
||||
<Typography variant="subtitle2">
|
||||
Update Available:
|
||||
</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{updateInfo.isFetching ? (
|
||||
"Checking for new updates..."
|
||||
) : updateInfo.data?.available ? (
|
||||
<Chip
|
||||
icon={
|
||||
<span className="material-symbols-rounded">
|
||||
new_releases
|
||||
</span>
|
||||
}
|
||||
label={
|
||||
<Typography variant="subtitle2">
|
||||
{applicationVersion}
|
||||
</Typography>
|
||||
}
|
||||
color="success"
|
||||
size="small"
|
||||
style={{
|
||||
width: "fit-content !important",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
"No update found."
|
||||
)}
|
||||
</Typography>
|
||||
</div>
|
||||
<LoadingButton
|
||||
style={{
|
||||
marginTop: "auto",
|
||||
}}
|
||||
loading={updateInfo.isFetching || updating}
|
||||
variant="contained"
|
||||
disabled={!updateInfo.data?.available}
|
||||
loadingPosition="start"
|
||||
onClick={async () => {
|
||||
if (updateInfo.data?.available) {
|
||||
setUpdating(true);
|
||||
await updateInfo.data?.downloadAndInstall();
|
||||
enqueueSnackbar(
|
||||
"Update has been installed! You need to relaunch Blink.",
|
||||
{
|
||||
variant: "success",
|
||||
},
|
||||
);
|
||||
await relaunch();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{updateInfo.isFetching
|
||||
? "Checking for Update..."
|
||||
: updateInfo.data?.available
|
||||
? "Update"
|
||||
: "No Update Found"}
|
||||
</LoadingButton>
|
||||
</div>
|
||||
{systemInfo.isSuccess ? (
|
||||
<div className="settings-info-container">
|
||||
<div className="settings-info">
|
||||
<Typography variant="subtitle2">Server:</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{systemInfo.data?.ServerName}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-info">
|
||||
<Typography variant="subtitle2">
|
||||
Jellyfin Version:
|
||||
</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{systemInfo.data?.Version}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-info">
|
||||
<Typography variant="subtitle2">
|
||||
Server Architecture:
|
||||
</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{systemInfo.data?.SystemArchitecture}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<Skeleton
|
||||
variant="rectangular"
|
||||
sx={{
|
||||
height: "100%",
|
||||
borderRadius: "10px",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
marginTop: "1em",
|
||||
background: "rgb(0 0 0 / 0.3)",
|
||||
padding: "1em",
|
||||
borderRadius: "10px",
|
||||
}}
|
||||
>
|
||||
<Typography variant="subtitle1" mb={1}>
|
||||
Links:
|
||||
</Typography>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "flex-start",
|
||||
gap: "0.1em",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
component={Link}
|
||||
variant="subtitle2"
|
||||
target="_blank"
|
||||
href="https://github.com/prayag17/Blink"
|
||||
>
|
||||
https://github.com/prayag17/Blink
|
||||
</Typography>
|
||||
<Typography
|
||||
component={Link}
|
||||
variant="subtitle2"
|
||||
target="_blank"
|
||||
href="https://jellyfin.org"
|
||||
>
|
||||
https://jellyfin.org
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
|
||||
{/* Add Server */}
|
||||
<Dialog
|
||||
open={addServerDialog}
|
||||
fullWidth
|
||||
hideBackdrop
|
||||
disableScrollLock={true}
|
||||
>
|
||||
<DialogTitle>Add Server</DialogTitle>
|
||||
<DialogContent className="settings-server-add">
|
||||
<TextField
|
||||
variant="filled"
|
||||
label="Address"
|
||||
fullWidth
|
||||
onChange={(e) => setServerIp(e.target.value)}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions
|
||||
style={{
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
padding: "1em",
|
||||
gap: "1em",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
cancel
|
||||
</span>
|
||||
}
|
||||
color="error"
|
||||
onClick={() => setAddServerDialog(false)}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
{/* @ts-ignore */}
|
||||
<LoadingButton
|
||||
startIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
add_circle
|
||||
</span>
|
||||
}
|
||||
variant="contained"
|
||||
loading={addServer.isPending}
|
||||
loadingPosition="start"
|
||||
onClick={addServer.mutate}
|
||||
color="success"
|
||||
>
|
||||
Add
|
||||
</LoadingButton>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default Settings;
|
||||
@@ -1,151 +0,0 @@
|
||||
.settings {
|
||||
display: grid !important;
|
||||
grid-template-columns: 20% 1fr;
|
||||
height: 60vh;
|
||||
overflow: hidden !important;
|
||||
.MuiTabs-flexContainerVertical {
|
||||
height: 100%;
|
||||
}
|
||||
&-container {
|
||||
margin: 14px 0 14px 14px;
|
||||
}
|
||||
&-tab {
|
||||
display: grid !important;
|
||||
grid-template-columns: 2em 1fr;
|
||||
align-items: center;
|
||||
justify-items: start !important;
|
||||
gap: 1em;
|
||||
& .material-symbols-rounded {
|
||||
justify-self: center !important;
|
||||
}
|
||||
}
|
||||
&-scroll {
|
||||
overflow-y: auto;
|
||||
scrollbar-gutter: stable;
|
||||
overscroll-behavior: contain;
|
||||
// Magic scrollbar
|
||||
&::-webkit-scrollbar {
|
||||
&-thumb {
|
||||
height: 150px;
|
||||
max-height: 33%;
|
||||
}
|
||||
&-track {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
background: transparent !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
// About page
|
||||
&-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: 1em;
|
||||
}
|
||||
&-logo {
|
||||
width: 100%;
|
||||
background: rgb(255 255 255 / 1);
|
||||
padding: 0em;
|
||||
height: 10em;
|
||||
margin-bottom: 1em;
|
||||
border-radius: $border-radius-default;
|
||||
object-fit: contain;
|
||||
}
|
||||
&-info {
|
||||
display: grid;
|
||||
grid-template-columns: 40% 1fr;
|
||||
gap: 1em;
|
||||
justify-items: start;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid rgb(255 255 255 / 0.1);
|
||||
padding-bottom: 0.5em;
|
||||
&-container {
|
||||
background: rgb(0 0 0 / 0.3);
|
||||
padding: 1em;
|
||||
border-radius: $border-radius-default;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6em;
|
||||
width: 100%;
|
||||
}
|
||||
&:last-child {
|
||||
border: none;
|
||||
padding-bottom: 0em;
|
||||
}
|
||||
> :last-child {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
//settings
|
||||
&-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
margin-bottom: 0.6em !important;
|
||||
&-info-caption {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
//serverList
|
||||
&-server {
|
||||
display: grid;
|
||||
grid-template-columns: 3.4em 1fr auto;
|
||||
justify-items: start;
|
||||
align-items: center;
|
||||
gap: 0.8em;
|
||||
background: rgb(0 0 0 / 0.3);
|
||||
padding: 1em;
|
||||
width: 100%;
|
||||
border-radius: $border-radius-default;
|
||||
&-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
align-items: center;
|
||||
padding-bottom: 4.6em;
|
||||
}
|
||||
&-icon {
|
||||
font-size: 3.4em !important;
|
||||
font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 10, "opsz" 40;
|
||||
}
|
||||
&-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
// width: 100%;
|
||||
&-version {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4em;
|
||||
}
|
||||
}
|
||||
&-buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 0.5em;
|
||||
// width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
&-fab-container {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
bottom: 14px;
|
||||
right: 14px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.8em;
|
||||
}
|
||||
// Dialog
|
||||
&-add {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 1em;
|
||||
}
|
||||
}
|
||||
}
|
||||
.Mui-selected .material-symbols-rounded {
|
||||
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
import { Skeleton } from "@mui/material";
|
||||
import { motion } from "framer-motion";
|
||||
import { motion } from "motion/react";
|
||||
|
||||
const ItemSkeleton = () => {
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Divider from "@mui/material/Divider";
|
||||
import Grid2 from "@mui/material/Grid2";
|
||||
import Grid2 from "@mui/material/Grid";
|
||||
import Skeleton from "@mui/material/Skeleton";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import React from "react";
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Chip,
|
||||
CircularProgress,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
Link,
|
||||
Stack,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { relaunch } from "@tauri-apps/plugin-process";
|
||||
import { type Update, check } from "@tauri-apps/plugin-updater";
|
||||
import { open } from "@tauri-apps/plugin-shell";
|
||||
import { check, type Update } from "@tauri-apps/plugin-updater";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React, { useLayoutEffect, useState } from "react";
|
||||
import React, { useCallback, useLayoutEffect, useState } from "react";
|
||||
|
||||
export default function Updater() {
|
||||
const [updateDialog, setUpdateDialog] = useState(false);
|
||||
@@ -23,8 +24,8 @@ export default function Updater() {
|
||||
async function checkForUpdates() {
|
||||
try {
|
||||
const update = await check();
|
||||
|
||||
if (update?.available) {
|
||||
if (update) {
|
||||
// console.log(update);
|
||||
setUpdateInfo(update);
|
||||
setUpdateDialog(true);
|
||||
|
||||
@@ -37,95 +38,281 @@ export default function Updater() {
|
||||
checkForUpdates();
|
||||
}, []);
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const [downloadProgress, setDownloadProgress] = useState(0);
|
||||
const [downloadSize, setDownloadSize] = useState(0);
|
||||
const handleUpdate = useCallback(async () => {
|
||||
try {
|
||||
setUpdateDialogButton(true);
|
||||
await updateInfo?.downloadAndInstall((e) => {
|
||||
switch (e.event) {
|
||||
case "Started":
|
||||
setDownloadSize(e.data.contentLength ?? 0);
|
||||
break;
|
||||
case "Progress":
|
||||
setDownloadProgress((s) => s + e.data.chunkLength);
|
||||
break;
|
||||
case "Finished":
|
||||
setDownloadProgress(downloadSize);
|
||||
break;
|
||||
}
|
||||
});
|
||||
enqueueSnackbar(
|
||||
"Update has been installed! You need to relaunch Blink.",
|
||||
{
|
||||
variant: "success",
|
||||
},
|
||||
);
|
||||
await relaunch();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
enqueueSnackbar(`Failed to update Blink. ${error}`, { variant: "error" });
|
||||
}
|
||||
setUpdateDialogButton(false);
|
||||
}, [enqueueSnackbar, updateInfo, downloadSize]);
|
||||
|
||||
if (!updateInfo) return null;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={updateDialog}
|
||||
maxWidth="xs"
|
||||
PaperProps={{
|
||||
style: {
|
||||
borderRadius: "20px",
|
||||
fullWidth
|
||||
slotProps={{
|
||||
paper: {
|
||||
className: "glass",
|
||||
style: {
|
||||
borderRadius: "24px",
|
||||
overflow: "hidden",
|
||||
},
|
||||
},
|
||||
className: "glass",
|
||||
}}
|
||||
sx={{
|
||||
"& img": {
|
||||
width: "100%",
|
||||
backdrop: {
|
||||
style: {
|
||||
backdropFilter: "blur(5px)",
|
||||
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle variant="h5" align="center" textAlign={"center"}>
|
||||
Update Available!
|
||||
</DialogTitle>
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: "140px",
|
||||
opacity: 0.5,
|
||||
background: (theme) =>
|
||||
`linear-gradient(135deg, ${theme.palette.primary.main} 0%, ${theme.palette.secondary.main} 100%)`,
|
||||
zIndex: 0,
|
||||
filter: "blur(40px)",
|
||||
transform: "translateY(-50%) scale(1.5)",
|
||||
}}
|
||||
/>
|
||||
|
||||
<DialogContent
|
||||
className="flex flex-center"
|
||||
style={{ gap: "0.5em", padding: "0 2em 1em 2em", flexWrap: "wrap" }}
|
||||
sx={{ position: "relative", zIndex: 1, pt: 5, pb: 3, px: 3 }}
|
||||
>
|
||||
<Chip
|
||||
icon={<span className="material-symbols-rounded">update</span>}
|
||||
label={`v${updateInfo.currentVersion}`}
|
||||
variant="outlined"
|
||||
/>
|
||||
<span className="material-symbols-rounded">arrow_right_alt</span>
|
||||
<Chip
|
||||
icon={<span className="material-symbols-rounded">update</span>}
|
||||
label={`v${updateInfo.version}`}
|
||||
variant="outlined"
|
||||
/>
|
||||
<DialogContentText sx={{ width: "100%" }}>
|
||||
<Link
|
||||
href={`https://github.com/prayag17/Blink/releases/v${updateInfo.version}`}
|
||||
target="_blank"
|
||||
<Stack alignItems="center" spacing={3}>
|
||||
<Box
|
||||
sx={{
|
||||
width: 72,
|
||||
height: 72,
|
||||
borderRadius: "50%",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
background: (theme) =>
|
||||
`linear-gradient(135deg, ${theme.palette.primary.main} 0%, ${theme.palette.secondary.main} 100%)`,
|
||||
boxShadow: (theme) =>
|
||||
`0 10px 25px -5px ${theme.palette.primary.main}80`,
|
||||
mb: 1,
|
||||
}}
|
||||
>
|
||||
Open changelog
|
||||
</Link>
|
||||
</DialogContentText>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: "36px", color: "white" }}
|
||||
>
|
||||
rocket_launch
|
||||
</span>
|
||||
</Box>
|
||||
|
||||
<Stack spacing={1} textAlign="center">
|
||||
<Typography
|
||||
variant="h5"
|
||||
fontWeight="900"
|
||||
sx={{
|
||||
background: (theme) =>
|
||||
`linear-gradient(135deg, ${theme.palette.primary.light} 0%, ${theme.palette.secondary.light} 100%)`,
|
||||
backgroundClip: "text",
|
||||
WebkitBackgroundClip: "text",
|
||||
color: "transparent",
|
||||
}}
|
||||
>
|
||||
Update Available
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
color="text.secondary"
|
||||
sx={{ maxWidth: "25ch" }}
|
||||
>
|
||||
A new version of Blink is ready for you.
|
||||
</Typography>
|
||||
</Stack>
|
||||
|
||||
<Stack
|
||||
direction="row"
|
||||
alignItems="center"
|
||||
justifyContent="space-between"
|
||||
sx={{
|
||||
width: "100%",
|
||||
bgcolor: "rgba(255,255,255,0.03)",
|
||||
borderRadius: 4,
|
||||
p: 2.5,
|
||||
border: "1px solid rgba(255,255,255,0.05)",
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Typography
|
||||
variant="caption"
|
||||
color="text.secondary"
|
||||
sx={{ mb: 0.5 }}
|
||||
>
|
||||
Current
|
||||
</Typography>
|
||||
<Typography variant="subtitle1" fontWeight="bold">
|
||||
v{updateInfo.currentVersion}
|
||||
</Typography>
|
||||
</Stack>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
width: 32,
|
||||
height: 32,
|
||||
borderRadius: "50%",
|
||||
bgcolor: "rgba(255,255,255,0.05)",
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
fontSize: "16px",
|
||||
color: "rgba(255,255,255,0.5)",
|
||||
}}
|
||||
>
|
||||
arrow_forward
|
||||
</span>
|
||||
</Box>
|
||||
|
||||
<Stack alignItems="flex-end">
|
||||
<Typography
|
||||
variant="caption"
|
||||
color="primary.main"
|
||||
sx={{ mb: 0.5 }}
|
||||
>
|
||||
New Version
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
fontWeight="bold"
|
||||
color="primary.main"
|
||||
>
|
||||
v{updateInfo.version}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
<Button
|
||||
onClick={() =>
|
||||
open(
|
||||
`https://github.com/prayag17/Blink/releases/v${updateInfo.version}`,
|
||||
)
|
||||
}
|
||||
size="small"
|
||||
sx={{
|
||||
textTransform: "none",
|
||||
cursor: "pointer",
|
||||
color: "text.secondary",
|
||||
borderRadius: "100px",
|
||||
px: 2,
|
||||
"&:hover": {
|
||||
color: "primary.main",
|
||||
bgcolor: "rgba(255,255,255,0.05)",
|
||||
},
|
||||
}}
|
||||
endIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: 16 }}
|
||||
>
|
||||
open_in_new
|
||||
</span>
|
||||
}
|
||||
>
|
||||
See what's new
|
||||
</Button>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
|
||||
<DialogActions
|
||||
style={{
|
||||
padding: "1em",
|
||||
sx={{
|
||||
p: 3,
|
||||
pt: 0,
|
||||
justifyContent: "space-between",
|
||||
gap: 1.5,
|
||||
}}
|
||||
className="flex flex-center"
|
||||
>
|
||||
{/* <Button
|
||||
variant="outlined"
|
||||
//@ts-ignore
|
||||
color="white"
|
||||
disabled={updateDialogButton}
|
||||
onClick={() => setUpdateDialog(false)}
|
||||
>
|
||||
changelog
|
||||
</Button> */}
|
||||
<Button
|
||||
color="error"
|
||||
variant="contained"
|
||||
disabled={updateDialogButton}
|
||||
color="inherit"
|
||||
size="large"
|
||||
onClick={() => setUpdateDialog(false)}
|
||||
style={{ borderRadius: "10px" }}
|
||||
disableElevation
|
||||
sx={{
|
||||
borderRadius: "14px",
|
||||
flex: 1,
|
||||
color: "text.secondary",
|
||||
height: 48,
|
||||
"&:hover": {
|
||||
bgcolor: "rgba(255,255,255,0.05)",
|
||||
color: "text.primary",
|
||||
},
|
||||
}}
|
||||
>
|
||||
close
|
||||
Later
|
||||
</Button>
|
||||
<LoadingButton
|
||||
style={{ borderRadius: "10px" }}
|
||||
color="success"
|
||||
<Button
|
||||
size="large"
|
||||
variant="contained"
|
||||
loading={updateDialogButton}
|
||||
loadingIndicator="Updating..."
|
||||
loadingIndicator={
|
||||
<CircularProgress
|
||||
size={24}
|
||||
color="inherit"
|
||||
value={downloadProgress / downloadSize}
|
||||
/>
|
||||
}
|
||||
disableElevation
|
||||
onClick={async () => {
|
||||
setUpdateDialogButton(true);
|
||||
await updateInfo.downloadAndInstall();
|
||||
enqueueSnackbar("Update has been installed! You need to relaunch Blink.", {
|
||||
variant: "success",
|
||||
});
|
||||
await relaunch();
|
||||
onClick={handleUpdate}
|
||||
sx={{
|
||||
borderRadius: "14px",
|
||||
flex: 1,
|
||||
height: 48,
|
||||
background: (theme) =>
|
||||
`linear-gradient(135deg, ${theme.palette.primary.main} 0%, ${theme.palette.secondary.main} 100%)`,
|
||||
boxShadow: (theme) =>
|
||||
`0 8px 20px -5px ${theme.palette.primary.main}60`,
|
||||
"&:hover": {
|
||||
background: (theme) =>
|
||||
`linear-gradient(135deg, ${theme.palette.primary.main} 0%, ${theme.palette.secondary.main} 100%)`,
|
||||
opacity: 0.9,
|
||||
boxShadow: (theme) =>
|
||||
`0 12px 25px -5px ${theme.palette.primary.main}80`,
|
||||
},
|
||||
}}
|
||||
>
|
||||
Update
|
||||
</LoadingButton>
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
import {
|
||||
Avatar,
|
||||
Divider,
|
||||
IconButton,
|
||||
ListItemIcon,
|
||||
Menu,
|
||||
MenuItem,
|
||||
} from "@mui/material";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useNavigate, useRouter } from "@tanstack/react-router";
|
||||
import React, {
|
||||
type MouseEventHandler,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
export const UserAvatarMenu = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
const [user, resetCurrentUser] = useCentralStore((s) => [
|
||||
s.currentUser,
|
||||
s.resetCurrentUser,
|
||||
]);
|
||||
const navigate = useNavigate();
|
||||
const router = useRouter();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
||||
const openMenu = Boolean(anchorEl);
|
||||
|
||||
const handleMenuOpen: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||
(event) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const handleMenuClose = useCallback(() => {
|
||||
setAnchorEl(null);
|
||||
}, []);
|
||||
|
||||
const handleLogout = useCallback(async () => {
|
||||
console.log("Logging out user...");
|
||||
await api?.logout();
|
||||
createApi(api?.basePath ?? "", undefined);
|
||||
resetCurrentUser();
|
||||
delUser();
|
||||
sessionStorage.removeItem("accessToken");
|
||||
queryClient.clear();
|
||||
await router.invalidate();
|
||||
setAnchorEl(null);
|
||||
navigate({ to: "/login", replace: true });
|
||||
}, [api, createApi, navigate, queryClient, resetCurrentUser, router]);
|
||||
|
||||
const menuButtonSx = useMemo(() => ({ p: 0 }), []);
|
||||
const menuStyle = useMemo(() => ({ mt: 2 }), []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<IconButton sx={menuButtonSx} onClick={handleMenuOpen}>
|
||||
{!!user?.Id &&
|
||||
(user?.PrimaryImageTag === undefined ? (
|
||||
<Avatar className="appBar-avatar" alt={user?.Name ?? "image"}>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
) : (
|
||||
<Avatar
|
||||
className="appBar-avatar"
|
||||
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
||||
alt={user?.Name ?? "image"}
|
||||
>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
))}
|
||||
</IconButton>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
open={openMenu}
|
||||
onClose={handleMenuClose}
|
||||
sx={menuStyle}
|
||||
disableScrollLock
|
||||
PaperProps={{ className: "glass" }}
|
||||
>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
handleLogout();
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">logout</span>
|
||||
</ListItemIcon>
|
||||
Logout
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/preferences" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">tune</span>
|
||||
</ListItemIcon>
|
||||
Preferences
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/about" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">info</span>
|
||||
</ListItemIcon>
|
||||
About
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Loaded 100 of 179 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user