Compare commits
162
Commits
v0.0.7-dev
...
nightly
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
295b8da8eb | ||
|
|
6d1c55dda5 | ||
|
|
0c47660501 | ||
|
|
e9b37d99aa | ||
|
|
f19ffb4361 | ||
|
|
ce533dde4b | ||
|
|
6d2448ef36 | ||
|
|
c572cb35cb | ||
|
|
f57e78b244 | ||
|
|
af8dec5844 | ||
|
|
7d2659f32b | ||
|
|
06015d7702 | ||
|
|
0847c2b2ef | ||
|
|
bc6d39b004 | ||
|
|
9f7fde2173 | ||
|
|
7410c8f3e3 | ||
|
|
fcf18c01e8 | ||
|
|
620b4ce253 | ||
|
|
9dbe11ce23 | ||
|
|
5d5f127525 | ||
|
|
d7f3892ff3 | ||
|
|
dc72f381e8 | ||
|
|
d238aeff1f | ||
|
|
1c38893c68 | ||
|
|
000e62873a | ||
|
|
5b322d49e6 | ||
|
|
232aad5e8a | ||
|
|
7aceb89e11 | ||
|
|
42c154f17a | ||
|
|
27cc14c1f5 | ||
|
|
cf8c5d4490 | ||
|
|
97526e29b4 | ||
|
|
e049ce9ad6 | ||
|
|
561daa7d81 | ||
|
|
2ad920af9d | ||
|
|
907753b041 | ||
|
|
591fce7e5c | ||
|
|
9d96667d60 | ||
|
|
5c8624a73c | ||
|
|
0319d9711e | ||
|
|
70da3b3754 | ||
|
|
98078585d6 | ||
|
|
cf66b8d20c | ||
|
|
a198e09864 | ||
|
|
25d9702283 | ||
|
|
0790f0afd5 | ||
|
|
240ed3b365 | ||
|
|
5cd9b57e1f | ||
|
|
88b016f6f5 | ||
|
|
8a459f588d | ||
|
|
6c5335648d | ||
|
|
fc9abf6c5b | ||
|
|
a53224f802 | ||
|
|
865c42b419 | ||
|
|
12f963d718 | ||
|
|
8917dd240a | ||
|
|
685ef4b2fc | ||
|
|
f141ddbaf3 | ||
|
|
6e55a287eb | ||
|
|
9c110ea8fa | ||
|
|
ebbe686a57 | ||
|
|
2cb10aa342 | ||
|
|
a64f5876f2 | ||
|
|
95a180e968 | ||
|
|
99ec17501d | ||
|
|
a7eab72639 | ||
|
|
81695a583d | ||
|
|
c6b5d6a4a2 | ||
|
|
7ef8e33669 | ||
|
|
9be02b6392 | ||
|
|
dd16f3a204 | ||
|
|
7e7f44ce94 | ||
|
|
61fa734629 | ||
|
|
45f67aac40 | ||
|
|
19343b4ea3 | ||
|
|
0dde74ab70 |
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']
|
||||||
@@ -13,12 +13,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 7
|
version: 10
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
- name: Get pnpm store directory
|
||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v5
|
||||||
name: Setup pnpm cache
|
name: Setup pnpm cache
|
||||||
with:
|
with:
|
||||||
path: ${{ env.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
- name: Sync node version and setup cache
|
- name: Sync node version and setup cache
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "lts/*"
|
node-version: "lts/*"
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
@@ -61,7 +61,7 @@ jobs:
|
|||||||
environment: TAURI
|
environment: TAURI
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Install dependencies (ubuntu only)
|
- name: Install dependencies (ubuntu only)
|
||||||
if: matrix.platform == 'ubuntu-22.04'
|
if: matrix.platform == 'ubuntu-22.04'
|
||||||
@@ -78,10 +78,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
workspaces: "./src-tauri -> target"
|
workspaces: "./src-tauri -> target"
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 7
|
version: 10
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
- name: Get pnpm store directory
|
||||||
@@ -89,7 +89,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v5
|
||||||
name: Setup pnpm cache
|
name: Setup pnpm cache
|
||||||
with:
|
with:
|
||||||
path: ${{ env.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
@@ -98,7 +98,7 @@ jobs:
|
|||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
- name: Sync node version and setup cache
|
- name: Sync node version and setup cache
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "lts/*"
|
node-version: "lts/*"
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
@@ -107,7 +107,7 @@ jobs:
|
|||||||
run: pnpm install --no-frozen-lockfile
|
run: pnpm install --no-frozen-lockfile
|
||||||
|
|
||||||
- name: Build app
|
- name: Build app
|
||||||
run: pnpm run tauri build
|
run: pnpm run tauri build --debug
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
@@ -115,8 +115,145 @@ jobs:
|
|||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
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
|
- name: Upload build Artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: Blink-${{ matrix.platform }}-dev${{ github.sha }}
|
name: Blink-${{ matrix.platform }}-dev${{ github.sha }}
|
||||||
path: src-tauri/target/release/bundle/*
|
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@v4.2.2
|
||||||
|
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v4.3.0
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install mime-types
|
||||||
|
|
||||||
|
- name: Get commit details
|
||||||
|
id: commit-details
|
||||||
|
run: |
|
||||||
|
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
|
||||||
|
- name: Create or update nightly release
|
||||||
|
uses: actions/github-script@v7.0.1
|
||||||
|
env:
|
||||||
|
COMMIT_MESSAGE: ${{ steps.commit-details.outputs.message }}
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
// Get today's date in YYYY-MM-DD format
|
||||||
|
const today = new Date().toISOString().split('T')[0];
|
||||||
|
const releaseTag = 'nightly';
|
||||||
|
const releaseName = `Nightly Build (${today})`;
|
||||||
|
|
||||||
|
// Check if nightly release already exists
|
||||||
|
console.log("Checking for existing nightly release...");
|
||||||
|
let release;
|
||||||
|
try {
|
||||||
|
release = await github.rest.repos.getReleaseByTag({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
tag: releaseTag
|
||||||
|
});
|
||||||
|
console.log("Found existing nightly release");
|
||||||
|
} catch (error) {
|
||||||
|
if (error.status === 404) {
|
||||||
|
console.log("No existing nightly release found, creating one...");
|
||||||
|
release = await github.rest.repos.createRelease({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
tag_name: releaseTag,
|
||||||
|
name: releaseName,
|
||||||
|
body: `Nightly build created on ${today} from the latest main branch\nLast commit: ${context.sha}\nCommit message: ${process.env.COMMIT_MESSAGE || "No commit message available"}`,
|
||||||
|
prerelease: true
|
||||||
|
});
|
||||||
|
release = release.data;
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle the case where we have an existing release
|
||||||
|
// The release object structure differs depending on whether it came from getReleaseByTag or createRelease
|
||||||
|
const releaseId = release.data ? release.data.id : release.id;
|
||||||
|
|
||||||
|
if (releaseId) {
|
||||||
|
// Update existing release
|
||||||
|
console.log("Updating existing nightly release...");
|
||||||
|
const updateResult = await github.rest.repos.updateRelease({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
release_id: releaseId,
|
||||||
|
name: releaseName,
|
||||||
|
body: `Nightly build updated on ${today} from the latest main branch.\nLast commit: ${context.sha}\nCommit message: ${process.env.COMMIT_MESSAGE || "No commit message available"}`,
|
||||||
|
prerelease: true
|
||||||
|
});
|
||||||
|
release = updateResult.data;
|
||||||
|
}
|
||||||
|
// Delete existing assets to replace them with new ones
|
||||||
|
if (release.assets && release.assets.length > 0) {
|
||||||
|
console.log("Deleting existing release assets...");
|
||||||
|
for (const asset of release.assets) {
|
||||||
|
await github.rest.repos.deleteReleaseAsset({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
asset_id: asset.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Upload new artifacts
|
||||||
|
console.log("Uploading new artifacts...");
|
||||||
|
const artifactsDir = 'artifacts';
|
||||||
|
const platforms = ['macos-latest', 'ubuntu-22.04', 'windows-latest'];
|
||||||
|
const mime = require('mime-types');
|
||||||
|
|
||||||
|
for (const platform of platforms) {
|
||||||
|
const platformDir = path.join(artifactsDir, `Blink-${platform}-dev${context.sha}`);
|
||||||
|
|
||||||
|
if (!fs.existsSync(platformDir)) {
|
||||||
|
console.log(`No artifacts found for ${platform}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = fs.readdirSync(platformDir, { recursive: true });
|
||||||
|
for (const file of files) {
|
||||||
|
if (typeof file === 'string' && !fs.statSync(path.join(platformDir, file)).isDirectory()) {
|
||||||
|
const filePath = path.join(platformDir, file);
|
||||||
|
const fileName = path.basename(filePath);
|
||||||
|
const contentType = mime.lookup(fileName) || 'application/octet-stream';
|
||||||
|
|
||||||
|
console.log(`Uploading ${fileName} from ${platform}...`);
|
||||||
|
|
||||||
|
// Use Octokit's uploadReleaseAsset with proper content type for binary data
|
||||||
|
await github.rest.repos.uploadReleaseAsset({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
release_id: release.id,
|
||||||
|
name: `${platform.replace(/-/g, '_')}-${fileName}`,
|
||||||
|
data: fs.readFileSync(filePath),
|
||||||
|
headers: {
|
||||||
|
'content-type': contentType,
|
||||||
|
'content-length': fs.statSync(filePath).size
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Nightly release updated successfully!");
|
||||||
@@ -17,7 +17,7 @@ jobs:
|
|||||||
environment: TAURI
|
environment: TAURI
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Install dependencies (ubuntu only)
|
- name: Install dependencies (ubuntu only)
|
||||||
if: matrix.platform == 'ubuntu-22.04'
|
if: matrix.platform == 'ubuntu-22.04'
|
||||||
@@ -28,16 +28,19 @@ jobs:
|
|||||||
|
|
||||||
- name: Rust setup
|
- name: Rust setup
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
|
||||||
|
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
||||||
|
|
||||||
- name: Rust cache
|
- name: Rust cache
|
||||||
uses: swatinem/rust-cache@v2
|
uses: swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: "./src-tauri -> target"
|
workspaces: "./src-tauri -> target"
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v3
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
version: 7
|
version: 10
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Get pnpm store directory
|
- name: Get pnpm store directory
|
||||||
@@ -45,7 +48,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v5
|
||||||
name: Setup pnpm cache
|
name: Setup pnpm cache
|
||||||
with:
|
with:
|
||||||
path: ${{ env.STORE_PATH }}
|
path: ${{ env.STORE_PATH }}
|
||||||
@@ -54,7 +57,7 @@ jobs:
|
|||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
- name: Sync node version and setup cache
|
- name: Sync node version and setup cache
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "lts/*"
|
node-version: "lts/*"
|
||||||
cache: "pnpm" # Set this to npm, yarn or pnpm.
|
cache: "pnpm" # Set this to npm, yarn or pnpm.
|
||||||
@@ -72,9 +75,14 @@ jobs:
|
|||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
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
|
||||||
with:
|
with:
|
||||||
tagName: ${{ github.ref_name }} # This only works if your workflow triggers on new tags.
|
tagName: ${{ github.ref_name }} # This only works if your workflow triggers on new tags.
|
||||||
releaseName: "App Name v__VERSION__" # tauri-action replaces \_\_VERSION\_\_ with the app version.
|
releaseName: "App Name v__VERSION__" # tauri-action replaces \_\_VERSION\_\_ with the app version.
|
||||||
releaseBody: "See the assets to download and install this version."
|
releaseBody: "See the assets to download and install this version."
|
||||||
releaseDraft: true
|
releaseDraft: true
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
args: ${{ matrix.platform == 'macos-latest' && '--target universal-apple-darwin' || '' }}
|
||||||
@@ -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@19e706d4c9121098010096f9c495a70a7518b30f
|
||||||
|
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@19e706d4c9121098010096f9c495a70a7518b30f
|
||||||
|
with:
|
||||||
|
identifier: prayag17.Blink
|
||||||
|
version: ${{ github.event.release.tag_name }}
|
||||||
|
installers-regex: '\.exe$'
|
||||||
|
token: ${{ secrets.WINGET_TOKEN }}
|
||||||
@@ -38,3 +38,7 @@ target/
|
|||||||
|
|
||||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
*.pdb
|
*.pdb
|
||||||
|
|
||||||
|
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
|
|
||||||
@@ -1,3 +1,79 @@
|
|||||||
|
- # Alpha 3 (11/12/2024)
|
||||||
|
- refactor: prepare for alpha 3
|
||||||
|
- refactor: cleanup
|
||||||
|
- refactor: remove unused imports
|
||||||
|
- fix: series page not fetching correct season
|
||||||
|
- feat: add key binding for macos users #435
|
||||||
|
- refactor: remove jellyPlayer naming from code #460
|
||||||
|
- feat: add playlist playback support
|
||||||
|
- refactor: improve server add process
|
||||||
|
- feat: show current time while scrubbing video progress #339
|
||||||
|
- style: increase the sharpness of card images
|
||||||
|
- feat: add skip recap button
|
||||||
|
- refactor: cleanup video player
|
||||||
|
- feat: add chapter navigation buttons to video player #457
|
||||||
|
- feat: allow changing audio track from video player
|
||||||
|
- feat: allow changing chapters from a chapter list #457
|
||||||
|
- refactor: cleanup search route
|
||||||
|
- refactor: cleanup some components
|
||||||
|
- refactor: unmount card image if not inView
|
||||||
|
- refactor: cleanup person route
|
||||||
|
- style: replace noto-sans with plus-jakarta-sans
|
||||||
|
- refactor: cleanup login routes
|
||||||
|
- fix: library items not of same size #380
|
||||||
|
- refactor: cleanup item.tsx
|
||||||
|
- fix: series page breaking if season is not loaded
|
||||||
|
- fix: do not display missing items in series
|
||||||
|
- refactor: move more files to ts
|
||||||
|
- refactor: move more files to ts
|
||||||
|
- refactor: move more files to ts
|
||||||
|
- refactor: move more files to typescript
|
||||||
|
- refactor: move more components to ts
|
||||||
|
- refactore: cleanup __root.tsx
|
||||||
|
- chore(deps): update dependencies
|
||||||
|
- fix: collections page not rendering #447
|
||||||
|
- fix: quick connect not working #445
|
||||||
|
- fix: playback error if subtitle is not set
|
||||||
|
- fix: index not being assigned proper value #420
|
||||||
|
- fix: synced lyrics not working
|
||||||
|
- Merge pull request #446 from prayag17/renovate/node-22.x-lockfile
|
||||||
|
- refactor: use saved lyrics
|
||||||
|
- refactor: change GenreView to genreFilter
|
||||||
|
- fix(deps): update dependency @types/node to v22.10.1
|
||||||
|
- Merge pull request #393 from prayag17/renovate/tanstack-router-monorepo
|
||||||
|
- Merge pull request #424 from prayag17/renovate/tanstack-query-monorepo
|
||||||
|
- fix(deps): update tanstack-router monorepo
|
||||||
|
- Merge pull request #426 from prayag17/renovate/node-22.x-lockfile
|
||||||
|
- fix(deps): update dependency @types/node to v22.10.0
|
||||||
|
- Merge pull request #437 from prayag17/dependabot/cargo/src-tauri/rustls-0.23.18
|
||||||
|
- fix(deps): update tanstack-query monorepo to v5.61.4
|
||||||
|
- Merge pull request #438 from prayag17/renovate/axios-1.x-lockfile
|
||||||
|
- Merge pull request #439 from prayag17/renovate/vitejs-plugin-react-4.x-lockfile
|
||||||
|
- chore(deps): update dependency @vitejs/plugin-react to v4.3.4
|
||||||
|
- refactore: move more components to typescript
|
||||||
|
- fix: episode and series not playing if episode is not present in nextUp and continueWatching
|
||||||
|
- feat: show current episode in PlayButton
|
||||||
|
- fix: episode indexing for absolute numbering indexNumbers in PlayButton
|
||||||
|
- fix: unable to read Id of undefined in PlayButton
|
||||||
|
- fix(deps): update dependency axios to v1.7.8
|
||||||
|
- chore(deps): bump rustls from 0.23.16 to 0.23.18 in /src-tauri
|
||||||
|
- fix(ci): not uploading debug builds
|
||||||
|
- refactor(ci): build debug builds in CI
|
||||||
|
- Merge pull request #425 from prayag17/renovate/serde_json-1.x-lockfile
|
||||||
|
- Merge pull request #436 from sambartik/macos-universal-dmg
|
||||||
|
- chore(deps): update dependencies
|
||||||
|
- refactor: convert more files to typescript
|
||||||
|
- fix: improper handling of undefined api leading to crashes
|
||||||
|
- refactor: move all buttons to tsx #338
|
||||||
|
- Add universal dmg for macOS in release job
|
||||||
|
- fix: audio queue not moving after 2 changes #182
|
||||||
|
- fix: playing track from album not updating the queue #182
|
||||||
|
- refactor: use MediaSegments api for intro/outro skipping
|
||||||
|
- fix: trickplay images not showing up
|
||||||
|
- refactor: improve login page UI #338 #202
|
||||||
|
- chore(release): update latest.json
|
||||||
|
- fix(deps): update rust crate serde_json to v1.0.133
|
||||||
|
|
||||||
- # 0.0.7-dev (20/11/2024)
|
- # 0.0.7-dev (20/11/2024)
|
||||||
- chore(deps): update dependencies
|
- chore(deps): update dependencies
|
||||||
- refactor: change UI of login/list and fix Api not being defined in context
|
- refactor: change UI of login/list and fix Api not being defined in context
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||

|

|
||||||
<div align="center">
|
<div align="center">
|
||||||
<img alt="GitHub Release" src="https://img.shields.io/github/v/release/prayag17/JellyPlayer?sort=date&display_name=tag&style=for-the-badge&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODc4IiBoZWlnaHQ9IjEwMTIiIHZpZXdCb3g9IjAgMCA4NzggMTAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00MzguODA5IDUwNkwzNS40MDQ4IDczOC45MDZMNDM4LjgwOSA5NzEuODEyTDg0Mi4yMTQgNzM4LjkwNlYyNzMuMDk0TDQzOC44MDkgNDAuMTg4NUwzNS40MDQ4IDI3My4wOTRMNDM4LjgwOSA1MDZaTTQzOC44MDkgMEw4NzcuMDE4IDI1M1Y3NTlMNDM4LjgwOSAxMDEyTDAuNjAwNTg2IDc1OVY3MTguODEyVjI5My4xODhWMjUzTDQzOC44MDkgMFoiIGZpbGw9IndoaXRlIi8%2BCjwvc3ZnPgo%3D&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%2FJellyPlayer%2Freleases%2Flatest">
|
<img alt="GitHub Release" src="https://img.shields.io/github/v/release/prayag17/Blink?sort=date&display_name=tag&style=for-the-badge&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODc4IiBoZWlnaHQ9IjEwMTIiIHZpZXdCb3g9IjAgMCA4NzggMTAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00MzguODA5IDUwNkwzNS40MDQ4IDczOC45MDZMNDM4LjgwOSA5NzEuODEyTDg0Mi4yMTQgNzM4LjkwNlYyNzMuMDk0TDQzOC44MDkgNDAuMTg4NUwzNS40MDQ4IDI3My4wOTRMNDM4LjgwOSA1MDZaTTQzOC44MDkgMEw4NzcuMDE4IDI1M1Y3NTlMNDM4LjgwOSAxMDEyTDAuNjAwNTg2IDc1OVY3MTguODEyVjI5My4xODhWMjUzTDQzOC44MDkgMFoiIGZpbGw9IndoaXRlIi8%2BCjwvc3ZnPgo%3D&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%Blink%2Freleases%2Flatest">
|
||||||
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/prayag17/JellyPlayer?style=for-the-badge&logo=github&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%2FJellyPlayer%2Fstargazers">
|
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/prayag17/Blink?style=for-the-badge&logo=github&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%Blink%2Fstargazers">
|
||||||
<img alt="GitHub License" src="https://img.shields.io/github/license/prayag17/JellyPlayer?style=for-the-badge&labelColor=000">
|
<img alt="GitHub License" src="https://img.shields.io/github/license/prayag17/Blink?style=for-the-badge&labelColor=000">
|
||||||
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/prayag17/JellyPlayer/continuous-integration.yml?style=for-the-badge&logo=github&label=CI&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%2FJellyPlayer%2Factions%2Fworkflows%2Fcontinuous-integration.yml">
|
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/prayag17/Blink/continuous-integration.yml?style=for-the-badge&logo=github&label=CI&labelColor=000&link=https%3A%2F%2Fgithub.com%2Fprayag17%Blink%2Factions%2Fworkflows%2Fcontinuous-integration.yml">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
###
|
###
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
## 📝 Prerequisites
|
## 📝 Prerequisites
|
||||||
|
|
||||||
- Nodejs (≥19.1.0)
|
- Nodejs (22.14.0)
|
||||||
- Rust (≥1.76.0)
|
- Rust (>=1.85.0)
|
||||||
- Visual Studio C++ Build tools
|
- Visual Studio C++ Build tools
|
||||||
- [pnpm](https://pnpm.io/)
|
- [pnpm](https://pnpm.io/)
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
pnpm run tauri build
|
pnpm run tauri build
|
||||||
```
|
```
|
||||||
|
|
||||||
- other commands can be found inside the `"scripts"` inside [package.json](https://github.com/prayag17/JellyPlayer/blob/main/package.json)
|
- other commands can be found inside the `"scripts"` inside [package.json](https://github.com/prayag17/Blink/blob/main/package.json)
|
||||||
|
|
||||||
## 💻 Contribution
|
## 💻 Contribution
|
||||||
|
|
||||||
@@ -64,17 +64,15 @@
|
|||||||
## 📷 Screenshots
|
## 📷 Screenshots
|
||||||
|
|
||||||
- Home
|
- Home
|
||||||

|

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

|

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

|

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

|

|
||||||
- Video Player
|
- Video Player
|
||||||

|

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

|
|
||||||
|
|
||||||
## 📃 Roadmap
|
## 📃 Roadmap
|
||||||
|
|
||||||
|
|||||||
+23
-14
@@ -1,19 +1,27 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
|
||||||
"organizeImports": {
|
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
"linter": {
|
"linter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
"recommended": true,
|
"recommended": true,
|
||||||
"style": {
|
"style": {
|
||||||
"noNonNullAssertion": "off",
|
"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": {
|
"a11y": {
|
||||||
"useKeyWithClickEvents": "off",
|
"useKeyWithClickEvents": "off",
|
||||||
"useMediaCaption": "off"
|
"useMediaCaption": "off",
|
||||||
|
"noStaticElementInteractions": "off"
|
||||||
},
|
},
|
||||||
"correctness": {
|
"correctness": {
|
||||||
"useExhaustiveDependencies": "off",
|
"useExhaustiveDependencies": "off",
|
||||||
@@ -21,17 +29,18 @@
|
|||||||
},
|
},
|
||||||
"suspicious": {
|
"suspicious": {
|
||||||
"noExplicitAny": "off"
|
"noExplicitAny": "off"
|
||||||
}
|
},
|
||||||
|
"nursery": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"include": [
|
"includes": [
|
||||||
"src/**/*.ts",
|
"**/src/**/*.ts",
|
||||||
"src/**/*.tsx",
|
"**/src/**/*.tsx",
|
||||||
"src/**/*.jsx",
|
"**/src/**/*.jsx",
|
||||||
"src/**/*.js",
|
"**/src/**/*.js",
|
||||||
"*.json",
|
"**/*.json",
|
||||||
"*.scss"
|
"**/*.scss"
|
||||||
],
|
],
|
||||||
"ignoreUnknown": true
|
"ignoreUnknown": true
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -4,8 +4,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<script src="http://localhost:8097"></script>
|
<!-- <script src="http://localhost:8097"></script> -->
|
||||||
<title>Jellyplayer</title>
|
<title>Blink</title>
|
||||||
<style>
|
<style>
|
||||||
.app-loading {
|
.app-loading {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|||||||
+9
-9
@@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"version": "0.0.6-dev",
|
"version": "0.0.7-dev",
|
||||||
"notes": "- feat: add video player slider bubble theming #337\n- feat: add trickplay support #338 #337\n- fix(ci): update env variables\n- fix(ci): fix ubuntu build failing\n- chore(deps): update js and rust deps\n- feat: add chapter markers #337\n- feat: add subtitle support #337\n- fix(ci): invalid tauri build command\n- fix(ci):workflow repo name\n- feat: remember last search query\n- feat: add new audioPlayer route and allow reordering queue\n- chore(deps): update deps\n- chore(deps): cleanup unused dependencies and update dependencies\n- refactor: replace wavesurfer with html audio player\n- feat: add new album page\n- fix: quick connect not working\n- chore: change tauri updater signing keys\n- feat: show upNext card for episode items in player\n- fix: login page not working\n- Merge pull request #332 from pypp/feat/double-click-fullscreen\n- Merge pull request #333 from pypp/feat/scrollwheel-volume-control\n- fix: removed subtitleRenderer state that was added while merging\n- fix: fixed bug caused by merge econflicts\n- Merge remote-tracking branch 'upstream/main' into feat/scrollwheel-volume-control\n- fix: fixed fucntion to use the new API\n- Merge remote-tracking branch 'upstream/main' into feat/double-click-fullscreen\n- Merge branch 'main' of https://github.com/pypp/JellyPlayer into feat/double-click-fullscreen\n- fix(deps): update dependency babel-plugin-react-compiler to v0.0.0\n- fix(deps): update tauri monorepo\n- chore(deps): update dependencies\n- feat: allow toggling subtitles on and off from player\n- fix: playNext and playPrevious logic\n- feat: add intro-skipper\n- refactor: cleanup unused variables in playbackStore\n- chore(deps): update packages\n- refactor: support vtt and ass subtitles\n- refactor: add sorting options to library page for Series and BoxSets\n- style: update hero-carousel styling\n- chore(deps): update deps\n- fix(deps): update dependency framer-motion to v11.2.9\n- refactor: move most routing logic to tanstack\n- refactor: implement new login logic and verify context.api status\n- chore(deps): update dependencies\n- refactor: move to tanstack router\n- fix: videoPlayer not restoring playback position when queueItem is updated\n- fix: Slight UI regression when changing servers on latest version #288\n- fix: eac3 codec support\n- refactor: queueItem playback\n- fix(deps): update rust crate tauri to 1.6.2 (#298)\n- fix: episode playback\n- feat: add queueButton\n- Merge branch 'main' of https://github.com/prayag17/JellyPlayer\n- chore(deps): fix vite 5.2 bundle\n- fix(deps): update dependency @types/react to v18.3.1 (#295)\n- fix: scrollTrigger in libraryView\n- style: improve styling\n- fix: backdrop flashing\n- feat: use tanstack virtual for rendering library items\n- style: improve login notice ui\n- refactor: fetch mediaSource for series\n- refactor: implement new playback method for playbutton (wip)\n- ui: improve glass texture\n- ui: implement new appBar #284\n- feat: display sdr and hdr only videoRange\n- style: improve hdr10 logo spacing\n- chore: update title-movie screenshot in README.md\n- chore: update title-movie.png\n- fix: hdr10 icon height not matching\n- style: update mediainfo icons\n- style: update mediainfo icons\n- fix: no subtitle option not selecting\n- feat: use brand logo for hdr10plus\n- fix: default subtitle not being selected properly\n- style: display backdrops in boxset\n- fix: videoPlayer not exiting if subtitles are disabled\n- chore: add kitsu icon to iconLink\n- fix: carousel not rendering\n- chore: update readme\n- chore: update screenshots\n- fix: improve hdr10+ detection\n- feat: add quality and audio brand labels\n- style: improve page-margin\n- fix(player): unable to play media without subtitles\n- fix: album not displaying if no parent backdrop is found\n- chore: add screenshots and some features of JellyPlayer #242\n- chore: upload screenshots\n- fix(nsis): nsis setup images not displaying correctly\n- style: Improve titlePage styling\n- style: change cardText styling\n- style: Improve overall app component paddings and margins and rollback vite to 5.1.6\n- chore(deps): update dependency vite to v5.2.6 (#286)\n- fix(deps): update material-ui monorepo (#270)\n- fix(deps): update dependency @types/node to v20.11.29 (#292)\n- fix(deps): update dependency @types/react to v18.2.67 (#293)\n- fix(deps): update tanstack-query monorepo to v5.28.6 (#271)\n- fix(deps): update dependency @types/react to v18.2.67 (#272)\n- fix(deps): update dependency @types/node to v20.11.29 (#274)\n- fix(deps): update dependency framer-motion to v11.0.15 (#278)\n- fix(deps): update dependency typescript to v5.4.3 (#287)\n- fix(deps): update dependency material-symbols to v0.17.1 (#289)\n- chore(deps): update dependency @biomejs/biome to v1.6.2 (#290)\n- fix(deps): update rust crate log to ^0.4.21 (#276)\n- chore: update latest.json",
|
"notes": "\n- chore(deps): update dependencies\n- refactor: change UI of login/list and fix Api not being defined in context\n- fix: player/audio route not able to interact with audioPlayer\n- fix: audio player info not visible\n- fix: audio player not playing audio\n- fix: toggling ssubtitles not working\n- fix: subtitles not being rendered #401\n- fix: hero carousel indicators not scrolling\n- fix: vite build error for safari13\n- fix: blink not launching or rendering on opening\n- Merge branch 'main' of https://github.com/prayag17/JellyPlayer\n- chore(deps): update dependencies\n- Merge pull request #410 from prayag17/renovate/tauri-plugin-notification-2.x-lockfile\n- Merge pull request #409 from Blackspirits/patch-1\n- chore(deps): update dependencies\n- fix(deps): update rust crate tauri-plugin-notification to v2.0.1\n- feat: allow downloading images from ImageViewer\n- Update index.tsx\n- feat: implement basic image viewer #338 #240\n- fix: react infinite depth error\n- fix: vite config\n- refactor: remove @million/js and @million/lint\n- refactor: remove Cargo.lock from .gitignore #400\n- chore(deps): update dependencies\n- refactor: code cleanup\n- fix: bug_report showing extra fields\n- refactor: remove redundant calls for getCurrentUser\n- feat: show queue item from currently playing item in queueButton\n- chore(deps): update dependencies\n- feat: remember library filters #192\n- Merge pull request #370 from prayag17/renovate/tauri-apps-plugin-clipboard-manager-2.x\n- fix(deps): update dependency @tauri-apps/plugin-clipboard-manager to v2.1.0-beta.6\n- Merge pull request #381 from prayag17/renovate/wavesurfer.js-7.x-lockfile\n- Merge pull request #342 from prayag17/renovate/tanstack-router-monorepo\n- Merge pull request #368 from prayag17/renovate/tauri-monorepo\n- chore(release): update latest.json",
|
||||||
"pub_date": "2024-09-06T20:40:35.324Z",
|
"pub_date": "2024-11-20T07:04:53.965Z",
|
||||||
"platforms": {
|
"platforms": {
|
||||||
"darwin-aarch64": {
|
"darwin-aarch64": {
|
||||||
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL1VsZ01leXRhMXFrek9ENWZCWHZPR3Y1Ky9SZ3BOc2hEeFlMU0pVR1gzL1NNdytOL1hGTzU5enpZNVRlY01JaDNjaTN3azdDMU9BcVVUWEg5RzdOY1FvPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzI1NjU0NzUzCWZpbGU6QmxpbmsuYXBwLnRhci5negphcUh0QXFNUnBEWUFGZGU3V0pzQXN5eXhzSmNOdzNoSDFLV3BlbHNGKzFvWXpJR0V4UmJoYTNNV0tZZ0VKcHdDbERxWFpEYk5kUVVxZWFnWnIrSThBUT09Cg==",
|
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL2RHaC9wc3VMQzJxeFRYaHVVN0xEZW91WWgwZkluYkYrdW5hUWl2UFlSeEUyRk93dm13WUdmQVZETWhmNW9MZ2lPUFdOdERzbGFibkpPNHJWMU1BYlFrPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzMyMDg1ODYyCWZpbGU6QmxpbmsuYXBwLnRhci5negpjK0VIaW9oVzlrUU92UWZudzcvRGlZNExwM0NOdmpHVGd1QUc2WWZ0bnRkU2NsWkdqQUJrR01ucVVRTktvR0RaV0l0L09KQ2luZHNUdjMvTGVlM2RCUT09Cg==",
|
||||||
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.6-dev/Blink_aarch64.app.tar.gz"
|
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.7-dev/Blink_aarch64.app.tar.gz"
|
||||||
},
|
},
|
||||||
"linux-x86_64": {
|
"linux-x86_64": {
|
||||||
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL1JtYjlPdWJ2WngrU21iV1ZSd3BCWjBSdDVxT0VGcSs5VFZ0YUs1eFlIbnNlUnN1VzJLOUg4K25sdVRWUzhkR0VJWDBIa081R01aUyt4S3VQZHlSQ3d3PQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzI1NjU1MTAxCWZpbGU6QmxpbmtfMC4wLjYtZGV2X2FtZDY0LkFwcEltYWdlLnRhci5nego4ZllLcnRyWW5FM0JRY0dZUkJocFdsNlRzdjdnY3dDUFpGSENNSVNwdkRMZStvZWZTSlFLL25IR1A3a2pzdTlBUjNveVJ5VDFqYkxJdWF5MWFFeWxDdz09Cg==",
|
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL1hKZGoxZFUvZzl5SmNnUEFRTGQ2TmFNMlphK25lTU9MTjJEM0JYQWt0Sy91Um9yRmk4QTl6dEtUSmRuRmFNODRwajJ2YW4rTGJzYVZjcmhFb1IxZkFnPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzMyMDg2MTQxCWZpbGU6QmxpbmtfMC4wLjctZGV2X2FtZDY0LkFwcEltYWdlCndKZURUdjF0bkNna1VCVDNEMFNodEZBZGkzZFBKVWx2cThSNE5najBmd2U5Rzh5SDFIbUxqRHlKOWdxMnY2QU9NdTRiQmtWY2VVaVlhNjRrNDVHMUFRPT0K",
|
||||||
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.6-dev/Blink_0.0.6-dev_amd64.AppImage.tar.gz"
|
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.7-dev/Blink_0.0.7-dev_amd64.AppImage"
|
||||||
},
|
},
|
||||||
"windows-x86_64": {
|
"windows-x86_64": {
|
||||||
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL2F4bGtQUmxDVjZadzRuNHk0RTd5RmRJbmVsOEwxaTV1U3FzZHAveEhiU0xmcGx2N0toaUR4alRiS2lmTTU0QStHc2JzT2diR1JjRm5VZU1SUWFuS0F3PQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzI1NjU1MjMyCWZpbGU6QmxpbmtfMC4wLjYtZGV2X3g2NC1zZXR1cC5uc2lzLnppcApPdk5zQ0NFcFQySXNjck8zTEM4SitwdTV6UXRKYnpPKzBJQnVJRDkxWjdqWGgwaXBSb1k0aGMvVEhwWWhBTEJzZHRhVy9KU0lCbjl2bG45WUJxOUlBZz09Cg==",
|
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSNkxEL1dFMElZL1MwRVJ0UXBUUEYvd01JbXhBalFwQ0w5bEdkZkdlblZNeW1EMXQxajhYeVd0cERWcnhWOWFOaXV4Q0hDU1VRTEhabXF1ekFIbzB0KzRmL0pxdEIzMEFrPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzMyMDg2Mjg5CWZpbGU6QmxpbmtfMC4wLjctZGV2X3g2NC1zZXR1cC5uc2lzLnppcApJMmRORUFhV3NKV3BCTTliQkIwcWtSZStKTzEwY002QndCWmxKb0ZRd2p2K0cvek90dmdsbmQ0MHhNOVJsWnE3Y29qQmNDckdxdUNabWpTWjJ3d0xBUT09Cg==",
|
||||||
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.6-dev/Blink_0.0.6-dev_x64-setup.nsis.zip"
|
"url": "https://github.com/prayag17/Blink/releases/download/v0.0.7-dev/Blink_0.0.7-dev_x64-setup.nsis.zip"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+68
-58
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "blink",
|
"name": "blink",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.7-dev",
|
"version": "1.0.0-alpha.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --force && tsr watch",
|
"dev": "vite --force && tsr watch",
|
||||||
@@ -13,73 +13,83 @@
|
|||||||
"tanstack-router-dev": "tsr watch"
|
"tanstack-router-dev": "tsr watch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.1.0",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/modifiers": "^7.0.0",
|
"@dnd-kit/modifiers": "^9.0.0",
|
||||||
"@dnd-kit/sortable": "^8.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.14.1",
|
||||||
"@fontsource-variable/jetbrains-mono": "^5.1.1",
|
"@fontsource-variable/jetbrains-mono": "^5.2.8",
|
||||||
"@fontsource-variable/noto-sans": "^5.1.0",
|
"@fontsource-variable/noto-sans": "^5.2.10",
|
||||||
"@jellyfin/sdk": "0.11.0",
|
"@fontsource-variable/plus-jakarta-sans": "^5.2.8",
|
||||||
"@million/lint": "^1.0.12",
|
"@fontsource-variable/space-grotesk": "^5.2.10",
|
||||||
"@mui/lab": "6.0.0-beta.15",
|
"@jellyfin/sdk": "0.13.0",
|
||||||
"@mui/material": "6.1.7",
|
"@mui/lab": "7.0.1-beta.20",
|
||||||
"@react-spring/web": "^9.7.5",
|
"@mui/material": "7.3.6",
|
||||||
"@tanem/react-nprogress": "^5.0.53",
|
"@popperjs/core": "^2.11.8",
|
||||||
"@tanstack/react-query": "^5.60.6",
|
"@react-spring/web": "^10.0.3",
|
||||||
"@tanstack/react-query-devtools": "^5.60.6",
|
"@tanem/react-nprogress": "^5.0.56",
|
||||||
"@tanstack/react-router": "^1.82.1",
|
"@tanstack/react-form": "^1.27.5",
|
||||||
"@tanstack/react-virtual": "^3.10.9",
|
"@tanstack/react-query": "^5.90.12",
|
||||||
"@tauri-apps/api": "2.1.1",
|
"@tanstack/react-query-devtools": "^5.91.1",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "2.1.0-beta.6",
|
"@tanstack/react-router": "^1.141.8",
|
||||||
"@tauri-apps/plugin-dialog": "2.0.1",
|
"@tanstack/react-router-devtools": "^1.141.8",
|
||||||
"@tauri-apps/plugin-notification": "2.0.0",
|
"@tanstack/react-virtual": "^3.13.13",
|
||||||
"@tauri-apps/plugin-process": "2.0.0",
|
"@tauri-apps/api": "2.9.1",
|
||||||
|
"@tauri-apps/plugin-clipboard-manager": "2.3.2",
|
||||||
|
"@tauri-apps/plugin-dialog": "2.4.2",
|
||||||
|
"@tauri-apps/plugin-notification": "2.3.3",
|
||||||
|
"@tauri-apps/plugin-process": "2.3.1",
|
||||||
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
||||||
"@tauri-apps/plugin-updater": "2.0.0",
|
"@tauri-apps/plugin-updater": "2.9.0",
|
||||||
"@tauri-apps/plugin-upload": "2.1.0",
|
"@tauri-apps/plugin-upload": "2.3.2",
|
||||||
"@types/node": "^22.9.1",
|
"@tauri-apps/plugin-window-state": "~2.4.1",
|
||||||
"@types/react": "^18.3.12",
|
"@types/node": "^25.0.3",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/react": "^19.2.7",
|
||||||
"axios": "^1.7.7",
|
"@types/react-dom": "^19.2.3",
|
||||||
"axios-tauri-api-adapter": "^2.0.3",
|
"axios": "^1.13.2",
|
||||||
|
"axios-tauri-api-adapter": "^2.0.6",
|
||||||
"blurhash": "^2.0.5",
|
"blurhash": "^2.0.5",
|
||||||
"framer-motion": "^11.11.17",
|
"blurhash-wasm": "^0.2.0",
|
||||||
"immer": "^10.1.1",
|
"immer": "^11.1.0",
|
||||||
"jassub": "^1.7.17",
|
"jassub": "^1.8.6",
|
||||||
|
"libpgs": "^0.8.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"material-symbols": "^0.27.0",
|
"material-symbols": "^0.40.2",
|
||||||
"million": "^3.1.11",
|
"motion": "^12.23.26",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.2",
|
||||||
"react": "18.3.1",
|
"react": "^19.2.3",
|
||||||
"react-blurhash": "^0.3.0",
|
"react-blurhash": "^0.3.0",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
"react-dom": "18.3.1",
|
"react-dom": "^19.2.3",
|
||||||
"react-error-boundary": "^4.1.2",
|
"react-error-boundary": "^6.0.0",
|
||||||
"react-markdown": "^9.0.1",
|
"react-intersection-observer": "^10.0.0",
|
||||||
"react-multi-carousel": "^2.8.5",
|
"react-markdown": "^10.1.0",
|
||||||
"react-player": "^2.16.0",
|
"react-multi-carousel": "^2.8.6",
|
||||||
"react-use-konami": "^1.1.0",
|
"react-player": "^3.4.0",
|
||||||
"remark-gfm": "^4.0.0",
|
"remark-gfm": "^4.0.1",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.9.3",
|
||||||
"vite-plugin-svgr": "^4.3.0",
|
"vite-plugin-svgr": "^4.5.0",
|
||||||
"wavesurfer.js": "^7.8.8",
|
"wavesurfer.js": "^7.12.1",
|
||||||
"zustand": "5.0.1"
|
"zod": "^4.2.1",
|
||||||
|
"zustand": "5.0.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-proposal-optional-chaining-assign": "^7.25.9",
|
"@babel/plugin-proposal-optional-chaining-assign": "^7.27.1",
|
||||||
"@biomejs/biome": "^1.9.4",
|
"@biomejs/biome": "^2.3.10",
|
||||||
"@tanstack/router-cli": "^1.81.9",
|
"@tanstack/router-cli": "^1.142.0",
|
||||||
"@tanstack/router-devtools": "^1.82.1",
|
"@tanstack/router-devtools": "^1.141.8",
|
||||||
"@tanstack/router-vite-plugin": "^1.81.9",
|
"@tanstack/router-vite-plugin": "^1.142.0",
|
||||||
"@tauri-apps/cli": "2.1.0",
|
"@tauri-apps/cli": "2.9.6",
|
||||||
"@types/lodash": "^4.17.13",
|
"@types/lodash": "^4.17.21",
|
||||||
"@vitejs/plugin-react": "^4.3.3",
|
"@vitejs/plugin-react": "^5.1.2",
|
||||||
|
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
||||||
|
"eslint-plugin-react-hooks": "7.0.1",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"sass": "^1.81.0",
|
"sass": "^1.97.1",
|
||||||
"vite": "^5.4.11"
|
"vite": "^7.3.0",
|
||||||
|
"vite-plugin-wasm": "^3.5.0"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0-only"
|
"license": "GPL-3.0-only"
|
||||||
}
|
}
|
||||||
Generated
+2985
-2924
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,4 @@
|
|||||||
|
onlyBuiltDependencies:
|
||||||
|
- '@parcel/watcher'
|
||||||
|
- core-js
|
||||||
|
- esbuild
|
||||||
Generated
+1708
-1601
File diff suppressed because it is too large.
Load diff
@@ -1,10 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "blink"
|
name = "blink"
|
||||||
version = "0.0.7-dev"
|
version = "1.0.0-alpha.3"
|
||||||
description = "A Modern Jellyfin Client"
|
description = "A Modern Jellyfin Client"
|
||||||
authors = ["prayag17", "JellyPlayer contributors (https://github.com/prayag17/JellyPlayer/graphs/contributors)"]
|
authors = ["prayag17", "Blink contributors (https://github.com/prayag17/Blink/graphs/contributors)"]
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
repository = "https://github.com/prayag17/JellyPlayer/"
|
repository = "https://github.com/prayag17/Blink/"
|
||||||
default-run = "blink"
|
default-run = "blink"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.59"
|
rust-version = "1.59"
|
||||||
@@ -22,7 +22,6 @@ tauri = { version = "2.0.0-beta", features = [ "devtools"] }
|
|||||||
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
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-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-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
|
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-process = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
@@ -38,3 +37,6 @@ default = [ "custom-protocol" ]
|
|||||||
# this feature is used for production builds where `devPath` points to the filesystem
|
# this feature is used for production builds where `devPath` points to the filesystem
|
||||||
# DO NOT remove this
|
# DO NOT remove this
|
||||||
custom-protocol = [ "tauri/custom-protocol" ]
|
custom-protocol = [ "tauri/custom-protocol" ]
|
||||||
|
|
||||||
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||||
|
tauri-plugin-window-state = "2"
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"identifier": "desktop-capability",
|
||||||
|
"platforms": [
|
||||||
|
"macOS",
|
||||||
|
"windows",
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"windows": [
|
||||||
|
"main"
|
||||||
|
],
|
||||||
|
"permissions": [
|
||||||
|
"window-state:default"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
"notification:default",
|
"notification:default",
|
||||||
"core:webview:allow-internal-toggle-devtools",
|
"core:webview:allow-internal-toggle-devtools",
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
"upload:allow-download"
|
"upload:allow-download",
|
||||||
|
"clipboard-manager:allow-write-text"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -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"]},"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"],"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","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"]}}
|
||||||
+2344
-1741
File diff suppressed because it is too large.
Load diff
+2344
-1741
File diff suppressed because it is too large.
Load diff
@@ -4,6 +4,7 @@ use tauri_plugin_log::{fern::colors::ColoredLevelConfig, Target, TargetKind};
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_window_state::Builder::new().build())
|
||||||
.plugin(tauri_plugin_dialog::init())
|
.plugin(tauri_plugin_dialog::init())
|
||||||
.plugin(tauri_plugin_upload::init())
|
.plugin(tauri_plugin_upload::init())
|
||||||
.plugin(tauri_plugin_notification::init())
|
.plugin(tauri_plugin_notification::init())
|
||||||
@@ -18,5 +19,5 @@ fn main() {
|
|||||||
.plugin(tauri_plugin_updater::Builder::default().build())
|
.plugin(tauri_plugin_updater::Builder::default().build())
|
||||||
// .plugin(tauri_plugin_window_state::Builder::default().build())
|
// .plugin(tauri_plugin_window_state::Builder::default().build())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running JellyPlayer");
|
.expect("error while running Blink");
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
|
||||||
"build": {
|
"build": {
|
||||||
"beforeBuildCommand": "pnpm run build",
|
"beforeBuildCommand": "pnpm run build",
|
||||||
"beforeDevCommand": "pnpm run dev",
|
"beforeDevCommand": "pnpm run dev",
|
||||||
@@ -56,10 +55,13 @@
|
|||||||
"identifier": "com.blink.prayag17",
|
"identifier": "com.blink.prayag17",
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"updater": {
|
"updater": {
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZEMTg0MjEzRDYzRjJDN0EKUldSNkxEL1dFMElZL1dxbHA0V2lyVDFEdGpOZXkxMG9XdHVLVnRpVVV5c1Z0OFNRUE45dkpxbFAK",
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEZBOTJGNzM3REU2Q0JEMEYKUldRUHZXemVOL2VTK2k2andMWTZYbEN6SnIwV0V0L2Z3NlA4RzFabThPaXRqSFRMc004WGhCb2kK",
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
"https://rawcdn.githack.com/prayag17/Blink/refs/heads/main/latest.json"
|
"https://rawcdn.githack.com/prayag17/Blink/refs/heads/main/latest.json"
|
||||||
]
|
],
|
||||||
|
"windows": {
|
||||||
|
"installMode": "passive"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
@@ -74,7 +76,8 @@
|
|||||||
"center": true,
|
"center": true,
|
||||||
"label": "main",
|
"label": "main",
|
||||||
"dragDropEnabled": false,
|
"dragDropEnabled": false,
|
||||||
"backgroundColor": "#08001f"
|
"backgroundColor": "#08001f",
|
||||||
|
"transparent": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB |
@@ -0,0 +1,135 @@
|
|||||||
|
import { setServer } from "@/utils/storage/servers";
|
||||||
|
import { jellyfin } from "@/utils/store/api";
|
||||||
|
import { LoadingButton } from "@mui/lab";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogTitle,
|
||||||
|
TextField,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
import { enqueueSnackbar } from "notistack";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
|
||||||
|
type AddServerDialogProps = {
|
||||||
|
open: boolean;
|
||||||
|
setAddServerDialog: (value: boolean) => void;
|
||||||
|
sideEffect?: () => Promise<unknown>;
|
||||||
|
hideBackdrop?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function AddServerDialog(props: AddServerDialogProps) {
|
||||||
|
const { open, setAddServerDialog, sideEffect, hideBackdrop } = props;
|
||||||
|
|
||||||
|
const [serverIp, setServerIp] = useState("");
|
||||||
|
const addServer = useMutation({
|
||||||
|
mutationKey: ["add-server"],
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (sideEffect) {
|
||||||
|
await sideEffect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={open}
|
||||||
|
hideBackdrop={Boolean(hideBackdrop)}
|
||||||
|
fullWidth
|
||||||
|
maxWidth="sm"
|
||||||
|
disableScrollLock={true}
|
||||||
|
>
|
||||||
|
<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)}
|
||||||
|
>
|
||||||
|
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
.item-info-track{
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 3em 60% 6em 1fr;
|
||||||
|
gap: 1em;
|
||||||
|
padding: 1em;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: $border-radius-default;
|
||||||
|
transition: background $transition-time-fast;
|
||||||
|
&.header {
|
||||||
|
border-bottom: 1px solid rgb(255 255 255 / 0.2);
|
||||||
|
color: rgb(255 255 255 / 0.7);
|
||||||
|
border-radius: 0 !important;
|
||||||
|
}
|
||||||
|
.index-container {
|
||||||
|
justify-self: center;
|
||||||
|
position: relative;
|
||||||
|
.material-symbols-rounded {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
font-size: 2em !important;
|
||||||
|
opacity: 0;
|
||||||
|
transition: none !important;
|
||||||
|
color: $clr-accent-default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.1em
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
background: rgb(255 255 255 / 0.1) !important;
|
||||||
|
.index-container {
|
||||||
|
// font-size: 0em;
|
||||||
|
.index {
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0;
|
||||||
|
}
|
||||||
|
.material-symbols-rounded {
|
||||||
|
opacity: 1;
|
||||||
|
font-size: 2.2em !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.playing {
|
||||||
|
background: rgb(0 0 0 / 0.4) !important;
|
||||||
|
.item-info-track-info-name, .index {
|
||||||
|
color: $clr-accent-default;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.4em
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
import {
|
||||||
|
generateAudioStreamUrl,
|
||||||
|
playAudio,
|
||||||
|
useAudioPlayback,
|
||||||
|
} from "@/utils/store/audioPlayback";
|
||||||
|
import type {
|
||||||
|
BaseItemDto,
|
||||||
|
BaseItemDtoQueryResult,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { Typography } from "@mui/material";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import { getRuntimeMusic } from "@/utils/date/time";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import { setQueue } from "@/utils/store/queue";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
||||||
|
import LikeButton from "../buttons/likeButton";
|
||||||
|
|
||||||
|
import "./albumMusicTrack.scss";
|
||||||
|
|
||||||
|
type AlbumMusicTrackProps = {
|
||||||
|
track: BaseItemDto;
|
||||||
|
/**
|
||||||
|
* This is the index of the track in the musicTracks array (not to be confused with IndexNumber property of the track)
|
||||||
|
*/
|
||||||
|
trackIndex: number;
|
||||||
|
musicTracks: BaseItemDtoQueryResult | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
||||||
|
const { track, musicTracks, trackIndex } = props;
|
||||||
|
const [currentPlayingItem] = useAudioPlayback((state) => [state.item]);
|
||||||
|
|
||||||
|
const user = useCentralStore((state) => state.currentUser);
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
|
const handlePlayback = (
|
||||||
|
index: number,
|
||||||
|
item: BaseItemDto,
|
||||||
|
queue: BaseItemDto[],
|
||||||
|
) => {
|
||||||
|
if (!user?.Id || !api) {
|
||||||
|
console.error("User not logged in");
|
||||||
|
enqueueSnackbar("You need to be logged in to play music", {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (item.Id) {
|
||||||
|
const url = generateAudioStreamUrl(
|
||||||
|
item.Id,
|
||||||
|
user.Id,
|
||||||
|
api.deviceInfo.id,
|
||||||
|
api.basePath,
|
||||||
|
api.accessToken,
|
||||||
|
);
|
||||||
|
playAudio(url, item);
|
||||||
|
setQueue(queue, index);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={
|
||||||
|
currentPlayingItem?.Id === track.Id
|
||||||
|
? "item-info-track playing"
|
||||||
|
: "item-info-track"
|
||||||
|
}
|
||||||
|
key={track.Id}
|
||||||
|
onClick={() => {
|
||||||
|
if (musicTracks?.Items) {
|
||||||
|
handlePlayback(trackIndex, track, musicTracks.Items);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="index-container">
|
||||||
|
<span className="material-symbols-rounded fill ">play_arrow</span>
|
||||||
|
<Typography className="index">{track.IndexNumber ?? "-"}</Typography>
|
||||||
|
</div>
|
||||||
|
<div className="item-info-track-info">
|
||||||
|
<Typography className="item-info-track-info-name">
|
||||||
|
{track.Name}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
style={{
|
||||||
|
opacity: 0.6,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "0.6em",
|
||||||
|
}}
|
||||||
|
fontWeight={300}
|
||||||
|
>
|
||||||
|
{track.HasLyrics && <img src={lyricsIcon} alt="lyrics" />}
|
||||||
|
{track.Artists?.join(", ")}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<Typography>{getRuntimeMusic(track.RunTimeTicks ?? 0)}</Typography>
|
||||||
|
<div className="flex flex-align-center">
|
||||||
|
<LikeButton
|
||||||
|
itemId={track.Id}
|
||||||
|
isFavorite={track.UserData?.IsFavorite}
|
||||||
|
queryKey={["item", "musicTracks"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={track.Name}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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 {
|
.appBar {
|
||||||
transition: background-color $transition-time-fast,
|
// Limit transitions to cheaper properties; avoid animating box-shadow directly
|
||||||
backdrop-filter $transition-time-fast,
|
transition: background-color $transition-time-fast;
|
||||||
box-shadow $transition-time-default !important;
|
|
||||||
padding: 0.8em ($page-margin - 1.7em);
|
padding: 0.8em ($page-margin - 1.7em);
|
||||||
z-index: 999 !important;
|
z-index: 999 !important;
|
||||||
.flex {
|
.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;
|
border-radius: 1000px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
// Pseudo-element handles elevation shadow; we animate its opacity
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
backdrop-filter: blur(40px);
|
||||||
|
inset: -0.35em;
|
||||||
|
pointer-events: none;
|
||||||
|
border-radius: inherit;
|
||||||
|
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
||||||
|
background: rgb(0 0 0 / 0.4);
|
||||||
|
opacity: 0;
|
||||||
|
z-index: -1;
|
||||||
|
transition: opacity $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{
|
&.elevated{
|
||||||
.flex {
|
.flex {
|
||||||
padding: 0.5em;
|
&::after {
|
||||||
background: rgb(0 0 0 / 0.4);
|
opacity: 1;
|
||||||
backdrop-filter: blur(40px);
|
}
|
||||||
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
}
|
||||||
|
|
||||||
|
// Apply a subtle scale to simulate shrink without layout changes
|
||||||
|
.flex-inner {
|
||||||
|
transform: scaleY(0.95);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&-avatar {
|
&-avatar {
|
||||||
|
|||||||
@@ -1,95 +1,65 @@
|
|||||||
import React, { 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 { Link, useLocation, useNavigate } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||||
|
import MuiAppBar from "@mui/material/AppBar";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||||
|
import React, { useCallback, useMemo, useState } from "react";
|
||||||
|
|
||||||
import { delUser } from "@/utils/storage/user";
|
|
||||||
import "./appBar.scss";
|
import "./appBar.scss";
|
||||||
|
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { Divider, Drawer, List, ListItem, ListItemButton } from "@mui/material";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
|
// removed search placeholder; library state now managed via zustand
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import useHeaderStore from "@/utils/store/header";
|
||||||
import {
|
import {
|
||||||
setSettingsDialogOpen,
|
setSettingsDialogOpen,
|
||||||
setSettingsTabValue,
|
setSettingsTabValue,
|
||||||
} from "@/utils/store/settings";
|
} from "@/utils/store/settings";
|
||||||
import {
|
|
||||||
Divider,
|
|
||||||
Drawer,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
ListItemButton,
|
|
||||||
ListItemText,
|
|
||||||
} from "@mui/material";
|
|
||||||
import BackButton from "../buttons/backButton";
|
import BackButton from "../buttons/backButton";
|
||||||
|
import ListItemLink from "../listItemLink";
|
||||||
interface ListItemLinkProps {
|
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||||
icon?: ReactNode;
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const MemoizeBackButton = React.memo(BackButton);
|
const MemoizeBackButton = React.memo(BackButton);
|
||||||
|
|
||||||
|
const HIDDEN_PATHS = [
|
||||||
|
"/login",
|
||||||
|
"/setup",
|
||||||
|
"/server",
|
||||||
|
"/player",
|
||||||
|
"/error",
|
||||||
|
"/settings",
|
||||||
|
"/library",
|
||||||
|
];
|
||||||
|
|
||||||
export const AppBar = () => {
|
export const AppBar = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [display, setDisplay] = useState(false);
|
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const display = !HIDDEN_PATHS.some(
|
||||||
|
(path) => location.pathname.startsWith(path) || location.pathname === "/",
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
const [user] = useCentralStore((s) => [s.currentUser]);
|
||||||
const libraries = useQuery({
|
const libraries = useQuery({
|
||||||
queryKey: ["libraries"],
|
queryKey: ["libraries"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!user?.Id || !api?.accessToken) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const libs = await getUserViewsApi(api).getUserViews({
|
const libs = await getUserViewsApi(api).getUserViews({
|
||||||
userId: user?.Id,
|
userId: user.Id,
|
||||||
});
|
});
|
||||||
return libs.data;
|
return libs.data;
|
||||||
},
|
},
|
||||||
enabled: !!user?.Id && !!api.accessToken,
|
enabled: !!user?.Id && !!api?.accessToken,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,41 +68,6 @@ export const AppBar = () => {
|
|||||||
threshold: 20,
|
threshold: 20,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
|
||||||
const openMenu = Boolean(anchorEl);
|
|
||||||
const handleMenuOpen = useCallback((event) => {
|
|
||||||
setAnchorEl(event.currentTarget);
|
|
||||||
}, []);
|
|
||||||
const handleMenuClose = useCallback(() => {
|
|
||||||
setAnchorEl(null);
|
|
||||||
}, []);
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
const handleLogout = async () => {
|
|
||||||
console.log("Logging out user...");
|
|
||||||
await api.logout();
|
|
||||||
delUser();
|
|
||||||
sessionStorage.removeItem("accessToken");
|
|
||||||
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 [showDrawer, setShowDrawer] = useState(false);
|
||||||
|
|
||||||
const appBarStyling = useMemo(() => {
|
const appBarStyling = useMemo(() => {
|
||||||
@@ -141,9 +76,6 @@ export const AppBar = () => {
|
|||||||
paddingRight: "0 !important",
|
paddingRight: "0 !important",
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
const menuStyle = useMemo(() => {
|
|
||||||
return { mt: 2 };
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const drawerPaperProps = useMemo(() => {
|
const drawerPaperProps = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
@@ -170,10 +102,10 @@ export const AppBar = () => {
|
|||||||
navigate({ to: "/favorite" });
|
navigate({ to: "/favorite" });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const menuButtonSx = useMemo(() => ({ p: 0 }), []);
|
useHeaderStore(useShallow((s) => ({ pageTitle: s.pageTitle })));
|
||||||
|
|
||||||
if (!display) {
|
if (!display) {
|
||||||
return <></>;
|
return null;
|
||||||
}
|
}
|
||||||
if (display) {
|
if (display) {
|
||||||
return (
|
return (
|
||||||
@@ -213,75 +145,12 @@ export const AppBar = () => {
|
|||||||
<IconButton onClick={handleNavigateToFavorite}>
|
<IconButton onClick={handleNavigateToFavorite}>
|
||||||
<div className="material-symbols-rounded">favorite</div>
|
<div className="material-symbols-rounded">favorite</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton sx={menuButtonSx} onClick={handleMenuOpen}>
|
<UserAvatarMenu />
|
||||||
{!!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>
|
|
||||||
</div>
|
</div>
|
||||||
</MuiAppBar>
|
</MuiAppBar>
|
||||||
<Drawer
|
<Drawer
|
||||||
open={showDrawer}
|
open={showDrawer}
|
||||||
PaperProps={drawerPaperProps}
|
slotProps={{ paper: drawerPaperProps }}
|
||||||
className="library-drawer"
|
className="library-drawer"
|
||||||
onClose={handleDrawerClose}
|
onClose={handleDrawerClose}
|
||||||
>
|
>
|
||||||
@@ -301,12 +170,19 @@ export const AppBar = () => {
|
|||||||
</List>
|
</List>
|
||||||
<Divider variant="middle" />
|
<Divider variant="middle" />
|
||||||
<List>
|
<List>
|
||||||
<ListItemLink to="/home" icon="home" primary="Home" />
|
|
||||||
{libraries.isSuccess &&
|
|
||||||
libraries.data.Items?.map((library) => (
|
|
||||||
<ListItemLink
|
<ListItemLink
|
||||||
|
className="library-drawer-item"
|
||||||
|
to="/home"
|
||||||
|
icon="home"
|
||||||
|
primary="Home"
|
||||||
|
/>
|
||||||
|
{libraries.isSuccess &&
|
||||||
|
libraries.data?.Items?.map((library) => (
|
||||||
|
<ListItemLink
|
||||||
|
className="library-drawer-item"
|
||||||
key={library.Id}
|
key={library.Id}
|
||||||
to={`/library/${library.Id}`}
|
to="/library/$id"
|
||||||
|
params={{ id: library.Id ?? "" }}
|
||||||
icon={
|
icon={
|
||||||
library.CollectionType &&
|
library.CollectionType &&
|
||||||
getTypeIcon(library.CollectionType)
|
getTypeIcon(library.CollectionType)
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
import AppBar from "@mui/material/AppBar";
|
import AppBar from "@mui/material/AppBar";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Toolbar from "@mui/material/Toolbar";
|
import Toolbar from "@mui/material/Toolbar";
|
||||||
import { useRouter } from "@tanstack/react-router";
|
import { useLocation, useRouter } from "@tanstack/react-router";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import QuickConnectButton from "../buttons/quickConnectButton";
|
import QuickConnectButton from "../buttons/quickConnectButton";
|
||||||
|
|
||||||
export const AppBarBackOnly = () => {
|
export default function AppBarBackOnly() {
|
||||||
const { history } = useRouter();
|
const { history } = useRouter();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
history.go(-1);
|
history.go(-1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hideQuickConnect = location.pathname === "/setup/server/list";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppBar elevation={0} color="transparent" position="fixed">
|
<AppBar elevation={0} color="transparent" position="fixed">
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
@@ -27,6 +30,7 @@ export const AppBarBackOnly = () => {
|
|||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">arrow_back</span>
|
<span className="material-symbols-rounded">arrow_back</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
{!hideQuickConnect && (
|
||||||
<QuickConnectButton
|
<QuickConnectButton
|
||||||
sx={{
|
sx={{
|
||||||
marginLeft: "auto",
|
marginLeft: "auto",
|
||||||
@@ -35,6 +39,7 @@ export const AppBarBackOnly = () => {
|
|||||||
}}
|
}}
|
||||||
color="secondary"
|
color="secondary"
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import PropTypes from "prop-types";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
|
|
||||||
import "./avatar.module.scss";
|
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
export const AvatarImage = ({ userId }) => {
|
|
||||||
const api = useRouteContext({ from: "/_api" }).api;
|
|
||||||
return (
|
|
||||||
<Box className="avatar-image-container">
|
|
||||||
<div
|
|
||||||
className="avatar-image"
|
|
||||||
style={{
|
|
||||||
backgroundImage: `url('${api.basePath}/Users/${userId}/Images/Primary')`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="avatar-image-icon-container">
|
|
||||||
<span className="material-symbols-rounded avatar-image-icon">
|
|
||||||
account_circle
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
AvatarImage.propType = {
|
|
||||||
userId: PropTypes.string.isRequired,
|
|
||||||
userImageTags: PropTypes.any,
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import "./avatar.module.scss";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
|
||||||
|
export const AvatarImage = ({ userId }: { userId: string }) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
if (!api) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="avatar-image-container">
|
||||||
|
<div
|
||||||
|
className="avatar-image"
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url('${api.basePath}/Users/${userId}/Images/Primary')`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="avatar-image-icon-container">
|
||||||
|
<span className="material-symbols-rounded avatar-image-icon">
|
||||||
|
account_circle
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
|
import React from "react";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
import BlurhashCanvas from "../blurhash-canvas";
|
||||||
|
|
||||||
|
export default function Backdrop() {
|
||||||
|
// const [backdropLoading, setBackdropLoading] = useState(true);
|
||||||
|
|
||||||
|
const { backdropHash } = useBackdropStore(
|
||||||
|
useShallow((state) => ({
|
||||||
|
backdropHash: state.backdropHash,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!backdropHash) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<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)",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</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;
|
||||||
@@ -9,7 +9,7 @@ export default function BackButton() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton onClick={handleClick}>
|
<IconButton onClick={handleClick} disabled={history.length === 0}>
|
||||||
<span className="material-symbols-rounded">arrow_back</span>
|
<span className="material-symbols-rounded">arrow_back</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,50 +1,57 @@
|
|||||||
import PropTypes from "prop-types";
|
import React from "react";
|
||||||
|
|
||||||
import React, { useEffect } from "react";
|
|
||||||
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
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 { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
|
||||||
import { pink } from "@mui/material/colors";
|
import { pink } from "@mui/material/colors";
|
||||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => {
|
export default function LikeButton({
|
||||||
|
itemId,
|
||||||
|
isFavorite,
|
||||||
|
queryKey,
|
||||||
|
userId,
|
||||||
|
itemName,
|
||||||
|
}: {
|
||||||
|
itemId: string | undefined;
|
||||||
|
isFavorite: boolean | undefined;
|
||||||
|
queryKey: string[] | undefined;
|
||||||
|
userId: string | undefined;
|
||||||
|
itemName?: string | null;
|
||||||
|
}) {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
const handleLiking = async () => {
|
const handleLiking = async () => {
|
||||||
let result = null;
|
let result: UserItemDataDto = null!;
|
||||||
|
if (!api) return;
|
||||||
|
if (!userId) return;
|
||||||
|
if (!itemId) return;
|
||||||
|
if (!itemName) return;
|
||||||
if (isFavorite) {
|
if (isFavorite) {
|
||||||
result = await getUserLibraryApi(api).unmarkFavoriteItem({
|
result = (
|
||||||
|
await getUserLibraryApi(api).unmarkFavoriteItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
});
|
})
|
||||||
|
).data;
|
||||||
} else if (!isFavorite) {
|
} else if (!isFavorite) {
|
||||||
result = await getUserLibraryApi(api).markFavoriteItem({
|
result = (
|
||||||
|
await getUserLibraryApi(api).markFavoriteItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
});
|
})
|
||||||
|
).data;
|
||||||
}
|
}
|
||||||
return result.data;
|
return result; // We need to return the result so that the onSettled function can invalidate the query
|
||||||
};
|
};
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
// mutationFn: async () => {
|
|
||||||
// new Promise((resolve, reject) => {
|
|
||||||
// setTimeout(() => {
|
|
||||||
// resolve("foo");
|
|
||||||
// }, 4000);
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
mutationFn: handleLiking,
|
mutationFn: handleLiking,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar(`${error}`, {
|
|
||||||
variant: "error",
|
|
||||||
});
|
|
||||||
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
enqueueSnackbar(`An error occured while updating "${itemName}"`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
@@ -76,10 +83,12 @@ const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => {
|
|||||||
style={
|
style={
|
||||||
isFavorite
|
isFavorite
|
||||||
? {
|
? {
|
||||||
|
//@ts-ignore
|
||||||
"--fill": mutation.isPending ? 0 : 1,
|
"--fill": mutation.isPending ? 0 : 1,
|
||||||
color: mutation.isPending ? "white" : pink.A700,
|
color: mutation.isPending ? "white" : pink.A700,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
|
//@ts-ignore
|
||||||
"--fill": mutation.isPending ? 1 : 0,
|
"--fill": mutation.isPending ? 1 : 0,
|
||||||
color: mutation.isPending ? pink.A700 : "white",
|
color: mutation.isPending ? pink.A700 : "white",
|
||||||
}
|
}
|
||||||
@@ -89,14 +98,4 @@ const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => {
|
|||||||
</div>
|
</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
LikeButton.propTypes = {
|
|
||||||
itemId: PropTypes.string.isRequired,
|
|
||||||
isFavorite: PropTypes.bool.isRequired,
|
|
||||||
queryKey: PropTypes.any.isRequired,
|
|
||||||
userId: PropTypes.string.isRequired,
|
|
||||||
itemName: PropTypes.string,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default LikeButton;
|
|
||||||
+22
-17
@@ -1,8 +1,5 @@
|
|||||||
import PropTypes from "prop-types";
|
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
|
||||||
import { green } from "@mui/material/colors";
|
import { green } from "@mui/material/colors";
|
||||||
@@ -10,10 +7,21 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
export default function MarkPlayedButton({
|
||||||
|
itemId,
|
||||||
|
isPlayed,
|
||||||
|
queryKey,
|
||||||
|
userId,
|
||||||
|
itemName,
|
||||||
|
}: {
|
||||||
|
itemId?: string;
|
||||||
|
isPlayed?: boolean;
|
||||||
|
queryKey?: string[];
|
||||||
|
userId?: string;
|
||||||
|
itemName?: string | null;
|
||||||
|
}) {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@@ -21,6 +29,12 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
|||||||
|
|
||||||
const handleMarking = async () => {
|
const handleMarking = async () => {
|
||||||
let result = null;
|
let result = null;
|
||||||
|
if (!api) return;
|
||||||
|
if (!api) return;
|
||||||
|
if (!userId) return;
|
||||||
|
if (!itemId) return;
|
||||||
|
if (!itemName) return;
|
||||||
|
|
||||||
if (!isPlayed) {
|
if (!isPlayed) {
|
||||||
result = await getPlaystateApi(api).markPlayedItem({
|
result = await getPlaystateApi(api).markPlayedItem({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
@@ -32,11 +46,11 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
|||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result; // We need to return the result so that the onSettled function can invalidate the query
|
||||||
};
|
};
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: handleMarking,
|
mutationFn: handleMarking,
|
||||||
onError: (error, a, context) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar(`${error}`, {
|
enqueueSnackbar(`${error}`, {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
@@ -81,13 +95,4 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
|||||||
</div>
|
</div>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
MarkPlayedButton.propTypes = {
|
|
||||||
itemId: PropTypes.string.isRequired,
|
|
||||||
isPlayed: PropTypes.bool.isRequired,
|
|
||||||
queryKey: PropTypes.any.isRequired,
|
|
||||||
userId: PropTypes.string.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MarkPlayedButton;
|
|
||||||
@@ -1,66 +1,33 @@
|
|||||||
import PropTypes from "prop-types";
|
import {
|
||||||
import React, { memo } from "react"; // Import memo
|
type BaseItemDto,
|
||||||
|
BaseItemKind,
|
||||||
import Button, {
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
type ButtonProps,
|
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||||
type ButtonPropsSizeOverrides,
|
import type { SxProps } from "@mui/material";
|
||||||
} from "@mui/material/Button";
|
import Button, { type ButtonProps } from "@mui/material/Button";
|
||||||
import Fab from "@mui/material/Fab";
|
import Fab from "@mui/material/Fab";
|
||||||
import LinearProgress from "@mui/material/LinearProgress";
|
import LinearProgress from "@mui/material/LinearProgress";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import {
|
|
||||||
type BaseItemDto,
|
|
||||||
type BaseItemDtoQueryResult,
|
|
||||||
BaseItemKind,
|
|
||||||
ItemFields,
|
|
||||||
ItemFilter,
|
|
||||||
LocationType,
|
|
||||||
MediaProtocol,
|
|
||||||
type PlaybackInfoResponse,
|
|
||||||
SortOrder,
|
|
||||||
type UserItemDataDto,
|
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getDlnaApi } from "@jellyfin/sdk/lib/utils/api/dlna-api";
|
|
||||||
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 } from "@tanstack/react-query";
|
|
||||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
import React, { type MouseEvent, memo } from "react"; // Import memo
|
||||||
import useQueue, { setQueue } from "@/utils/store/queue";
|
|
||||||
|
|
||||||
import { playItem, usePlaybackDataLoadStore } from "@/utils/store/playback";
|
|
||||||
|
|
||||||
import type PlayResult from "@//utils/types/playResult";
|
import type PlayResult from "@//utils/types/playResult";
|
||||||
import { getRuntimeCompact } from "@/utils/date/time";
|
import { getRuntimeCompact } from "@/utils/date/time";
|
||||||
import getSubtitle from "@/utils/methods/getSubtitles";
|
import getSubtitle from "@/utils/methods/getSubtitles";
|
||||||
import playbackProfile from "@/utils/playback-profiles";
|
import { getNextEpisode, getPlaybackInfo } from "@/utils/methods/playback";
|
||||||
import { axiosClient, useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
||||||
import type IntroMediaInfo from "@/utils/types/introMediaInfo";
|
import { playItem } from "@/utils/store/playback";
|
||||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
import { setQueue } from "@/utils/store/queue";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
|
||||||
import type { SxProps } from "@mui/material";
|
|
||||||
import type { AxiosResponse } from "axios";
|
|
||||||
|
|
||||||
type PlayButtonProps = {
|
type PlayButtonProps = {
|
||||||
item: BaseItemDto;
|
item: BaseItemDto;
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
itemId?: string;
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
itemUserData?: UserItemDataDto;
|
|
||||||
userId: string | undefined;
|
userId: string | undefined;
|
||||||
itemType: BaseItemKind;
|
itemType: BaseItemKind;
|
||||||
currentAudioTrack?: number;
|
currentAudioTrack?: number | "auto";
|
||||||
currentVideoTrack?: number;
|
currentVideoTrack?: number;
|
||||||
currentSubTrack?: number | "nosub";
|
currentSubTrack?: number | "nosub";
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -68,8 +35,8 @@ type PlayButtonProps = {
|
|||||||
buttonProps?: ButtonProps;
|
buttonProps?: ButtonProps;
|
||||||
iconOnly?: boolean;
|
iconOnly?: boolean;
|
||||||
audio?: boolean;
|
audio?: boolean;
|
||||||
size?: ButtonPropsSizeOverrides;
|
size?: "small" | "large" | "medium";
|
||||||
playlistItem?: BaseItemDto;
|
playlistItem?: boolean;
|
||||||
playlistItemId?: string;
|
playlistItemId?: string;
|
||||||
trackIndex?: number;
|
trackIndex?: number;
|
||||||
};
|
};
|
||||||
@@ -91,19 +58,18 @@ const MemoizedLinearProgress = memo(({ value }: { value: number }) => (
|
|||||||
zIndex: 0,
|
zIndex: 0,
|
||||||
mixBlendMode: "difference",
|
mixBlendMode: "difference",
|
||||||
}}
|
}}
|
||||||
|
//@ts-expect-error
|
||||||
color="white"
|
color="white"
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
const PlayButton = ({
|
const PlayButton = ({
|
||||||
item,
|
item,
|
||||||
itemId,
|
|
||||||
itemUserData,
|
|
||||||
userId,
|
userId,
|
||||||
itemType,
|
itemType,
|
||||||
currentAudioTrack,
|
currentAudioTrack,
|
||||||
currentSubTrack,
|
currentSubTrack,
|
||||||
currentVideoTrack,
|
// currentVideoTrack,
|
||||||
className,
|
className,
|
||||||
sx,
|
sx,
|
||||||
buttonProps,
|
buttonProps,
|
||||||
@@ -112,227 +78,62 @@ const PlayButton = ({
|
|||||||
size = "large",
|
size = "large",
|
||||||
playlistItem,
|
playlistItem,
|
||||||
playlistItemId = "",
|
playlistItemId = "",
|
||||||
trackIndex,
|
|
||||||
}: PlayButtonProps) => {
|
}: PlayButtonProps) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const setPlaybackDataLoading = usePlaybackDataLoadStore(
|
// const setPlaybackDataLoading = usePlaybackDataLoadStore(
|
||||||
(state) => state.setisPending,
|
// (state) => state.setisPending,
|
||||||
);
|
// );
|
||||||
const playPhotos = usePhotosPlayback((s) => s.playPhotos);
|
const playPhotos = usePhotosPlayback((s) => s.playPhotos);
|
||||||
|
const currentUser = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
const itemQuery = useMutation({
|
const itemQuery = useMutation({
|
||||||
mutationKey: ["playButton", item?.Id, userId],
|
mutationKey: ["playButton", item?.Id, userId],
|
||||||
mutationFn: async () => {
|
mutationFn: async (currentEpisodeId?: string) => {
|
||||||
setPlaybackDataLoading(true);
|
if (!api) {
|
||||||
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
throw new Error("API is not available");
|
||||||
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
|
||||||
let introInfo: undefined | IntroMediaInfo;
|
|
||||||
const indexNumber = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
|
||||||
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,
|
|
||||||
// startItemId: item.Id,
|
|
||||||
});
|
|
||||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
|
||||||
audioStreamIndex: currentAudioTrack,
|
|
||||||
subtitleStreamIndex:
|
|
||||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
|
||||||
itemId: result.data.Items?.[indexNumber].Id,
|
|
||||||
startTimeTicks:
|
|
||||||
result.data.Items?.[indexNumber].UserData
|
|
||||||
?.PlaybackPositionTicks,
|
|
||||||
userId: userId,
|
|
||||||
mediaSourceId:
|
|
||||||
result.data.Items?.[indexNumber].MediaSources?.[0].Id,
|
|
||||||
playbackInfoDto: {
|
|
||||||
DeviceProfile: playbackProfile,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
introInfo = (
|
|
||||||
await axiosClient.get(
|
|
||||||
`${api.basePath}/Episode/${result.data.Items?.[0]?.Id}/IntroSkipperSegments`,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: `MediaBrowser Token=${api.accessToken}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
)?.data;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
}
|
||||||
|
if (!userId) {
|
||||||
|
throw new Error("User ID is not available");
|
||||||
}
|
}
|
||||||
break;
|
if (!item.Id) {
|
||||||
case BaseItemKind.Series:
|
throw new Error("Item ID is not available");
|
||||||
result = await getTvShowsApi(api).getEpisodes({
|
|
||||||
seriesId: item.Id,
|
|
||||||
fields: [
|
|
||||||
ItemFields.MediaSources,
|
|
||||||
ItemFields.MediaStreams,
|
|
||||||
ItemFields.Overview,
|
|
||||||
ItemFields.Chapters,
|
|
||||||
ItemFields.Trickplay,
|
|
||||||
],
|
|
||||||
enableUserData: true,
|
|
||||||
userId: userId,
|
|
||||||
});
|
|
||||||
if (
|
|
||||||
result.data.Items?.[0].Id &&
|
|
||||||
result.data.Items?.[0].MediaSources?.[0].Id
|
|
||||||
)
|
|
||||||
mediaSource = await getMediaInfoApi(api).getPostedPlaybackInfo({
|
|
||||||
audioStreamIndex: currentAudioTrack,
|
|
||||||
subtitleStreamIndex:
|
|
||||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
|
||||||
itemId: result.data.Items?.[0].Id,
|
|
||||||
startTimeTicks:
|
|
||||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
|
||||||
userId: userId,
|
|
||||||
mediaSourceId: result.data.Items?.[0].MediaSources?.[0].Id,
|
|
||||||
playbackInfoDto: {
|
|
||||||
DeviceProfile: playbackProfile,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
introInfo = (
|
|
||||||
await axiosClient.get(
|
|
||||||
`${api.basePath}/Episode/${result.data.Items?.[0]?.Id}/IntroSkipperSegments`,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: `MediaBrowser Token=${api.accessToken}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
)?.data;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case BaseItemKind.Playlist:
|
return await getPlaybackInfo(api, userId, item, {
|
||||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
currentAudioTrack,
|
||||||
userId: userId,
|
currentSubTrack,
|
||||||
playlistId: playlistItemId,
|
currentEpisodeId,
|
||||||
|
playlistItem,
|
||||||
|
playlistItemId,
|
||||||
});
|
});
|
||||||
break;
|
|
||||||
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"],
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case BaseItemKind.Photo:
|
|
||||||
if (item.Id) {
|
|
||||||
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"],
|
|
||||||
});
|
|
||||||
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,
|
|
||||||
},
|
},
|
||||||
});
|
onSuccess: async (result: PlayResult | null) => {
|
||||||
break;
|
if (!api) {
|
||||||
|
console.error("API is not available");
|
||||||
|
enqueueSnackbar("API is not available", { variant: "error" });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (!userId) {
|
||||||
|
console.error("User ID is not available");
|
||||||
|
enqueueSnackbar("User ID is not available", { variant: "error" });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return { item: result?.data, mediaSource: mediaSource?.data, introInfo };
|
if (!result?.item?.Items?.length) {
|
||||||
},
|
console.error("No items found");
|
||||||
onSuccess: (result: PlayResult | null) => {
|
enqueueSnackbar("No items found", { variant: "error" });
|
||||||
if (trackIndex) {
|
return;
|
||||||
// Playlist Playback
|
}
|
||||||
enqueueSnackbar("Playlist playback is WIP", { variant: "info" });
|
if (!result?.item?.Items?.[0]?.Id) {
|
||||||
} else if (audio) {
|
console.error("No item ID found");
|
||||||
|
enqueueSnackbar("No item ID found", { variant: "error" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audio) {
|
||||||
// Album/Individual audio track playback
|
// Album/Individual audio track playback
|
||||||
const urlOptions: Record<string, string> = {
|
|
||||||
deviceId: api?.deviceInfo.id,
|
|
||||||
//@ts-ignore
|
|
||||||
userId: userId,
|
|
||||||
api_key: api?.accessToken,
|
|
||||||
};
|
|
||||||
const urlParams = new URLSearchParams(urlOptions).toString();
|
|
||||||
const playbackUrl = generateAudioStreamUrl(
|
const playbackUrl = generateAudioStreamUrl(
|
||||||
result?.item?.Items?.[0].Id,
|
result?.item?.Items?.[0].Id,
|
||||||
userId,
|
userId,
|
||||||
@@ -349,24 +150,77 @@ const PlayButton = ({
|
|||||||
navigate({ to: "/player/photos" });
|
navigate({ to: "/player/photos" });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const episodeIndex = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
||||||
|
console.error("No media source ID found");
|
||||||
|
enqueueSnackbar("No media source ID found", { variant: "error" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const episodeIndex = result.episodeIndex;
|
||||||
|
|
||||||
// Creates a queue containing all Episodes for a particular season(series) or collection of movies
|
// Creates a queue containing all Episodes for a particular season(series) or collection of movies
|
||||||
const queue = result?.item.Items;
|
const queue = result?.item?.Items;
|
||||||
|
|
||||||
let itemName = item.Name;
|
let itemName = item.Name;
|
||||||
let episodeTitle = "";
|
let episodeTitle = "";
|
||||||
if (result?.item.Items?.[episodeIndex].SeriesId) {
|
if (result?.item?.Items?.[episodeIndex].SeriesId) {
|
||||||
itemName = result?.item.Items[episodeIndex].SeriesName;
|
itemName = result?.item.Items[episodeIndex].SeriesName;
|
||||||
episodeTitle = `S${result?.item.Items[episodeIndex].ParentIndexNumber ?? 0}:E${
|
episodeTitle = `S${result?.item.Items[episodeIndex].ParentIndexNumber ?? 0}:E${
|
||||||
result?.item.Items[episodeIndex].IndexNumber ?? 0
|
result?.item.Items[episodeIndex].IndexNumber ?? 0
|
||||||
} ${result?.item.Items[episodeIndex].Name}`;
|
} ${result?.item.Items[episodeIndex].Name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemType === "BoxSet") {
|
||||||
|
itemName = result.item.Items[0].Name;
|
||||||
|
}
|
||||||
|
|
||||||
// Subtitle
|
// Subtitle
|
||||||
const subtitle = getSubtitle(
|
const userSubtitleLanguagePreference =
|
||||||
currentSubTrack,
|
currentUser?.Configuration?.SubtitleLanguagePreference;
|
||||||
result?.mediaSource.MediaSources?.[0].MediaStreams,
|
// Get all subtitle streams
|
||||||
|
const allSubtitles =
|
||||||
|
result?.mediaSource?.MediaSources?.[0]?.MediaStreams?.filter(
|
||||||
|
(stream) => stream.Type === "Subtitle",
|
||||||
);
|
);
|
||||||
|
// Find preferred subtitle based on user's language preference
|
||||||
|
const preferredSubtitle =
|
||||||
|
allSubtitles?.find(
|
||||||
|
(sub) => sub.Language === userSubtitleLanguagePreference,
|
||||||
|
) || null;
|
||||||
|
|
||||||
|
const subtitle = getSubtitle(
|
||||||
|
preferredSubtitle?.Index ??
|
||||||
|
result.mediaSource.MediaSources?.[0].DefaultSubtitleStreamIndex ??
|
||||||
|
-1,
|
||||||
|
result?.mediaSource?.MediaSources?.[0]?.MediaStreams,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Audio
|
||||||
|
const userAudioLanguagePreference =
|
||||||
|
currentUser?.Configuration?.AudioLanguagePreference;
|
||||||
|
// Get all audio streams
|
||||||
|
const allAudioTracks =
|
||||||
|
result.mediaSource.MediaSources?.[0].MediaStreams?.filter(
|
||||||
|
(value) => value.Type === "Audio",
|
||||||
|
);
|
||||||
|
// Find preferred audio track based on user's language preference
|
||||||
|
const preferredAudioTrack =
|
||||||
|
allAudioTracks?.find(
|
||||||
|
(track) => track.Language === userAudioLanguagePreference,
|
||||||
|
) ||
|
||||||
|
allAudioTracks?.find((track) => track.IsDefault) ||
|
||||||
|
allAudioTracks?.[0];
|
||||||
|
|
||||||
|
const audio = {
|
||||||
|
track:
|
||||||
|
preferredAudioTrack?.Index ??
|
||||||
|
result.mediaSource.MediaSources?.[0].DefaultAudioStreamIndex ??
|
||||||
|
0,
|
||||||
|
allTracks: allAudioTracks,
|
||||||
|
};
|
||||||
|
|
||||||
// URL generation
|
// URL generation
|
||||||
const urlOptions: URLSearchParams = {
|
const urlOptions: URLSearchParams = {
|
||||||
|
//@ts-expect-error
|
||||||
Static: true,
|
Static: true,
|
||||||
tag: result?.mediaSource.MediaSources?.[0].ETag,
|
tag: result?.mediaSource.MediaSources?.[0].ETag,
|
||||||
mediaSourceId: result?.mediaSource.MediaSources?.[0].Id,
|
mediaSourceId: result?.mediaSource.MediaSources?.[0].Id,
|
||||||
@@ -381,34 +235,71 @@ const PlayButton = ({
|
|||||||
) {
|
) {
|
||||||
playbackUrl = `${api.basePath}${result.mediaSource.MediaSources[0].TranscodingUrl}`;
|
playbackUrl = `${api.basePath}${result.mediaSource.MediaSources[0].TranscodingUrl}`;
|
||||||
}
|
}
|
||||||
let playItemValue = item;
|
let playItemValue = result?.item?.Items?.[episodeIndex];
|
||||||
if (itemType === BaseItemKind.Movie) {
|
if (itemType === BaseItemKind.Movie) {
|
||||||
playItemValue = result?.item.Items?.[0];
|
playItemValue = result?.item?.Items?.[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
playItem(
|
const startPosition =
|
||||||
itemName,
|
result?.item?.Items?.[episodeIndex].UserData?.PlaybackPositionTicks;
|
||||||
episodeTitle,
|
|
||||||
currentVideoTrack,
|
const videoTrack =
|
||||||
currentAudioTrack,
|
result.mediaSource.MediaSources?.[0].MediaStreams?.filter(
|
||||||
result?.mediaSource?.MediaSources?.[0].Container ?? "mkv",
|
(value) => value.Type === "Video",
|
||||||
playbackUrl,
|
|
||||||
userId,
|
|
||||||
item.UserData?.PlaybackPositionTicks,
|
|
||||||
item.RunTimeTicks,
|
|
||||||
playItemValue,
|
|
||||||
queue,
|
|
||||||
episodeIndex,
|
|
||||||
result?.mediaSource.MediaSources?.[0]?.Id,
|
|
||||||
result?.mediaSource.PlaySessionId,
|
|
||||||
subtitle,
|
|
||||||
result?.introInfo,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isDirectPlay =
|
||||||
|
!result.mediaSource.MediaSources?.[0].SupportsTranscoding ||
|
||||||
|
!result.mediaSource.MediaSources?.[0].TranscodingUrl;
|
||||||
|
|
||||||
|
playItem({
|
||||||
|
metadata: {
|
||||||
|
itemName: itemName ?? "",
|
||||||
|
episodeTitle: episodeTitle,
|
||||||
|
isEpisode: !!item.SeriesId,
|
||||||
|
itemDuration: playItemValue?.RunTimeTicks ?? item.RunTimeTicks ?? 0,
|
||||||
|
item: playItemValue ?? item,
|
||||||
|
mediaSegments: result.mediaSegments,
|
||||||
|
userDataLastPlayedPositionTicks: startPosition ?? 0,
|
||||||
|
},
|
||||||
|
mediaSource: {
|
||||||
|
videoTrack: videoTrack?.[0]?.Index ?? 0,
|
||||||
|
audioTrack: audio.track,
|
||||||
|
container: result.mediaSource.MediaSources?.[0].Container ?? "",
|
||||||
|
id: result.mediaSource.MediaSources?.[0]?.Id,
|
||||||
|
subtitle: {
|
||||||
|
url: subtitle?.url,
|
||||||
|
track: subtitle?.track ?? -1,
|
||||||
|
format: subtitle?.format ?? "nosub",
|
||||||
|
allTracks:
|
||||||
|
result.mediaSource.MediaSources?.[0].MediaStreams?.filter(
|
||||||
|
(value) => value.Type === "Subtitle",
|
||||||
|
),
|
||||||
|
enable: subtitle?.enable ?? false,
|
||||||
|
},
|
||||||
|
audio: audio,
|
||||||
|
bitrate: result.mediaSource.MediaSources?.[0].Bitrate ?? 0,
|
||||||
|
videoCodec: videoTrack?.[0]?.Codec ?? "",
|
||||||
|
audioCodec:
|
||||||
|
audio.allTracks?.find((t) => t.Index === audio.track)?.Codec ??
|
||||||
|
"",
|
||||||
|
isDirectPlay: isDirectPlay,
|
||||||
|
transcodingUrl:
|
||||||
|
result.mediaSource.MediaSources?.[0].TranscodingUrl ?? "",
|
||||||
|
},
|
||||||
|
playbackStream: playbackUrl,
|
||||||
|
playsessionId: result.mediaSource.PlaySessionId,
|
||||||
|
userDataPlayedPositionTicks:
|
||||||
|
item.UserData?.PlaybackPositionTicks ?? 0,
|
||||||
|
userId,
|
||||||
|
queueItems: queue ?? [],
|
||||||
|
queueItemIndex: episodeIndex,
|
||||||
|
});
|
||||||
navigate({ to: "/player" });
|
navigate({ to: "/player" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
setPlaybackDataLoading(false);
|
// setPlaybackDataLoading(false);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -417,19 +308,73 @@ const PlayButton = ({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const handleClick = (e) => {
|
const handleClick = (
|
||||||
|
e: MouseEvent<HTMLAnchorElement | MouseEvent>,
|
||||||
|
currentEpisodeId?: string | undefined,
|
||||||
|
) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
itemQuery.mutate();
|
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) {
|
if (iconOnly) {
|
||||||
return (
|
return (
|
||||||
|
//@ts-expect-error
|
||||||
<Fab
|
<Fab
|
||||||
color="primary"
|
color="primary"
|
||||||
aria-label="Play"
|
aria-label="Play"
|
||||||
className={className}
|
className={className}
|
||||||
onClick={handleClick}
|
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}
|
sx={sx}
|
||||||
size={size}
|
size={size}
|
||||||
|
disabled={
|
||||||
|
itemType === BaseItemKind.Series &&
|
||||||
|
(!currentEpisode.data ||
|
||||||
|
!currentEpisode.data.Items ||
|
||||||
|
currentEpisode.data.Items.length === 0)
|
||||||
|
}
|
||||||
{...buttonProps}
|
{...buttonProps}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -443,6 +388,8 @@ const PlayButton = ({
|
|||||||
</Fab>
|
</Fab>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemType === BaseItemKind.Series) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="play-button"
|
className="play-button"
|
||||||
@@ -452,9 +399,15 @@ const PlayButton = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
|
loading={currentEpisode.isPending}
|
||||||
className={className ?? "play-button"}
|
className={className ?? "play-button"}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={handleClick}
|
onClick={(e) => {
|
||||||
|
const episodeId = currentEpisode.data?.Items?.[0]?.Id;
|
||||||
|
if (episodeId) {
|
||||||
|
handleClick(e, episodeId);
|
||||||
|
}
|
||||||
|
}}
|
||||||
startIcon={
|
startIcon={
|
||||||
<div
|
<div
|
||||||
className="material-symbols-rounded fill"
|
className="material-symbols-rounded fill"
|
||||||
@@ -471,28 +424,44 @@ const PlayButton = ({
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
}}
|
}}
|
||||||
|
//@ts-expect-error - white color is a custom color in the theme which mui's types don't know about
|
||||||
color="white"
|
color="white"
|
||||||
size={size}
|
size={size}
|
||||||
|
disabled={
|
||||||
|
currentEpisode.isPending ||
|
||||||
|
!currentEpisode.data ||
|
||||||
|
!currentEpisode.data.Items ||
|
||||||
|
currentEpisode.data.Items.length === 0 ||
|
||||||
|
!currentEpisode.data.Items[0].Id
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{itemUserData?.PlaybackPositionTicks
|
{currentEpisode.isPending ? (
|
||||||
? "Continue Watching"
|
"Loading..."
|
||||||
: item?.Type === "MusicAlbum" ||
|
) : !currentEpisode.data ||
|
||||||
item?.Type === "Audio" ||
|
!currentEpisode.data.Items ||
|
||||||
item?.Type === "AudioBook" ||
|
currentEpisode.data.Items.length === 0 ? (
|
||||||
item?.Type === "Playlist" ||
|
"No episodes to watch found"
|
||||||
audio
|
) : (
|
||||||
? "Play Now"
|
<>
|
||||||
: "Watch Now"}
|
Watch S{currentEpisode.data.Items[0].ParentIndexNumber ?? 1}E
|
||||||
|
{currentEpisode.data.Items[0]?.IndexNumber ?? 1}
|
||||||
<MemoizedLinearProgress
|
<MemoizedLinearProgress
|
||||||
|
//@ts-expect-error
|
||||||
value={
|
value={
|
||||||
100 > itemUserData?.PlayedPercentage &&
|
100 >
|
||||||
itemUserData?.PlayedPercentage > 0
|
(currentEpisode.data.Items[0].UserData?.PlayedPercentage ??
|
||||||
? itemUserData?.PlayedPercentage
|
100) &&
|
||||||
|
(currentEpisode.data.Items[0].UserData?.PlayedPercentage ??
|
||||||
|
0) > 0
|
||||||
|
? currentEpisode.data.Items[0].UserData?.PlayedPercentage
|
||||||
: 0
|
: 0
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
{itemUserData?.PlaybackPositionTicks > 0 && (
|
{(currentEpisode.data?.Items?.[0]?.UserData?.PlaybackPositionTicks ??
|
||||||
|
0) > 0 && (
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
@@ -504,7 +473,83 @@ const PlayButton = ({
|
|||||||
variant="caption"
|
variant="caption"
|
||||||
>
|
>
|
||||||
{getRuntimeCompact(
|
{getRuntimeCompact(
|
||||||
item.RunTimeTicks - itemUserData.PlaybackPositionTicks,
|
(currentEpisode.data?.Items?.[0]?.RunTimeTicks ?? 0) -
|
||||||
|
(currentEpisode.data?.Items?.[0]?.UserData
|
||||||
|
?.PlaybackPositionTicks ?? 0),
|
||||||
|
)}{" "}
|
||||||
|
left
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="play-button"
|
||||||
|
style={{
|
||||||
|
width: "auto",
|
||||||
|
position: "relative",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
className={className ?? "play-button"}
|
||||||
|
variant="contained"
|
||||||
|
onClick={(e) =>
|
||||||
|
item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e)
|
||||||
|
}
|
||||||
|
startIcon={
|
||||||
|
<div
|
||||||
|
className="material-symbols-rounded fill"
|
||||||
|
style={{
|
||||||
|
zIndex: 1,
|
||||||
|
fontSize: "2em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
play_arrow
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
{...buttonProps}
|
||||||
|
sx={{
|
||||||
|
position: "relative",
|
||||||
|
overflow: "hidden",
|
||||||
|
}}
|
||||||
|
//@ts-expect-error - white color is a custom color in the theme which mui's types don't know about
|
||||||
|
color="white"
|
||||||
|
size={size}
|
||||||
|
>
|
||||||
|
{item.UserData?.PlaybackPositionTicks
|
||||||
|
? "Continue Watching"
|
||||||
|
: item?.Type === "MusicAlbum" ||
|
||||||
|
item?.Type === "Audio" ||
|
||||||
|
item?.Type === "AudioBook" ||
|
||||||
|
item?.Type === "Playlist" ||
|
||||||
|
audio
|
||||||
|
? "Play Now"
|
||||||
|
: "Watch Now"}
|
||||||
|
<MemoizedLinearProgress
|
||||||
|
//@ts-expect-error
|
||||||
|
value={
|
||||||
|
100 > (item.UserData?.PlayedPercentage ?? 100) &&
|
||||||
|
(item.UserData?.PlayedPercentage ?? 0) > 0
|
||||||
|
? item.UserData?.PlayedPercentage
|
||||||
|
: 0
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Button>
|
||||||
|
{(item.UserData?.PlaybackPositionTicks ?? 0) > 0 && (
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
opacity: 0.8,
|
||||||
|
position: "absolute",
|
||||||
|
bottom: "-1.8em",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%)",
|
||||||
|
}}
|
||||||
|
variant="caption"
|
||||||
|
>
|
||||||
|
{getRuntimeCompact(
|
||||||
|
(item.RunTimeTicks ?? 0) -
|
||||||
|
(item.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
)}{" "}
|
)}{" "}
|
||||||
left
|
left
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -4,23 +4,23 @@ import useQueue from "@/utils/store/queue";
|
|||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { IconButton } from "@mui/material";
|
import { IconButton } from "@mui/material";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const PlayNextButton = () => {
|
const PlayNextButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
queryKey: ["user"],
|
queryKey: ["user"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const result = await getUserApi(api).getCurrentUser();
|
const result = await getUserApi(api).getCurrentUser();
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const navigate = useNavigate();
|
|
||||||
const handlePlayNext = useMutation({
|
const handlePlayNext = useMutation({
|
||||||
mutationKey: ["playNextButton"],
|
mutationKey: ["playNextButton"],
|
||||||
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
||||||
onError: (error) => [console.error(error)],
|
onError: (error) => console.error(error),
|
||||||
});
|
});
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||||
state.tracks,
|
state.tracks,
|
||||||
@@ -28,7 +28,7 @@ const PlayNextButton = () => {
|
|||||||
]);
|
]);
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={queueItems.length === currentItemIndex + 1}
|
disabled={queueItems?.length === currentItemIndex + 1}
|
||||||
onClick={() => handlePlayNext.mutate()}
|
onClick={() => handlePlayNext.mutate()}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">skip_next</span>
|
<span className="material-symbols-rounded">skip_next</span>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import useQueue from "@/utils/store/queue";
|
|||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { IconButton } from "@mui/material";
|
import { IconButton } from "@mui/material";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const PlayPreviousButton = () => {
|
const PlayPreviousButton = () => {
|
||||||
@@ -12,6 +11,7 @@ const PlayPreviousButton = () => {
|
|||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
queryKey: ["user"],
|
queryKey: ["user"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const result = await getUserApi(api).getCurrentUser();
|
const result = await getUserApi(api).getCurrentUser();
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -21,10 +21,7 @@ const PlayPreviousButton = () => {
|
|||||||
mutationFn: () => playItemFromQueue("previous", user.data?.Id, api),
|
mutationFn: () => playItemFromQueue("previous", user.data?.Id, api),
|
||||||
onError: (error) => [console.error(error)],
|
onError: (error) => [console.error(error)],
|
||||||
});
|
});
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
const [currentItemIndex] = useQueue((state) => [state.currentItemIndex]);
|
||||||
state.tracks,
|
|
||||||
state.currentItemIndex,
|
|
||||||
]);
|
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={currentItemIndex === 0}
|
disabled={currentItemIndex === 0}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
const QueueButton = () => {
|
const QueueButton = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||||
state.tracks,
|
state.tracks,
|
||||||
state.currentItemIndex,
|
state.currentItemIndex,
|
||||||
@@ -25,6 +26,7 @@ const QueueButton = () => {
|
|||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
queryKey: ["user"],
|
queryKey: ["user"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return;
|
||||||
const result = await getUserApi(api).getCurrentUser();
|
const result = await getUserApi(api).getCurrentUser();
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -76,7 +78,7 @@ const QueueButton = () => {
|
|||||||
position: "relative",
|
position: "relative",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{queueItems[currentItemIndex]?.Id && (
|
{queueItems?.[currentItemIndex]?.Id && (
|
||||||
<>
|
<>
|
||||||
<Typography px="1em" mb={2} variant="h5" fontWeight={300}>
|
<Typography px="1em" mb={2} variant="h5" fontWeight={300}>
|
||||||
Currently Playing:
|
Currently Playing:
|
||||||
@@ -97,27 +99,34 @@ const QueueButton = () => {
|
|||||||
{queueItems[currentItemIndex].ImageTags?.Primary ? (
|
{queueItems[currentItemIndex].ImageTags?.Primary ? (
|
||||||
<img
|
<img
|
||||||
className="queue-item-image"
|
className="queue-item-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
queueItems[currentItemIndex]?.Id,
|
queueItems[currentItemIndex]?.Id,
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
tag: queueItems[currentItemIndex].ImageTags?.Primary,
|
tag: queueItems[currentItemIndex].ImageTags
|
||||||
|
?.Primary,
|
||||||
},
|
},
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
alt={queueItems[currentItemIndex].Name ?? "image"}
|
alt={queueItems[currentItemIndex].Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : (queueItems[currentItemIndex].AlbumPrimaryImageTag
|
) : (queueItems[currentItemIndex].AlbumPrimaryImageTag
|
||||||
?.length ?? -1) > 0 ? (
|
?.length ?? -1) > 0 ? (
|
||||||
<img
|
<img
|
||||||
className="queue-item-image"
|
className="queue-item-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
queueItems[currentItemIndex]?.AlbumId,
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
queueItems?.[currentItemIndex]?.AlbumId ?? "",
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
tag: queueItems[currentItemIndex]
|
tag: queueItems?.[currentItemIndex]
|
||||||
.AlbumPrimaryImageTag[0],
|
.AlbumPrimaryImageTag?.[0],
|
||||||
},
|
},
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
alt={queueItems[currentItemIndex].Name ?? "image"}
|
alt={queueItems[currentItemIndex].Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -134,6 +143,7 @@ const QueueButton = () => {
|
|||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translate(-50%,-50%)",
|
transform: "translate(-50%,-50%)",
|
||||||
fontSize: "2em",
|
fontSize: "2em",
|
||||||
|
//@ts-ignore
|
||||||
"--wght": "100",
|
"--wght": "100",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -163,14 +173,15 @@ const QueueButton = () => {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{queueItems.slice(currentItemIndex + 1, queueItems.length - 1)
|
{queueItems &&
|
||||||
|
queueItems.slice(currentItemIndex + 1, queueItems.length - 1)
|
||||||
.length > 0 && (
|
.length > 0 && (
|
||||||
<Typography px="1em" my={2} variant="h5" fontWeight={300}>
|
<Typography px="1em" my={2} variant="h5" fontWeight={300}>
|
||||||
Queue:
|
Queue:
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
{queueItems
|
{queueItems
|
||||||
.slice(currentItemIndex + 1, queueItems.length - 1)
|
?.slice(currentItemIndex + 1, queueItems.length - 1)
|
||||||
.map((item, index) => {
|
.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@@ -191,25 +202,31 @@ const QueueButton = () => {
|
|||||||
{item.ImageTags?.Primary ? (
|
{item.ImageTags?.Primary ? (
|
||||||
<img
|
<img
|
||||||
className="queue-item-image"
|
className="queue-item-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item?.Id,
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
item?.Id ?? "",
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
tag: item.ImageTags?.Primary,
|
tag: item.ImageTags?.Primary,
|
||||||
},
|
},
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
alt={item.Name ?? "image"}
|
alt={item.Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : (item.AlbumPrimaryImageTag?.length ?? -1) > 0 ? (
|
) : (item.AlbumPrimaryImageTag?.length ?? -1) > 0 ? (
|
||||||
<img
|
<img
|
||||||
className="queue-item-image"
|
className="queue-item-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
item?.AlbumId,
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
item?.AlbumId ?? "",
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
tag: item.AlbumPrimaryImageTag[0],
|
tag: item.AlbumPrimaryImageTag?.[0],
|
||||||
},
|
},
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
alt={item.Name ?? "image"}
|
alt={item.Name ?? "image"}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import useInterval from "@/utils/hooks/useInterval";
|
import useInterval from "@/utils/hooks/useInterval";
|
||||||
|
import { saveUser } from "@/utils/storage/user";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-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";
|
import { LoadingButton, type LoadingButtonProps } from "@mui/lab";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -16,9 +18,10 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import type { TransitionProps } from "@mui/material/transitions";
|
import type { TransitionProps } from "@mui/material/transitions";
|
||||||
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import React, { useState } from "react";
|
import React, { useCallback, useState } from "react";
|
||||||
|
|
||||||
const Transition = React.forwardRef(function Transition(
|
const Transition = React.forwardRef(function Transition(
|
||||||
props: TransitionProps & {
|
props: TransitionProps & {
|
||||||
@@ -40,10 +43,20 @@ const Transition = React.forwardRef(function Transition(
|
|||||||
|
|
||||||
const QuickConnectButton = (props: LoadingButtonProps) => {
|
const QuickConnectButton = (props: LoadingButtonProps) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const createApi = useApiInContext((s) => s.createApi);
|
||||||
|
// if (!api) {
|
||||||
|
// console.error(
|
||||||
|
// "Unable to display quick connect button, api is not available",
|
||||||
|
// );
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
"X-Emby-Authorization": `MediaBrowser Client="${api?.clientInfo.name}", Device="${api?.deviceInfo.name}", DeviceId="${api?.deviceInfo.id}", Version="${api?.clientInfo.version}"`,
|
"X-Emby-Authorization": `MediaBrowser Client="${api?.clientInfo.name}", Device="${api?.deviceInfo.name}", DeviceId="${api?.deviceInfo.id}", Version="${api?.clientInfo.version}"`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const quickConnectEnabled = useQuery({
|
const quickConnectEnabled = useQuery({
|
||||||
queryKey: ["quick-connect-button", "check-quick-connect-enabled"],
|
queryKey: ["quick-connect-button", "check-quick-connect-enabled"],
|
||||||
queryFn: api
|
queryFn: api
|
||||||
@@ -54,18 +67,56 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
const [quickConnectCode, setQuickConnectCode] = useState<string | null>();
|
const [quickConnectCode, setQuickConnectCode] = useState<string | null>();
|
||||||
|
const [quickConnectSecret, setQuickConnectSecret] = useState<string | null>();
|
||||||
|
const [checkForQuickConnect, setCheckForQuickConnect] = useState(false);
|
||||||
const [rememberUser, setRememberUser] = useState(true);
|
const [rememberUser, setRememberUser] = useState(true);
|
||||||
|
const authenticateUser = useMutation({
|
||||||
|
mutationKey: ["quick-connect-button", "authenticate-user"],
|
||||||
|
mutationFn: async () => {
|
||||||
|
if (api && quickConnectSecret) {
|
||||||
|
return await getUserApi(api).authenticateWithQuickConnect(
|
||||||
|
{ quickConnectDto: { Secret: quickConnectSecret } },
|
||||||
|
{ headers },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSuccess: (result) => {
|
||||||
|
if (api && result?.data?.AccessToken && result.data.User?.Name) {
|
||||||
|
setCheckForQuickConnect(false);
|
||||||
|
// saveUser({ username, password, rememberMe: rememberUser });
|
||||||
|
enqueueSnackbar(`Logged in as ${result.data.User?.Name}!`, {
|
||||||
|
variant: "success",
|
||||||
|
});
|
||||||
|
createApi(api.basePath, result.data.AccessToken);
|
||||||
|
if (rememberUser) {
|
||||||
|
saveUser(result.data.User?.Name, result.data.AccessToken);
|
||||||
|
}
|
||||||
|
navigate({ to: "/home", replace: true });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
enqueueSnackbar("Error authenticating user.", { variant: "error" });
|
||||||
|
console.error(error);
|
||||||
|
},
|
||||||
|
});
|
||||||
const checkQuickConnectStatus = useMutation({
|
const checkQuickConnectStatus = useMutation({
|
||||||
mutationKey: ["quick-connect-button", "check-quick-connect-status"],
|
mutationKey: ["quick-connect-button", "check-quick-connect-status"],
|
||||||
mutationFn: async (secret: string) =>
|
mutationFn: async (secret: string) =>
|
||||||
api
|
api &&
|
||||||
? (
|
(
|
||||||
await getQuickConnectApi(api).getQuickConnectState(
|
await getQuickConnectApi(api).getQuickConnectState(
|
||||||
{ secret },
|
{ secret },
|
||||||
{ headers },
|
{ headers },
|
||||||
)
|
)
|
||||||
).data
|
).data,
|
||||||
: skipToken,
|
onSuccess: (result) => {
|
||||||
|
if (result?.Authenticated) {
|
||||||
|
setQuickConnectCode(null);
|
||||||
|
initQuickConnect.reset();
|
||||||
|
checkQuickConnectStatus.reset();
|
||||||
|
authenticateUser.mutate();
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const initQuickConnect = useMutation({
|
const initQuickConnect = useMutation({
|
||||||
mutationKey: ["quick-connect-button", "initiate-connection"],
|
mutationKey: ["quick-connect-button", "initiate-connection"],
|
||||||
@@ -81,6 +132,8 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
},
|
},
|
||||||
onSuccess: (result) => {
|
onSuccess: (result) => {
|
||||||
setQuickConnectCode(result?.data.Code);
|
setQuickConnectCode(result?.data.Code);
|
||||||
|
setQuickConnectSecret(result?.data.Secret);
|
||||||
|
setCheckForQuickConnect(true);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar("Error initiating Quick Connect.", { variant: "error" });
|
enqueueSnackbar("Error initiating Quick Connect.", { variant: "error" });
|
||||||
@@ -88,17 +141,26 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleQuickConnectClose = useCallback(() => {
|
||||||
|
setQuickConnectCode(null);
|
||||||
|
setCheckForQuickConnect(false);
|
||||||
|
initQuickConnect.reset();
|
||||||
|
checkQuickConnectStatus.reset();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useInterval(
|
useInterval(
|
||||||
() => {
|
() => {
|
||||||
if (quickConnectCode) {
|
if (quickConnectSecret) {
|
||||||
checkQuickConnectStatus.mutate(quickConnectCode);
|
console.log(checkForQuickConnect);
|
||||||
|
checkQuickConnectStatus.mutate(quickConnectSecret);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
quickConnectCode ? 1000 : null,
|
checkForQuickConnect ? 1500 : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div style={{ marginLeft: "auto" }}>
|
||||||
|
{/* @ts-ignore */}
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
{...props}
|
{...props}
|
||||||
disabled={
|
disabled={
|
||||||
@@ -111,18 +173,15 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
(quickConnectCode && !checkQuickConnectStatus.data?.Authenticated),
|
(quickConnectCode && !checkQuickConnectStatus.data?.Authenticated),
|
||||||
)}
|
)}
|
||||||
variant={props.variant ?? "contained"}
|
variant={props.variant ?? "contained"}
|
||||||
style={{ flex: 1 }}
|
|
||||||
onClick={initQuickConnect.mutate}
|
onClick={initQuickConnect.mutate}
|
||||||
>
|
>
|
||||||
Quick Connect
|
{quickConnectEnabled.data?.data
|
||||||
|
? "Use Quick Connect"
|
||||||
|
: "Quick Connect Disabled"}
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={Boolean(quickConnectCode)}
|
open={Boolean(quickConnectCode)}
|
||||||
onClose={() => {
|
onClose={handleQuickConnectClose}
|
||||||
setQuickConnectCode(null);
|
|
||||||
initQuickConnect.reset();
|
|
||||||
checkQuickConnectStatus.reset();
|
|
||||||
}}
|
|
||||||
fullWidth
|
fullWidth
|
||||||
maxWidth="xs"
|
maxWidth="xs"
|
||||||
TransitionComponent={Transition}
|
TransitionComponent={Transition}
|
||||||
@@ -191,17 +250,12 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
}
|
}
|
||||||
label="Remember device"
|
label="Remember device"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button variant="contained" onClick={handleQuickConnectClose}>
|
||||||
variant="contained"
|
|
||||||
onClick={() => {
|
|
||||||
setQuickConnectCode(null);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ type TrailerButtonType = {
|
|||||||
const TrailerButton = (props: TrailerButtonType) => {
|
const TrailerButton = (props: TrailerButtonType) => {
|
||||||
const [dialog, setDialog] = useState(false);
|
const [dialog, setDialog] = useState(false);
|
||||||
return (
|
return (
|
||||||
<>
|
<div>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={props.disabled ?? false}
|
disabled={props.disabled ?? false}
|
||||||
onClick={() => setDialog(true)}
|
onClick={() => setDialog(true)}
|
||||||
@@ -29,6 +29,7 @@ const TrailerButton = (props: TrailerButtonType) => {
|
|||||||
}}
|
}}
|
||||||
onClose={() => setDialog(false)}
|
onClose={() => setDialog(false)}
|
||||||
>
|
>
|
||||||
|
{props.trailerItem[0]?.Url && (
|
||||||
<ReactPlayer
|
<ReactPlayer
|
||||||
playing={false}
|
playing={false}
|
||||||
url={props.trailerItem[0]?.Url}
|
url={props.trailerItem[0]?.Url}
|
||||||
@@ -39,8 +40,9 @@ const TrailerButton = (props: TrailerButtonType) => {
|
|||||||
}}
|
}}
|
||||||
controls
|
controls
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
|
|
||||||
import MuiCard from "@mui/material/Card";
|
|
||||||
import CardActionArea from "@mui/material/CardActionArea";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { Blurhash } from "react-blurhash";
|
|
||||||
import { useApi } from "../../utils/store/api";
|
|
||||||
import "./card.scss";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
* @property {string} cardTitle
|
|
||||||
* @property {string | number} cardCaption
|
|
||||||
* @property {string} imageBlurhash
|
|
||||||
* @property {string} seriesId
|
|
||||||
* @property {boolean} hideText
|
|
||||||
* @property {() => {}} onClick
|
|
||||||
* @property {boolean} disablePadding
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Hero section for item pages
|
|
||||||
* @param {Props}
|
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const ActorCard = ({
|
|
||||||
item,
|
|
||||||
cardTitle,
|
|
||||||
cardCaption,
|
|
||||||
imageBlurhash,
|
|
||||||
seriesId,
|
|
||||||
hideText,
|
|
||||||
onClick,
|
|
||||||
disablePadding,
|
|
||||||
}) => {
|
|
||||||
const [api] = useApi((state) => [state.api]);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const defaultOnClick = () => {
|
|
||||||
navigate(`/person/${item.Id}`);
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="card card-actor"
|
|
||||||
elevation={0}
|
|
||||||
onClick={onClick ? onClick : defaultOnClick}
|
|
||||||
>
|
|
||||||
<div className="card-box">
|
|
||||||
<div
|
|
||||||
className="card-image-container"
|
|
||||||
style={{
|
|
||||||
aspectRatio: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!!imageBlurhash && (
|
|
||||||
<Blurhash
|
|
||||||
hash={imageBlurhash}
|
|
||||||
width={128}
|
|
||||||
height={128}
|
|
||||||
resolutionX={24}
|
|
||||||
resolutionY={24}
|
|
||||||
className="card-image-blurhash"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="card-image-icon-container">
|
|
||||||
<div className="material-symbols-rounded">person</div>
|
|
||||||
</div>
|
|
||||||
<img
|
|
||||||
alt={item.Name}
|
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
seriesId ? item.SeriesId : item.Id,
|
|
||||||
"Primary",
|
|
||||||
{
|
|
||||||
quality: 80,
|
|
||||||
fillHeight: 448,
|
|
||||||
fillWidth: 448,
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
style={{
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
loading="lazy"
|
|
||||||
onLoad={(e) => {
|
|
||||||
e.target.style.opacity = 1;
|
|
||||||
}}
|
|
||||||
className="card-image"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="card-text-container"
|
|
||||||
style={{ display: hideText ? "none" : "block" }}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
fontWeight={500}
|
|
||||||
noWrap
|
|
||||||
textAlign="center"
|
|
||||||
style={{ opacity: 0.9 }}
|
|
||||||
>
|
|
||||||
{cardTitle}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
noWrap
|
|
||||||
textAlign="center"
|
|
||||||
style={{ opacity: 0.6 }}
|
|
||||||
lineHeight="auto"
|
|
||||||
>
|
|
||||||
{cardCaption}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
+106
-54
@@ -1,26 +1,40 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
|
|
||||||
import React, { memo } from "react";
|
|
||||||
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
type ImageType,
|
type ImageType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import type React from "react";
|
||||||
|
import { memo, 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 LikeButton from "../buttons/likeButton";
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
import ErrorBoundary from "../errorBoundary";
|
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
import "./card.scss";
|
import "./card.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
|
|
||||||
const CardComponent = ({
|
interface CardProps {
|
||||||
|
item: BaseItemDto;
|
||||||
|
cardTitle: string | undefined | null;
|
||||||
|
cardCaption?: string | null | number;
|
||||||
|
imageType?: ImageType;
|
||||||
|
cardType: "square" | "thumb" | "portrait";
|
||||||
|
queryKey?: string[];
|
||||||
|
userId?: string;
|
||||||
|
seriesId?: string | null;
|
||||||
|
hideText?: boolean;
|
||||||
|
onClick?: () => void;
|
||||||
|
disableOverlay?: boolean;
|
||||||
|
overrideIcon?: any;
|
||||||
|
skipInView?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CardContent = ({
|
||||||
item,
|
item,
|
||||||
cardTitle,
|
cardTitle,
|
||||||
cardCaption,
|
cardCaption,
|
||||||
@@ -33,23 +47,17 @@ const CardComponent = ({
|
|||||||
onClick,
|
onClick,
|
||||||
disableOverlay = false,
|
disableOverlay = false,
|
||||||
overrideIcon,
|
overrideIcon,
|
||||||
}: {
|
inView,
|
||||||
item: BaseItemDto;
|
forwardedRef,
|
||||||
cardTitle: string | undefined | null;
|
}: CardProps & {
|
||||||
cardCaption?: string | null | number;
|
inView: boolean;
|
||||||
imageType: ImageType;
|
forwardedRef?: React.Ref<HTMLDivElement>;
|
||||||
cardType: string;
|
|
||||||
queryKey?: string[];
|
|
||||||
userId?: string;
|
|
||||||
seriesId?: string | null;
|
|
||||||
hideText?: boolean;
|
|
||||||
onClick?: () => void;
|
|
||||||
disableOverlay?: boolean;
|
|
||||||
overrideIcon?: any;
|
|
||||||
}) => {
|
}) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const defaultOnClick = () => {
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
|
|
||||||
|
const defaultOnClick = useCallback(() => {
|
||||||
if (item?.Id) {
|
if (item?.Id) {
|
||||||
switch (item?.Type) {
|
switch (item?.Type) {
|
||||||
case BaseItemKind.BoxSet:
|
case BaseItemKind.BoxSet:
|
||||||
@@ -78,12 +86,23 @@ const CardComponent = ({
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}, [item?.Id, item?.Type, navigate]);
|
||||||
|
|
||||||
|
const handleInteractionStart = useCallback(() => setIsHovered(true), []);
|
||||||
|
const handleInteractionEnd = useCallback(() => setIsHovered(false), []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card" onClick={onClick ? onClick : defaultOnClick}>
|
<div
|
||||||
|
className="card"
|
||||||
|
ref={forwardedRef}
|
||||||
|
onClick={onClick || defaultOnClick}
|
||||||
|
onMouseEnter={handleInteractionStart}
|
||||||
|
onMouseLeave={handleInteractionEnd}
|
||||||
|
onFocus={handleInteractionStart}
|
||||||
|
onBlur={handleInteractionEnd}
|
||||||
|
>
|
||||||
<div className={`card-image-container ${cardType}`}>
|
<div className={`card-image-container ${cardType}`}>
|
||||||
<ErrorBoundary fallback>
|
<ErrorBoundary fallback={<></>}>
|
||||||
<div
|
<div
|
||||||
className="card-indicator check"
|
className="card-indicator check"
|
||||||
style={{
|
style={{
|
||||||
@@ -98,13 +117,17 @@ const CardComponent = ({
|
|||||||
opacity: item.UserData?.UnplayedItemCount ? 1 : 0,
|
opacity: item.UserData?.UnplayedItemCount ? 1 : 0,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography
|
<span
|
||||||
variant="subtitle2"
|
style={{
|
||||||
padding="0.1em 0.4em"
|
padding: "0.1em 0.4em",
|
||||||
fontWeight={400}
|
fontWeight: 400,
|
||||||
|
fontSize: "0.875rem",
|
||||||
|
lineHeight: 1.57,
|
||||||
|
fontFamily: "inherit",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{item.UserData?.UnplayedItemCount}
|
{item.UserData?.UnplayedItemCount}
|
||||||
</Typography>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
<div className="card-image-icon-container">
|
<div className="card-image-icon-container">
|
||||||
@@ -112,6 +135,7 @@ const CardComponent = ({
|
|||||||
? getTypeIcon(overrideIcon)
|
? getTypeIcon(overrideIcon)
|
||||||
: getTypeIcon(item.Type ?? "universal")}
|
: getTypeIcon(item.Type ?? "universal")}
|
||||||
</div>
|
</div>
|
||||||
|
{inView && (
|
||||||
<img
|
<img
|
||||||
alt={item.Name ?? "blink"}
|
alt={item.Name ?? "blink"}
|
||||||
src={
|
src={
|
||||||
@@ -124,7 +148,7 @@ const CardComponent = ({
|
|||||||
imageType,
|
imageType,
|
||||||
{
|
{
|
||||||
quality: 90,
|
quality: 90,
|
||||||
fillWidth: cardType === "thumb" ? 560 : 280,
|
fillWidth: cardType === "thumb" ? 560 : 320,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: ""
|
: ""
|
||||||
@@ -133,29 +157,28 @@ const CardComponent = ({
|
|||||||
height: "100%",
|
height: "100%",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
|
display: "block",
|
||||||
|
transition: "opacity 0.3s ease-in-out",
|
||||||
}}
|
}}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.currentTarget.style.setProperty("opacity", "1");
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
onLoadStart={(e) => console.log(e)}
|
|
||||||
className="card-image"
|
className="card-image"
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{inView && !disableOverlay && (
|
||||||
<div className="card-overlay">
|
<div className="card-overlay">
|
||||||
{!disableOverlay && (
|
{isHovered && (
|
||||||
<>
|
<>
|
||||||
<PlayButton
|
<PlayButton
|
||||||
itemId={item.Id}
|
|
||||||
item={item}
|
item={item}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
itemType={item.Type}
|
itemType={item.Type ?? "Movie"}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack="auto"
|
||||||
currentSubTrack="nosub"
|
currentSubTrack={-1}
|
||||||
currentVideoTrack={0}
|
currentVideoTrack={0}
|
||||||
className="card-play-button"
|
className="card-play-button"
|
||||||
iconProps={{
|
|
||||||
style: { fontSize: "2.5em" },
|
|
||||||
}}
|
|
||||||
iconOnly
|
iconOnly
|
||||||
audio={
|
audio={
|
||||||
item.Type === BaseItemKind.MusicAlbum ||
|
item.Type === BaseItemKind.MusicAlbum ||
|
||||||
@@ -168,14 +191,14 @@ const CardComponent = ({
|
|||||||
/>
|
/>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
itemName={item.Name}
|
itemName={item.Name ?? ""}
|
||||||
isFavorite={item.UserData?.IsFavorite}
|
isFavorite={item.UserData?.IsFavorite}
|
||||||
queryKey={queryKey}
|
queryKey={queryKey}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
/>
|
/>
|
||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
itemName={item.Name}
|
itemName={item.Name ?? ""}
|
||||||
isPlayed={item.UserData?.Played}
|
isPlayed={item.UserData?.Played}
|
||||||
queryKey={queryKey}
|
queryKey={queryKey}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
@@ -183,6 +206,7 @@ const CardComponent = ({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
{(item.UserData?.PlaybackPositionTicks ?? -1) > 0 && (
|
{(item.UserData?.PlaybackPositionTicks ?? -1) > 0 && (
|
||||||
<div className="card-progress-container">
|
<div className="card-progress-container">
|
||||||
<div
|
<div
|
||||||
@@ -196,22 +220,50 @@ const CardComponent = ({
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="card-text-container"
|
className="card-text-container"
|
||||||
style={{ display: hideText ? "none" : "block" }}
|
style={{ display: hideText ? "none" : "block", marginLeft: "0.2em" }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginTop: "8px",
|
||||||
|
opacity: 0.9,
|
||||||
|
fontSize: "0.875rem",
|
||||||
|
fontWeight: 500,
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Typography mt={1} variant="subtitle2" noWrap style={{ opacity: 0.9 }}>
|
|
||||||
{cardTitle}
|
{cardTitle}
|
||||||
</Typography>
|
</div>
|
||||||
<Typography
|
<div
|
||||||
variant="caption"
|
style={{
|
||||||
noWrap
|
opacity: 0.6,
|
||||||
style={{ opacity: 0.6 }}
|
fontSize: "0.75rem",
|
||||||
lineHeight="auto"
|
whiteSpace: "nowrap",
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{cardCaption}
|
{cardCaption}
|
||||||
</Typography>
|
</div>
|
||||||
</div>
|
</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);
|
export const Card = memo(CardComponent);
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
import MuiCard from "@mui/material/Card";
|
|
||||||
import CardActionArea from "@mui/material/CardActionArea";
|
|
||||||
import LinearProgress from "@mui/material/LinearProgress";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { Blurhash } from "react-blurhash";
|
|
||||||
|
|
||||||
import "./card.scss";
|
|
||||||
|
|
||||||
import { getRuntimeCompact } from "@/utils/date/time";
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
|
||||||
import LikeButton from "../buttons/likeButton";
|
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
|
||||||
import PlayButton from "../buttons/playButton";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
* @property {string} cardTitle
|
|
||||||
* @property {string | number} cardCaption
|
|
||||||
* @property {string} imageBlurhash
|
|
||||||
* @property {Array} queryKey
|
|
||||||
* @property {string} userId
|
|
||||||
* @property {boolean} disableRunTime
|
|
||||||
* @property {() => {}} onClick
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Hero section for item pages
|
|
||||||
* @param {Props}
|
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const EpisodeCard = ({
|
|
||||||
item,
|
|
||||||
cardTitle,
|
|
||||||
cardCaption,
|
|
||||||
imageBlurhash,
|
|
||||||
queryKey,
|
|
||||||
userId,
|
|
||||||
disableRunTime = false,
|
|
||||||
onClick,
|
|
||||||
}) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const defaultOnClick = () => {
|
|
||||||
navigate({ to: `/episode/${item.Id}` });
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="card card-episode"
|
|
||||||
elevation={0}
|
|
||||||
onClick={onClick ? onClick : defaultOnClick}
|
|
||||||
>
|
|
||||||
<div className="card-box">
|
|
||||||
<div
|
|
||||||
className="card-image-container"
|
|
||||||
style={{
|
|
||||||
aspectRatio: 1.777,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!!item.UserData && (
|
|
||||||
<div
|
|
||||||
className="card-indicator check"
|
|
||||||
style={{
|
|
||||||
opacity: item.UserData?.Played ? 1 : 0,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="material-symbols-rounded">done</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{!!imageBlurhash && (
|
|
||||||
<Blurhash
|
|
||||||
hash={imageBlurhash}
|
|
||||||
width={128}
|
|
||||||
height={128}
|
|
||||||
resolutionX={24}
|
|
||||||
resolutionY={24}
|
|
||||||
className="card-image-blurhash"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="card-image-icon-container">
|
|
||||||
<div className="material-symbols-rounded">tv_gen</div>
|
|
||||||
</div>
|
|
||||||
<img
|
|
||||||
alt={item.Name}
|
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
|
|
||||||
quality: 90,
|
|
||||||
fillHeight: 512,
|
|
||||||
fillWidth: 512,
|
|
||||||
})}
|
|
||||||
style={{
|
|
||||||
height: "100%",
|
|
||||||
width: "100%",
|
|
||||||
opacity: 0,
|
|
||||||
}}
|
|
||||||
loading="lazy"
|
|
||||||
onLoad={(e) => {
|
|
||||||
e.target.style.opacity = 1;
|
|
||||||
}}
|
|
||||||
className="card-image"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="card-overlay">
|
|
||||||
<PlayButton
|
|
||||||
itemId={item.Id}
|
|
||||||
userId={userId}
|
|
||||||
itemType={item.Type}
|
|
||||||
currentAudioTrack={0}
|
|
||||||
currentSubTrack={0}
|
|
||||||
currentVideoTrack={0}
|
|
||||||
className="card-play-button"
|
|
||||||
iconProps={{
|
|
||||||
style: { fontSize: "2.5em" },
|
|
||||||
}}
|
|
||||||
iconOnly
|
|
||||||
/>
|
|
||||||
<LikeButton
|
|
||||||
itemId={item.Id}
|
|
||||||
itemName={item.Name}
|
|
||||||
isFavorite={item.UserData?.IsFavorite}
|
|
||||||
queryKey={queryKey}
|
|
||||||
userId={userId}
|
|
||||||
/>
|
|
||||||
<MarkPlayedButton
|
|
||||||
itemId={item.Id}
|
|
||||||
itemName={item.Name}
|
|
||||||
isPlayed={item.UserData?.Played}
|
|
||||||
queryKey={queryKey}
|
|
||||||
userId={userId}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{100 > item.UserData?.PlayedPercentage > 0 && (
|
|
||||||
<LinearProgress
|
|
||||||
variant="determinate"
|
|
||||||
value={item.UserData.PlayedPercentage}
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
zIndex: 2,
|
|
||||||
height: "6px",
|
|
||||||
background: "rgb(5 5 5 / 0.5) !important",
|
|
||||||
backdropFilter: "blur(5px)",
|
|
||||||
}}
|
|
||||||
color="primary"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="card-text-container"
|
|
||||||
style={{ display: "block", marginTop: "0.5em" }}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
gap: "1em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
fontWeight={500}
|
|
||||||
textAlign="start"
|
|
||||||
noWrap
|
|
||||||
style={{
|
|
||||||
opacity: 0.9,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{cardTitle}
|
|
||||||
</Typography>
|
|
||||||
{!disableRunTime && (
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
fontWeight={500}
|
|
||||||
noWrap
|
|
||||||
textAlign="start"
|
|
||||||
style={{ opacity: 0.8, flexShrink: 0 }}
|
|
||||||
>
|
|
||||||
{getRuntimeCompact(item.RunTimeTicks)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
textAlign="start"
|
|
||||||
style={{
|
|
||||||
opacity: 0.6,
|
|
||||||
display: "-webkit-box",
|
|
||||||
overflow: "hidden",
|
|
||||||
WebkitBoxOrient: "vertical",
|
|
||||||
WebkitLineClamp: 3,
|
|
||||||
}}
|
|
||||||
lineHeight="auto"
|
|
||||||
>
|
|
||||||
{cardCaption}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
+22
-18
@@ -1,11 +1,8 @@
|
|||||||
import PropTypes from "prop-types";
|
import React, { type ReactNode } from "react";
|
||||||
import React, { useState } from "react";
|
|
||||||
|
|
||||||
import Carousel from "react-multi-carousel";
|
import Carousel from "react-multi-carousel";
|
||||||
import "react-multi-carousel/lib/styles.css";
|
import "react-multi-carousel/lib/styles.css";
|
||||||
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import ButtonGroup from "@mui/material/ButtonGroup";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
@@ -30,14 +27,23 @@ function LeftButton(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CardScroller = ({
|
type CardScrollerProps = {
|
||||||
|
children: ReactNode;
|
||||||
|
displayCards: number;
|
||||||
|
title: string;
|
||||||
|
headingProps?: object;
|
||||||
|
disableDecoration?: boolean;
|
||||||
|
boxProps?: object;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function CardScroller({
|
||||||
children,
|
children,
|
||||||
displayCards,
|
displayCards,
|
||||||
title,
|
title,
|
||||||
headingProps,
|
headingProps,
|
||||||
disableDecoration = false,
|
disableDecoration = false,
|
||||||
boxProps,
|
boxProps,
|
||||||
}) => {
|
}: CardScrollerProps) {
|
||||||
const responsive = {
|
const responsive = {
|
||||||
superLargeDesktop: {
|
superLargeDesktop: {
|
||||||
// the naming can be any, depends on you.
|
// the naming can be any, depends on you.
|
||||||
@@ -73,9 +79,13 @@ export const CardScroller = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box {...boxProps} className="card-scroller-container" mb={1}>
|
<div
|
||||||
<Box
|
{...boxProps}
|
||||||
sx={{ mb: 1 }}
|
className="card-scroller-container"
|
||||||
|
style={{ marginBottom: "1.2em" }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{ marginBottom: "1.2em" }}
|
||||||
className={
|
className={
|
||||||
disableDecoration
|
disableDecoration
|
||||||
? "card-scroller-header-container hidden-decoration"
|
? "card-scroller-header-container hidden-decoration"
|
||||||
@@ -90,7 +100,7 @@ export const CardScroller = ({
|
|||||||
>
|
>
|
||||||
<div className="card-scroller-heading-decoration" /> {title}
|
<div className="card-scroller-heading-decoration" /> {title}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</div>
|
||||||
<Carousel
|
<Carousel
|
||||||
swipeable
|
swipeable
|
||||||
draggable
|
draggable
|
||||||
@@ -104,12 +114,6 @@ export const CardScroller = ({
|
|||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Carousel>
|
</Carousel>
|
||||||
</Box>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
CardScroller.propTypes = {
|
|
||||||
displayCards: PropTypes.number.isRequired,
|
|
||||||
title: PropTypes.string.isRequired,
|
|
||||||
headingProps: PropTypes.any,
|
|
||||||
};
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
|
import type { PanInfo } from "motion/react";
|
||||||
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
import React, { useEffect, useState, useMemo, useCallback } from "react";
|
||||||
|
import type { MouseEvent, PointerEvent } from "react";
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
|
|
||||||
import { useCarouselStore } from "../../utils/store/carousel";
|
import { useCarouselStore } from "../../utils/store/carousel";
|
||||||
import "./carousel.scss";
|
import "./carousel.scss";
|
||||||
@@ -10,12 +10,11 @@ import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|||||||
import CarouselSlide from "../carouselSlide";
|
import CarouselSlide from "../carouselSlide";
|
||||||
|
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import ReactMultiCarousel from "react-multi-carousel";
|
|
||||||
import Slider from "../Slider";
|
import Slider from "../Slider";
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
|
|
||||||
const swipeConfidenceThreshold = 8000;
|
const swipeConfidenceThreshold = 8000;
|
||||||
const swipePower = (offset, velocity) => {
|
const swipePower = (offset: number, velocity: number) => {
|
||||||
return Math.abs(offset) * velocity;
|
return Math.abs(offset) * velocity;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,14 +29,11 @@ const Carousel = ({
|
|||||||
onChange,
|
onChange,
|
||||||
}: {
|
}: {
|
||||||
content: BaseItemDto[];
|
content: BaseItemDto[];
|
||||||
onChange: () => void;
|
onChange: (currentSlide: number) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [currentSlide, setCurrentSlide] = useState(0);
|
const [currentSlide, setCurrentSlide] = useState(0);
|
||||||
|
|
||||||
const [setDirection, dir] = useCarouselStore((state) => [
|
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
|
||||||
state.setDirection,
|
|
||||||
state.direction,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onChange(currentSlide);
|
onChange(currentSlide);
|
||||||
@@ -45,27 +41,6 @@ const Carousel = ({
|
|||||||
|
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const responsive = {
|
|
||||||
superLargeDesktop: {
|
|
||||||
breakpoint: { max: 4000, min: 3000 },
|
|
||||||
items: 6,
|
|
||||||
},
|
|
||||||
desktop: {
|
|
||||||
breakpoint: { max: 3000, min: 1024 },
|
|
||||||
items: 6,
|
|
||||||
},
|
|
||||||
tablet: {
|
|
||||||
breakpoint: { max: 1024, min: 464 },
|
|
||||||
items: 4,
|
|
||||||
},
|
|
||||||
mobile: {
|
|
||||||
breakpoint: { max: 464, min: 0 },
|
|
||||||
items: 1,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Memoize the content mapping
|
// Memoize the content mapping
|
||||||
const sliderContent = useMemo(() => {
|
const sliderContent = useMemo(() => {
|
||||||
return content.map((item, index) => {
|
return content.map((item, index) => {
|
||||||
@@ -98,16 +73,23 @@ const Carousel = ({
|
|||||||
>
|
>
|
||||||
{item.ImageTags?.Thumb ? (
|
{item.ImageTags?.Thumb ? (
|
||||||
<img
|
<img
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Thumb", {
|
src={
|
||||||
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
item.Id ?? "",
|
||||||
|
"Thumb",
|
||||||
|
{
|
||||||
tag: item.ImageTags.Primary,
|
tag: item.ImageTags.Primary,
|
||||||
fillWidth: 300,
|
fillWidth: 300,
|
||||||
})}
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
alt={item.Name ?? "item-image"}
|
alt={item.Name ?? "item-image"}
|
||||||
className="carousel-indicator-image"
|
className="carousel-indicator-image"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="carousel-indicator-icon">
|
<div className="carousel-indicator-icon">
|
||||||
{getTypeIcon(item.Type)}
|
{getTypeIcon(item.Type ?? "Movie")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
@@ -116,7 +98,10 @@ const Carousel = ({
|
|||||||
}, [content, currentSlide, api, setDirection]);
|
}, [content, currentSlide, api, setDirection]);
|
||||||
|
|
||||||
const handleDragEnd = useCallback(
|
const handleDragEnd = useCallback(
|
||||||
(e, { offset, velocity }) => {
|
(
|
||||||
|
_: MouseEvent | TouchEvent | PointerEvent,
|
||||||
|
{ offset, velocity }: PanInfo,
|
||||||
|
) => {
|
||||||
const swipe = swipePower(offset.x, velocity.x);
|
const swipe = swipePower(offset.x, velocity.x);
|
||||||
if (
|
if (
|
||||||
currentSlide !== content.length - 1 &&
|
currentSlide !== content.length - 1 &&
|
||||||
@@ -147,6 +132,7 @@ const Carousel = ({
|
|||||||
drag={"x"}
|
drag={"x"}
|
||||||
dragConstraints={{ left: 0, right: 0 }}
|
dragConstraints={{ left: 0, right: 0 }}
|
||||||
dragElastic={1}
|
dragElastic={1}
|
||||||
|
//@ts-ignore
|
||||||
onDragEnd={handleDragEnd}
|
onDragEnd={handleDragEnd}
|
||||||
style={{
|
style={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "motion/react";
|
||||||
|
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Chip from "@mui/material/Chip";
|
import Chip from "@mui/material/Chip";
|
||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
@@ -17,6 +16,7 @@ import { getTypeIcon } from "../utils/iconsCollection";
|
|||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCarouselStore } from "@/utils/store/carousel";
|
import { useCarouselStore } from "@/utils/store/carousel";
|
||||||
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
@@ -24,7 +24,6 @@ import {
|
|||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
|
||||||
|
|
||||||
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -74,20 +73,20 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
className="hero-carousel-background-image"
|
className="hero-carousel-background-image"
|
||||||
src={
|
src={
|
||||||
item.ParentBackdropItemId
|
item.ParentBackdropItemId
|
||||||
? `${api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
|
? `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop?quality=80`
|
||||||
: `${api.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
|
: `${api?.basePath}/Items/${item.Id}/Images/Backdrop?quality=80&fillHeight=1400`
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.target.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
loading="eager"
|
loading="eager"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="hero-carousel-background-icon-container">
|
<div className="hero-carousel-background-icon-container">
|
||||||
{getTypeIcon(item.Type)}
|
{getTypeIcon(item.Type ?? "Movie")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -129,16 +128,16 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
item.Name
|
item.Name
|
||||||
) : (
|
) : (
|
||||||
<img
|
<img
|
||||||
alt={item.Name}
|
alt={item.Name ?? "Item"}
|
||||||
className="hero-carousel-text-logo"
|
className="hero-carousel-text-logo"
|
||||||
src={`${api.basePath}/Items/${item.Id}/Images/Logo?quality=90&tag=${item.ImageTags.Logo}`}
|
src={`${api?.basePath}/Items/${item.Id}/Images/Logo?quality=90&tag=${item.ImageTags.Logo}`}
|
||||||
style={{
|
style={{
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
transition: "opacity 0.2s",
|
transition: "opacity 0.2s",
|
||||||
objectFit: "contain",
|
objectFit: "contain",
|
||||||
}}
|
}}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.target.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -177,7 +176,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
>
|
>
|
||||||
{item.PremiereDate && (
|
{item.PremiereDate && (
|
||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{item.ProductionYear ?? ""}
|
{item.ProductionYear}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
{item.OfficialRating && (
|
{item.OfficialRating && (
|
||||||
@@ -240,15 +239,21 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{item.RunTimeTicks && (
|
{item.RunTimeTicks ? (
|
||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{getRuntime(item.RunTimeTicks)}
|
{getRuntime(item.RunTimeTicks)}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
)}
|
)}
|
||||||
{item.RunTimeTicks && (
|
{item.RunTimeTicks ? (
|
||||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||||
{endsAt(item.RunTimeTicks - item.UserData.PlaybackPositionTicks)}
|
{endsAt(
|
||||||
|
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
||||||
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
)}
|
)}
|
||||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||||
{item.Genres?.slice(0, 4).join(" / ")}
|
{item.Genres?.slice(0, 4).join(" / ")}
|
||||||
@@ -305,16 +310,14 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
>
|
>
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item}
|
item={item}
|
||||||
itemId={item.Id}
|
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
itemType={item.Type}
|
itemType={item.Type ?? "Movie"}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
currentSubTrack={0}
|
currentSubTrack={0}
|
||||||
currentVideoTrack={0}
|
currentVideoTrack={0}
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
size: "large",
|
size: "large",
|
||||||
}}
|
}}
|
||||||
itemUserData={item.UserData}
|
|
||||||
audio={
|
audio={
|
||||||
item.Type === BaseItemKind.MusicAlbum ||
|
item.Type === BaseItemKind.MusicAlbum ||
|
||||||
item.Type === BaseItemKind.Audio ||
|
item.Type === BaseItemKind.Audio ||
|
||||||
@@ -327,6 +330,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
size="large"
|
size="large"
|
||||||
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
endIcon={
|
endIcon={
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
class ErrorBoundary extends React.Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = { hasError: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
static getDerivedStateFromError(error) {
|
|
||||||
// Update state so the next render will show the fallback UI.
|
|
||||||
return { hasError: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidCatch(error, info) {
|
|
||||||
// Example "componentStack":
|
|
||||||
// in ComponentThatThrows (created by App)
|
|
||||||
// in ErrorBoundary (created by App)
|
|
||||||
// in div (created by App)
|
|
||||||
// in App
|
|
||||||
this.setState;
|
|
||||||
console.error(`Err in ${info} - ${error}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (this.state.hasError) {
|
|
||||||
// You can render any custom fallback UI
|
|
||||||
return this.props.fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.props.children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export default ErrorBoundary;
|
|
||||||
@@ -0,0 +1,509 @@
|
|||||||
|
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>
|
||||||
|
<DialogTitle>Filters</DialogTitle>
|
||||||
|
<DialogContent dividers>
|
||||||
|
<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={
|
||||||
|
<div className="material-symbols-rounded">expand_more</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<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={
|
||||||
|
<div className="material-symbols-rounded">expand_more</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<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={
|
||||||
|
<div className="material-symbols-rounded">expand_more</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<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={
|
||||||
|
<div className="material-symbols-rounded">expand_more</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<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={
|
||||||
|
<div className="material-symbols-rounded">expand_more</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<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"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
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>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<FiltersDialog open={open} onClose={() => setOpen(false)} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FiltersDialog;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Link, Typography } from "@mui/material";
|
import { Link, Typography } from "@mui/material";
|
||||||
import React from "react";
|
import React, { memo } from "react";
|
||||||
|
|
||||||
import anidbIcon from "../../assets/icons/anidb.png";
|
import anidbIcon from "../../assets/icons/anidb.png";
|
||||||
import anilistIcon from "../../assets/icons/anilist.svg";
|
import anilistIcon from "../../assets/icons/anilist.svg";
|
||||||
@@ -25,7 +25,7 @@ const knownIcons = [
|
|||||||
"kitsu",
|
"kitsu",
|
||||||
];
|
];
|
||||||
|
|
||||||
const IconLink = ({ name, url }: { name: string; url: string }) => {
|
const IconLink = memo(({ name, url }: { name: string; url: string }) => {
|
||||||
return (
|
return (
|
||||||
<Link target="_blank" href={url} className="item-detail-link">
|
<Link target="_blank" href={url} className="item-detail-link">
|
||||||
{name.toLocaleLowerCase() === "imdb" && <img src={imdbIcon} alt="IMDb" />}
|
{name.toLocaleLowerCase() === "imdb" && <img src={imdbIcon} alt="IMDb" />}
|
||||||
@@ -61,6 +61,6 @@ const IconLink = ({ name, url }: { name: string; url: string }) => {
|
|||||||
)}
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
export default IconLink;
|
export default IconLink;
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
import {
|
||||||
|
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">;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
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 (
|
||||||
|
<motion.img
|
||||||
|
alt={alt}
|
||||||
|
src={src}
|
||||||
|
className={className ?? "item-hero-backdrop"}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
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]);
|
||||||
|
|
||||||
|
if (!ready) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
alt={alt}
|
||||||
|
src={src}
|
||||||
|
className={className ?? "item-hero-backdrop"}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
onLoad?.(e);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ItemBackdropContent
|
||||||
|
targetRef={targetRef}
|
||||||
|
src={src}
|
||||||
|
alt={alt}
|
||||||
|
distance={distance}
|
||||||
|
className={className}
|
||||||
|
onLoad={onLoad}
|
||||||
|
motionProps={motionProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ItemBackdrop;
|
||||||
@@ -0,0 +1,319 @@
|
|||||||
|
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 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ItemHeader = ({
|
||||||
|
item,
|
||||||
|
api,
|
||||||
|
mediaQualityInfo,
|
||||||
|
scrollTargetRef,
|
||||||
|
children,
|
||||||
|
}: ItemHeaderProps) => {
|
||||||
|
return (
|
||||||
|
<div className="item-hero">
|
||||||
|
<div className="item-hero-backdrop-container">
|
||||||
|
{scrollTargetRef && (
|
||||||
|
<ItemBackdrop
|
||||||
|
targetRef={scrollTargetRef}
|
||||||
|
alt={item.Name ?? ""}
|
||||||
|
backdropSrc={
|
||||||
|
item.BackdropImageTags?.length
|
||||||
|
? api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
item.Id ?? "",
|
||||||
|
"Backdrop",
|
||||||
|
{ tag: item.BackdropImageTags[0] },
|
||||||
|
)
|
||||||
|
: 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">
|
||||||
|
{item.ImageTags?.Logo ? (
|
||||||
|
<img
|
||||||
|
alt={item.Name ?? ""}
|
||||||
|
src={
|
||||||
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(item.Id ?? "", "Logo", {
|
||||||
|
quality: 90,
|
||||||
|
fillWidth: 592,
|
||||||
|
fillHeight: 592,
|
||||||
|
tag: item.ImageTags.Logo,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
|
className="item-hero-logo"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Typography mb={2} fontWeight={200} variant="h2">
|
||||||
|
{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,98 @@
|
|||||||
|
@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;
|
||||||
|
transition: opacity $transition-time-default;
|
||||||
|
&-container {
|
||||||
|
filter: brightness(0.8);
|
||||||
|
position: absolute;
|
||||||
|
top: -4.4em;
|
||||||
|
left: -$page-margin;
|
||||||
|
width: 100vw;
|
||||||
|
height: calc(54vh + 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
height: 16em;
|
height: 16em;
|
||||||
box-shadow: $shadow-card-image;
|
box-shadow: $shadow-card-image;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
flex-shrink: 0;
|
||||||
&-icon {
|
&-icon {
|
||||||
color: rgb(255 255 255 / 0.5);
|
color: rgb(255 255 255 / 0.5);
|
||||||
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
|
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
|
||||||
|
|||||||
@@ -1,274 +0,0 @@
|
|||||||
import React, { useState } from "react";
|
|
||||||
|
|
||||||
import MuiLink from "@mui/material/Link";
|
|
||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
|
|
||||||
import { getRuntimeMusic } from "../../../utils/date/time";
|
|
||||||
|
|
||||||
import { SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { useAudioPlayback } from "../../../utils/store/audioPlayback";
|
|
||||||
import LikeButton from "../../buttons/likeButton";
|
|
||||||
import PlayButton from "../../buttons/playButton";
|
|
||||||
|
|
||||||
import TrackList from "../tracksList/index";
|
|
||||||
import "./albumArtist.scss";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { Link, useRouteContext } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
export const ArtistAlbum = ({ user, album, boxProps }) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
const albumTracks = useQuery({
|
|
||||||
queryKey: ["artist", "album", album.Id],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getItemsApi(api).getItems({
|
|
||||||
userId: user.Id,
|
|
||||||
parentId: album.Id,
|
|
||||||
sortOrder: SortOrder.Ascending,
|
|
||||||
sortBy: "IndexNumber",
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
|
|
||||||
networkMode: "always",
|
|
||||||
});
|
|
||||||
|
|
||||||
const [
|
|
||||||
currentTrackItem,
|
|
||||||
setCurrentAudioTrack,
|
|
||||||
setAudioUrl,
|
|
||||||
setAudioDisplay,
|
|
||||||
setAudioItem,
|
|
||||||
setAudioTracks,
|
|
||||||
] = useAudioPlayback((state) => [
|
|
||||||
state.item,
|
|
||||||
state.setCurrentTrack,
|
|
||||||
state.setUrl,
|
|
||||||
state.setDisplay,
|
|
||||||
state.setItem,
|
|
||||||
state.setTracks,
|
|
||||||
]);
|
|
||||||
const playTrack = (index) => {
|
|
||||||
setAudioTracks(albumTracks.data.Items);
|
|
||||||
setCurrentAudioTrack(index);
|
|
||||||
setAudioUrl(
|
|
||||||
`${api.basePath}/Audio/${albumTracks.data.Items[index].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${user.Id}&api_key=${api.accessToken}`,
|
|
||||||
);
|
|
||||||
setAudioItem(albumTracks.data.Items[index]);
|
|
||||||
setAudioDisplay(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{ marginBottom: "3em" }} {...boxProps}>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "row",
|
|
||||||
gap: "1em",
|
|
||||||
marginBottom: "1em",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!!album.ImageTags?.Primary && (
|
|
||||||
<div className="album-image">
|
|
||||||
<img
|
|
||||||
alt={album.Name}
|
|
||||||
src={`${api.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
height: "100%",
|
|
||||||
objectFit: "cover",
|
|
||||||
opacity: 0,
|
|
||||||
transition: "opacity 250ms",
|
|
||||||
position: "relative",
|
|
||||||
zIndex: 2,
|
|
||||||
}}
|
|
||||||
onLoad={(e) => (e.currentTarget.style.opacity = 1)}
|
|
||||||
/>
|
|
||||||
<div className="album-image-icon-container">
|
|
||||||
<span
|
|
||||||
className="material-symbols-rounded album-image-icon"
|
|
||||||
style={{ fontSize: "8em" }}
|
|
||||||
>
|
|
||||||
album
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div
|
|
||||||
className="flex flex-column"
|
|
||||||
style={{
|
|
||||||
alignItems: "flex-start",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
padding: "1em 0",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="flex flex-column">
|
|
||||||
<Typography
|
|
||||||
variant="h4"
|
|
||||||
fontWeight={300}
|
|
||||||
style={{ opacity: "0.6", mb: 1 }}
|
|
||||||
>
|
|
||||||
{album.ProductionYear}
|
|
||||||
</Typography>
|
|
||||||
<MuiLink
|
|
||||||
component={Link}
|
|
||||||
to="/album/$Id"
|
|
||||||
variant="h2"
|
|
||||||
color="inherit"
|
|
||||||
underline="hover"
|
|
||||||
>
|
|
||||||
{album.Name}
|
|
||||||
</MuiLink>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className=" flex flex-row"
|
|
||||||
style={{
|
|
||||||
gap: "1em",
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PlayButton
|
|
||||||
audio
|
|
||||||
itemId={album.Id}
|
|
||||||
itemType={album.Type}
|
|
||||||
itemUserData={album.UserData}
|
|
||||||
userId={user.Id}
|
|
||||||
buttonProps={{
|
|
||||||
color: "white",
|
|
||||||
style: {
|
|
||||||
color: "black ",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<LikeButton
|
|
||||||
itemName={album.Name}
|
|
||||||
key={album.Id}
|
|
||||||
queryKey={[
|
|
||||||
"item",
|
|
||||||
album.ParentBackdropItemId,
|
|
||||||
"artist",
|
|
||||||
"discography",
|
|
||||||
]}
|
|
||||||
isFavorite={album.UserData.IsFavorite}
|
|
||||||
itemId={album.Id}
|
|
||||||
itemType={album.Type}
|
|
||||||
itemUserData={album.UserData}
|
|
||||||
userId={user.Id}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{albumTracks.isSuccess && (
|
|
||||||
<TrackList user={user} tracks={albumTracks.data.Items} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
|
||||||
/* <div
|
|
||||||
key={0}
|
|
||||||
className="item-detail-album-track"
|
|
||||||
style={{
|
|
||||||
padding: "0.75em 0 ",
|
|
||||||
background: "rgb(0 0 0 / 0.6)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
fontWeight={400}
|
|
||||||
style={{
|
|
||||||
justifySelf: "end",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
#
|
|
||||||
</Typography>
|
|
||||||
<div />
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
style={{
|
|
||||||
justifySelf: "start",
|
|
||||||
}}
|
|
||||||
fontWeight={400}
|
|
||||||
>
|
|
||||||
Name
|
|
||||||
</Typography>
|
|
||||||
<span className="material-symbols-rounded">schedule</span>
|
|
||||||
</div>
|
|
||||||
{/*albumTracks.data.Items.map((track, index) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={track.Id}
|
|
||||||
className={
|
|
||||||
currentTrackItem.Id === track.Id &&
|
|
||||||
currentTrackItem.ParentId === track.ParentId
|
|
||||||
? "item-detail-album-track playing"
|
|
||||||
: "item-detail-album-track"
|
|
||||||
}
|
|
||||||
onClick={() => playTrack(index)}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
style={{
|
|
||||||
justifySelf: "end",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.IndexNumber ? track.IndexNumber : "-"}
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={["artist", "album", album.Id]}
|
|
||||||
userId={user.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
color={
|
|
||||||
currentTrackItem.Id === track.Id &&
|
|
||||||
currentTrackItem.ParentId === track.ParentId
|
|
||||||
? "hsl(337, 96%, 56%)"
|
|
||||||
: "white"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
style={{
|
|
||||||
justifySelf: "start",
|
|
||||||
}}
|
|
||||||
fontWeight={500}
|
|
||||||
>
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
{track.AlbumArtist === "Various Artists" && (
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
style={{
|
|
||||||
opacity: 0.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.ArtistItems.map((artist) => artist.Name).join(
|
|
||||||
", ",
|
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<Typography variant="subtitle1">
|
|
||||||
{getRuntimeMusic(track.RunTimeTicks)}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})*/
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
|
SortOrder,
|
||||||
|
type UserDto,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import LikeButton from "../../buttons/likeButton";
|
||||||
|
import PlayButton from "../../buttons/playButton";
|
||||||
|
|
||||||
|
import "./albumArtist.scss";
|
||||||
|
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { Link } from "@tanstack/react-router";
|
||||||
|
|
||||||
|
type ArtistAlbumProps = {
|
||||||
|
user: UserDto;
|
||||||
|
album: BaseItemDto;
|
||||||
|
boxProps?: object;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
||||||
|
const api = useApiInContext((s) => s.api);
|
||||||
|
const albumTracks = useQuery({
|
||||||
|
queryKey: ["artist", "album", album.Id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
const result = await getItemsApi(api).getItems({
|
||||||
|
userId: user.Id,
|
||||||
|
parentId: album.Id,
|
||||||
|
sortOrder: [SortOrder.Ascending],
|
||||||
|
sortBy: ["IndexNumber"],
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
networkMode: "always",
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ marginBottom: "3em" }} {...boxProps}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
gap: "1em",
|
||||||
|
marginBottom: "1em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{!!album.ImageTags?.Primary && (
|
||||||
|
<div className="album-image">
|
||||||
|
<img
|
||||||
|
alt={album.Name ?? "Album Image"}
|
||||||
|
src={`${api?.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
objectFit: "cover",
|
||||||
|
opacity: 0,
|
||||||
|
transition: "opacity 250ms",
|
||||||
|
position: "relative",
|
||||||
|
zIndex: 2,
|
||||||
|
}}
|
||||||
|
onLoad={(e) => {
|
||||||
|
e.currentTarget.style.opacity = "1";
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className="album-image-icon-container">
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded album-image-icon"
|
||||||
|
style={{ fontSize: "8em" }}
|
||||||
|
>
|
||||||
|
album
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
className="flex flex-column"
|
||||||
|
style={{
|
||||||
|
alignItems: "flex-start",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
padding: "1em 0",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="flex flex-column">
|
||||||
|
<Typography
|
||||||
|
variant="h5"
|
||||||
|
fontWeight={300}
|
||||||
|
style={{ opacity: "0.6" }}
|
||||||
|
>
|
||||||
|
{album.ProductionYear}
|
||||||
|
</Typography>
|
||||||
|
<Link
|
||||||
|
to="/album/$id"
|
||||||
|
params={{ id: album.Id ?? "" }}
|
||||||
|
style={{ color: "white", textDecoration: "none" }}
|
||||||
|
>
|
||||||
|
<Typography variant="h4" color="white">
|
||||||
|
{album.Name}
|
||||||
|
</Typography>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className=" flex flex-row"
|
||||||
|
style={{
|
||||||
|
gap: "1em",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PlayButton
|
||||||
|
audio
|
||||||
|
item={album}
|
||||||
|
itemType={album.Type ?? "MusicAlbum"}
|
||||||
|
userId={user.Id}
|
||||||
|
buttonProps={{
|
||||||
|
//@ts-ignore
|
||||||
|
color: "white",
|
||||||
|
style: {
|
||||||
|
color: "black ",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LikeButton
|
||||||
|
itemName={album.Name}
|
||||||
|
key={album.Id}
|
||||||
|
queryKey={[
|
||||||
|
"item",
|
||||||
|
album.ParentBackdropItemId ?? "",
|
||||||
|
"artist",
|
||||||
|
"discography",
|
||||||
|
]}
|
||||||
|
isFavorite={album.UserData?.IsFavorite}
|
||||||
|
itemId={album.Id}
|
||||||
|
userId={user.Id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{albumTracks.isSuccess && (albumTracks.data?.Items?.length ?? 0) > 0 && (
|
||||||
|
<div>
|
||||||
|
<div className="item-info-track header">
|
||||||
|
<span className="material-symbols-rounded index">tag</span>
|
||||||
|
<Typography variant="subtitle1">Title</Typography>
|
||||||
|
<Typography variant="subtitle1">Duration</Typography>
|
||||||
|
</div>
|
||||||
|
{albumTracks.data?.Items?.map((track, index) => (
|
||||||
|
<AlbumMusicTrack
|
||||||
|
track={track}
|
||||||
|
trackIndex={index}
|
||||||
|
musicTracks={albumTracks.data}
|
||||||
|
key={track.Id}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Card } from "../../card/card";
|
import { Card } from "../../card/card";
|
||||||
import { CardScroller } from "../../cardScroller/cardScroller";
|
import CardScroller from "../../cardScroller/cardScroller";
|
||||||
import { CardsSkeleton } from "../../skeleton/cards";
|
import { CardsSkeleton } from "../../skeleton/cards";
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,8 +21,9 @@ export const LatestMediaSection = ({
|
|||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
const fetchLatestMedia = async (library: BaseItemDto) => {
|
const fetchLatestMedia = async (library: BaseItemDto) => {
|
||||||
|
if (!api || !user?.Id) return null;
|
||||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||||
userId: user?.Id,
|
userId: user.Id,
|
||||||
parentId: library.Id,
|
parentId: library.Id,
|
||||||
limit: 16,
|
limit: 16,
|
||||||
fields: ["PrimaryImageAspectRatio", "ParentId"],
|
fields: ["PrimaryImageAspectRatio", "ParentId"],
|
||||||
@@ -39,10 +39,10 @@ export const LatestMediaSection = ({
|
|||||||
if (data.isPending) {
|
if (data.isPending) {
|
||||||
return <CardsSkeleton />;
|
return <CardsSkeleton />;
|
||||||
}
|
}
|
||||||
if (data.isSuccess && data.data.length >= 1) {
|
if (data.isSuccess && (data.data?.length ?? 0) >= 1) {
|
||||||
return (
|
return (
|
||||||
<CardScroller displayCards={7} title={`Latest ${latestMediaLib.Name}`}>
|
<CardScroller displayCards={7} title={`Latest ${latestMediaLib.Name}`}>
|
||||||
{data.data.map((item) => {
|
{data.data?.map((item) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
@@ -73,14 +73,8 @@ export const LatestMediaSection = ({
|
|||||||
? "square"
|
? "square"
|
||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={["home", "latestMedia", latestMediaLib.Id]}
|
queryKey={["home", "latestMedia", latestMediaLib.Id ?? ""]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
|
||||||
import { Card } from "../../../card/card";
|
|
||||||
import { CardScroller } from "../../../cardScroller/cardScroller";
|
|
||||||
|
|
||||||
const GenreView = ({ libraryId, genreId, genreName, userId }) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
|
|
||||||
const items = useQuery({
|
|
||||||
queryKey: ["library", "genreItem", genreId],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getItemsApi(api).getItems({
|
|
||||||
genreIds: [genreId],
|
|
||||||
parentId: libraryId,
|
|
||||||
userId: userId,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (items.isSuccess && items.data.Items.length > 0) {
|
|
||||||
return (
|
|
||||||
<div className="library-genre">
|
|
||||||
<CardScroller title={genreName} displayCards={8} disableDecoration>
|
|
||||||
{items.data.Items.map((item) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={item.Id}
|
|
||||||
item={item}
|
|
||||||
seriesId={item.SeriesId}
|
|
||||||
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.MusicAlbum ||
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
queryKey={["library", "genreItem", genreId]}
|
|
||||||
userId={userId}
|
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default GenreView;
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
// Types
|
|
||||||
import type { BaseItemDto, UserDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
|
|
||||||
import { getRuntimeMusic } from "../../../utils/date/time";
|
|
||||||
import { useAudioPlayback } from "../../../utils/store/audioPlayback";
|
|
||||||
import LikeButton from "../../buttons/likeButton";
|
|
||||||
import "./tracksList.scss";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
export default function TracksList({
|
|
||||||
tracks,
|
|
||||||
user,
|
|
||||||
queryKey,
|
|
||||||
}: { tracks: BaseItemDto[]; user: UserDto; queryKey: [] }) {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
|
|
||||||
const [
|
|
||||||
currentItem,
|
|
||||||
setCurrentAudioTrack,
|
|
||||||
setAudioUrl,
|
|
||||||
setAudioDisplay,
|
|
||||||
setAudioItem,
|
|
||||||
setAudioTracks,
|
|
||||||
] = useAudioPlayback((state) => [
|
|
||||||
state.item,
|
|
||||||
state.setCurrentTrack,
|
|
||||||
state.setUrl,
|
|
||||||
state.setDisplay,
|
|
||||||
state.setItem,
|
|
||||||
state.setTracks,
|
|
||||||
]);
|
|
||||||
const playTrack = (index: number) => {
|
|
||||||
setAudioTracks(tracks);
|
|
||||||
setCurrentAudioTrack(index);
|
|
||||||
setAudioUrl(
|
|
||||||
`${api.basePath}/Audio/${tracks[index].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${user.Id}&api_key=${api.accessToken}`,
|
|
||||||
);
|
|
||||||
setAudioItem(tracks[index]);
|
|
||||||
setAudioDisplay(true);
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div className="track-list">
|
|
||||||
<div className="track track-header">
|
|
||||||
<Typography variant="h6">#</Typography>
|
|
||||||
<div>{""}</div>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Name
|
|
||||||
</Typography>
|
|
||||||
<span className="material-symbols-rounded">schedule</span>
|
|
||||||
</div>
|
|
||||||
{tracks.map((track, index) => (
|
|
||||||
<div
|
|
||||||
className={currentItem?.Id === track.Id ? "track playing" : "track"}
|
|
||||||
key={track.Id}
|
|
||||||
onClick={() => playTrack(index)}
|
|
||||||
>
|
|
||||||
{currentItem?.Id === track.Id ? (
|
|
||||||
<span className="material-symbols-rounded ">equalizer</span>
|
|
||||||
) : (
|
|
||||||
<Typography>{track.IndexNumber ?? "-"}</Typography>
|
|
||||||
)}
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={queryKey}
|
|
||||||
userId={user.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
/>
|
|
||||||
<Typography
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography>{getRuntimeMusic(track?.RunTimeTicks)}</Typography>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
.track{
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 4% 1fr 80% 1fr;
|
|
||||||
align-items: center;
|
|
||||||
justify-items: center;
|
|
||||||
gap: 0.5em;
|
|
||||||
width: 100%;
|
|
||||||
transition: background $transition-time-default;
|
|
||||||
padding: 0.4em;
|
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.1);
|
|
||||||
cursor: pointer;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
&:hover{
|
|
||||||
background: rgb(255 255 255 / 0.1);
|
|
||||||
}
|
|
||||||
&.playing {
|
|
||||||
background: rgb(255 255 255 / 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
&-list {
|
|
||||||
background: rgb(0 0 0 / 0.4);
|
|
||||||
backdrop-filter: blur(5px);
|
|
||||||
border-radius: 20px;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.2);
|
|
||||||
margin-bottom: 2em;
|
|
||||||
}
|
|
||||||
&-header{
|
|
||||||
background: rgb(0 0 0 / 0.4) !important;
|
|
||||||
padding: 0.8em 0.4em;
|
|
||||||
}
|
|
||||||
> *:first-child {
|
|
||||||
justify-self: end;
|
|
||||||
}
|
|
||||||
&:last-child {
|
|
||||||
border-bottom: 0px solid !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,362 @@
|
|||||||
|
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 } 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 "./libraryHeader.scss";
|
||||||
|
import BackButton from "../buttons/backButton";
|
||||||
|
import { FiltersDialogTrigger } from "../filtersDialog";
|
||||||
|
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||||
|
|
||||||
|
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 handleNavigateToSearch = useCallback(
|
||||||
|
() => navigate({ to: "/search", search: { query: "" } }),
|
||||||
|
[navigate],
|
||||||
|
);
|
||||||
|
const handleNavigateToHome = useCallback(
|
||||||
|
() => navigate({ to: "/home" }),
|
||||||
|
[navigate],
|
||||||
|
);
|
||||||
|
const handleNavigateToFavorite = useCallback(
|
||||||
|
() => navigate({ to: "/favorite" }),
|
||||||
|
[navigate],
|
||||||
|
);
|
||||||
|
|
||||||
|
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 disabled>
|
||||||
|
<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}
|
||||||
|
>
|
||||||
|
{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}
|
||||||
|
>
|
||||||
|
{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={handleNavigateToSearch}>
|
||||||
|
<div className="material-symbols-rounded">search</div>
|
||||||
|
</IconButton>
|
||||||
|
<IconButton onClick={handleNavigateToFavorite}>
|
||||||
|
<div className="material-symbols-rounded">favorite</div>
|
||||||
|
</IconButton>
|
||||||
|
<UserAvatarMenu />
|
||||||
|
</div>
|
||||||
|
</AppBar>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
.library-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
inset: 1em 1em auto 1em !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;
|
||||||
|
backdrop-filter: blur(40px);
|
||||||
|
inset: -0.35em;
|
||||||
|
pointer-events: none;
|
||||||
|
border-radius: inherit;
|
||||||
|
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
||||||
|
background: rgb(0 0 0 / 0.4);
|
||||||
|
opacity: 0;
|
||||||
|
z-index: -1;
|
||||||
|
transition: opacity $transition-time-fast;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.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,65 @@
|
|||||||
|
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
|
||||||
|
style={{
|
||||||
|
borderRadius: "100px",
|
||||||
|
gap: "0.85em",
|
||||||
|
color: "white",
|
||||||
|
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-ignore /*}
|
||||||
|
<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>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -4,30 +4,16 @@ import { getRuntimeMusic } from "../../utils/date/time";
|
|||||||
import { useAudioPlayback } from "../../utils/store/audioPlayback";
|
import { useAudioPlayback } from "../../utils/store/audioPlayback";
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
import TextLink from "../textLink";
|
|
||||||
import "./musicTrack.scss";
|
import "./musicTrack.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import type { QueryKey } from "@tanstack/react-query";
|
import { Link } from "@tanstack/react-router";
|
||||||
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
* @property {Array} queryKey
|
|
||||||
* @property {string} userId
|
|
||||||
* @property {bool} playlistItem
|
|
||||||
* @property {number} trackIndex
|
|
||||||
* @property {string | undefined} playlistItemId
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Music Track element displayed in ArtistTitlePage and Songs library
|
* @description Music Track element displayed in ArtistTitlePage and Songs library
|
||||||
* @param {Props}
|
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const MusicTrack = ({
|
const MusicTrack = ({
|
||||||
item,
|
item,
|
||||||
queryKey,
|
queryKey,
|
||||||
@@ -37,8 +23,8 @@ const MusicTrack = ({
|
|||||||
trackIndex,
|
trackIndex,
|
||||||
className = "",
|
className = "",
|
||||||
}: {
|
}: {
|
||||||
item?: BaseItemDto | null;
|
item: BaseItemDto;
|
||||||
queryKey?: QueryKey;
|
queryKey: string[];
|
||||||
userId?: string | undefined;
|
userId?: string | undefined;
|
||||||
playlistItem?: boolean;
|
playlistItem?: boolean;
|
||||||
playlistItemId?: string;
|
playlistItemId?: string;
|
||||||
@@ -60,16 +46,21 @@ const MusicTrack = ({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<img
|
<img
|
||||||
alt={item.Name}
|
alt={item.Name ?? "Music Track"}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={
|
||||||
Object.keys(item.ImageTags).length === 0 ? item.AlbumId : item.Id,
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
(Object.keys(item.ImageTags ?? {}).length === 0
|
||||||
|
? item.AlbumId
|
||||||
|
: item.Id) ?? "",
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
quality: 70,
|
quality: 70,
|
||||||
fillHeight: 128,
|
fillHeight: 128,
|
||||||
fillWidth: 128,
|
fillWidth: 128,
|
||||||
},
|
},
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
@@ -77,14 +68,14 @@ const MusicTrack = ({
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
}}
|
}}
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
e.target.style.opacity = 1;
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="music-track-image-overlay">
|
<div className="music-track-image-overlay">
|
||||||
<PlayButton
|
<PlayButton
|
||||||
itemId={item.Id}
|
item={item}
|
||||||
|
itemType="Audio"
|
||||||
userId={userId}
|
userId={userId}
|
||||||
itemType={item.Type}
|
|
||||||
size="small"
|
size="small"
|
||||||
iconOnly
|
iconOnly
|
||||||
audio
|
audio
|
||||||
@@ -119,21 +110,26 @@ const MusicTrack = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{item.ArtistItems?.map((artist, index) => (
|
{item.ArtistItems?.map((artist, index) => (
|
||||||
<>
|
<span
|
||||||
<TextLink
|
style={{ display: "inline-flex", alignItems: "center" }}
|
||||||
key={index}
|
key={artist.Id}
|
||||||
variant={"subtitle2"}
|
>
|
||||||
location={`/artist/${artist.Id}`}
|
<Typography
|
||||||
otherProps={{
|
variant="subtitle2"
|
||||||
fontWeight: 400,
|
fontWeight="400"
|
||||||
style: {
|
style={{
|
||||||
textDecoration: "none",
|
textDecoration: "none",
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
style={{ textDecoration: "none", color: "white" }}
|
||||||
|
to="/artist/$id"
|
||||||
|
params={{ id: artist.Id ?? "" }}
|
||||||
>
|
>
|
||||||
{artist.Name}
|
{artist.Name}
|
||||||
</TextLink>
|
</Link>
|
||||||
{index !== item.ArtistItems.length - 1 && (
|
</Typography>
|
||||||
|
{index !== (item.ArtistItems?.length ?? 0) - 1 && (
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
whiteSpace: "pre",
|
whiteSpace: "pre",
|
||||||
@@ -142,12 +138,12 @@ const MusicTrack = ({
|
|||||||
,{" "}
|
,{" "}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Typography variant="subtitl1">
|
<Typography variant="subtitle1">
|
||||||
{getRuntimeMusic(item.RunTimeTicks)}
|
{getRuntimeMusic(item.RunTimeTicks ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
|
|||||||
@@ -1,27 +1,40 @@
|
|||||||
import { LinearProgress } from "@mui/material";
|
import { LinearProgress } from "@mui/material";
|
||||||
import { useNProgress } from "@tanem/react-nprogress";
|
import { useNProgress } from "@tanem/react-nprogress";
|
||||||
import React from "react";
|
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
||||||
|
import { useRouterState } from "@tanstack/react-router";
|
||||||
|
import React, { useMemo } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
|
||||||
|
export default function NProgress() {
|
||||||
|
const isQueryFetching = useIsFetching();
|
||||||
|
const isMutating = useIsMutating();
|
||||||
|
const routeIsLoading = useRouterState().isLoading;
|
||||||
|
|
||||||
|
const isAnimating = useMemo(() => {
|
||||||
|
if (isQueryFetching || isMutating || routeIsLoading) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, [isQueryFetching, isMutating, routeIsLoading]);
|
||||||
|
|
||||||
const NProgress: React.FC<{ isAnimating: boolean | number }> = ({
|
|
||||||
isAnimating,
|
|
||||||
}) => {
|
|
||||||
const { animationDuration, isFinished, progress } = useNProgress({
|
const { animationDuration, isFinished, progress } = useNProgress({
|
||||||
isAnimating,
|
isAnimating,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isAnimating) {
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
pointerEvents: "none",
|
pointerEvents: "none",
|
||||||
transition: `opacity ${animationDuration}ms linear`,
|
transition: "opacity 250ms linear",
|
||||||
position: "fixed",
|
position: "fixed",
|
||||||
top: "0",
|
top: "0",
|
||||||
left: "0",
|
left: "0",
|
||||||
right: "0",
|
right: "0",
|
||||||
zIndex: "10001",
|
zIndex: "10001",
|
||||||
|
opacity: isFinished ? 0 : 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{isAnimating && (
|
||||||
<LinearProgress
|
<LinearProgress
|
||||||
sx={{
|
sx={{
|
||||||
height: 3,
|
height: 3,
|
||||||
@@ -30,9 +43,8 @@ const NProgress: React.FC<{ isAnimating: boolean | number }> = ({
|
|||||||
value={progress * 100}
|
value={progress * 100}
|
||||||
variant="determinate"
|
variant="determinate"
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NProgress;
|
|
||||||
+1
-1
@@ -4,7 +4,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import { yellow } from "@mui/material/colors";
|
import { yellow } from "@mui/material/colors";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const EmptyNotice = ({ extraMsg }) => {
|
export const EmptyNotice = ({ extraMsg }: { extraMsg?: string }) => {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -42,12 +42,14 @@ export const ErrorNotice = ({ error }: { error?: Error }) => {
|
|||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
border: "2px dashed rgb(255 255 255 / 0.5)",
|
border: "2px dashed rgb(255 255 255 / 0.5)",
|
||||||
maxWidth: "40em",
|
maxWidth: "40em",
|
||||||
|
maxHeight: "20em",
|
||||||
|
overflow: "auto",
|
||||||
marginTop: "1em",
|
marginTop: "1em",
|
||||||
// opacity: 0.6,
|
// opacity: 0.6,
|
||||||
}}
|
}}
|
||||||
color="gray"
|
color="gray"
|
||||||
>
|
>
|
||||||
{JSON.stringify(error?.message)}
|
{JSON.stringify(error?.stack)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { playItemFromQueue, usePlaybackStore } from "@/utils/store/playback";
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
import useQueue from "@/utils/store/queue";
|
import useQueue from "@/utils/store/queue";
|
||||||
import { Button, Typography } from "@mui/material";
|
import { Button, Typography } from "@mui/material";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
@@ -7,8 +7,8 @@ import { getTypeIcon } from "../utils/iconsCollection";
|
|||||||
|
|
||||||
import "./outroCard.scss";
|
import "./outroCard.scss";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
|
||||||
const OutroCard = (props: { handleShowCredits: () => void }) => {
|
const OutroCard = (props: { handleShowCredits: () => void }) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
@@ -16,19 +16,14 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
s.currentItemIndex,
|
s.currentItemIndex,
|
||||||
s.tracks,
|
s.tracks,
|
||||||
]);
|
]);
|
||||||
const item = queueItems[nextItemIndex + 1];
|
const item = queueItems?.[nextItemIndex + 1];
|
||||||
const user = useQuery({
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
queryKey: ["user"],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getUserApi(api).getCurrentUser();
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const handlePlayNext = useMutation({
|
const handlePlayNext = useMutation({
|
||||||
mutationKey: ["playNextButton"],
|
mutationKey: ["playNextButton"],
|
||||||
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
mutationFn: () => playItemFromQueue("next", user?.Id, api),
|
||||||
onError: (error) => [console.error(error)],
|
onError: (error) => [console.error(error)],
|
||||||
});
|
});
|
||||||
|
if (!item || !item.Type) return null;
|
||||||
return (
|
return (
|
||||||
<div className="outro-card">
|
<div className="outro-card">
|
||||||
<Typography variant="h4">Up Next</Typography>
|
<Typography variant="h4">Up Next</Typography>
|
||||||
@@ -37,14 +32,21 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
<img
|
<img
|
||||||
className="outro-card-content-image"
|
className="outro-card-content-image"
|
||||||
alt={item.Name ?? "Cover"}
|
alt={item.Name ?? "Cover"}
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(item.Id, "Primary", {
|
src={
|
||||||
|
api &&
|
||||||
|
getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
item.Id ?? "",
|
||||||
|
"Primary",
|
||||||
|
{
|
||||||
tag: item.ImageTags.Primary,
|
tag: item.ImageTags.Primary,
|
||||||
quality: 80,
|
quality: 80,
|
||||||
})}
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="outro-card-content-image icon">
|
<div className="outro-card-content-image icon">
|
||||||
{getTypeIcon(item?.Type)}
|
{getTypeIcon(item.Type)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Typography variant="h5" className="outro-card-content-title">
|
<Typography variant="h5" className="outro-card-content-title">
|
||||||
@@ -56,6 +58,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
<div className="outro-card-content-buttons">
|
<div className="outro-card-content-buttons">
|
||||||
<Button
|
<Button
|
||||||
onClick={handlePlayNext.mutate}
|
onClick={handlePlayNext.mutate}
|
||||||
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
startIcon={
|
startIcon={
|
||||||
@@ -74,6 +77,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={props.handleShowCredits}
|
onClick={props.handleShowCredits}
|
||||||
|
//@ts-ignore
|
||||||
color="white"
|
color="white"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
&-image {
|
&-image {
|
||||||
grid-area: img;
|
grid-area: img;
|
||||||
max-height: 14em;
|
aspect-ratio: 16/9;
|
||||||
width: 20em;
|
width: 20em;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
border-radius: $border-radius-default;
|
border-radius: $border-radius-default;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||||
|
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "motion/react";
|
||||||
|
|
||||||
import Fab from "@mui/material/Fab";
|
import Fab from "@mui/material/Fab";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
@@ -10,7 +10,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import { setAudioRef, useAudioPlayback } from "@/utils/store/audioPlayback";
|
import { setAudioRef, useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||||
import useQueue from "@/utils/store/queue";
|
import useQueue from "@/utils/store/queue";
|
||||||
|
|
||||||
import { AnimatePresence } from "framer-motion";
|
import { AnimatePresence } from "motion/react";
|
||||||
import "./audioPlayer.scss";
|
import "./audioPlayer.scss";
|
||||||
|
|
||||||
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
||||||
@@ -22,13 +22,12 @@ import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { playItemFromQueue } from "@/utils/store/playback";
|
import { playItemFromQueue } from "@/utils/store/playback";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
const AudioPlayer = () => {
|
const AudioPlayer = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const audioRef = useRef<HTMLAudioElement>(null!);
|
|
||||||
|
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||||
const [url, display, item] = useAudioPlayback((state) => [
|
const [url, display, item] = useAudioPlayback((state) => [
|
||||||
state.url,
|
state.url,
|
||||||
state.display,
|
state.display,
|
||||||
@@ -46,15 +45,12 @@ const AudioPlayer = () => {
|
|||||||
if (audioRef.current?.paused) return false;
|
if (audioRef.current?.paused) return false;
|
||||||
return true;
|
return true;
|
||||||
}, [audioRef.current?.paused]);
|
}, [audioRef.current?.paused]);
|
||||||
const [playerReady, setPlayerReady] = useState(false);
|
|
||||||
const [volume, setVolume] = useState(0.8);
|
const [volume, setVolume] = useState(0.8);
|
||||||
const [isMuted, setIsMuted] = useState(false);
|
const [isMuted, setIsMuted] = useState(false);
|
||||||
const [progress, setProgress] = useState(0);
|
const [progress, setProgress] = useState(0);
|
||||||
const [isScrubbing, setIsScrubbing] = useState(false);
|
const [isScrubbing, setIsScrubbing] = useState(false);
|
||||||
const [sliderProgress, setSliderProgress] = useState(0);
|
const [sliderProgress, setSliderProgress] = useState(0);
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (display) {
|
if (display) {
|
||||||
// const audioUrlRequest = new Request(audioRef.current?.dataset.src, {
|
// const audioUrlRequest = new Request(audioRef.current?.dataset.src, {
|
||||||
@@ -82,7 +78,7 @@ const AudioPlayer = () => {
|
|||||||
|
|
||||||
const info = useMemo(
|
const info = useMemo(
|
||||||
() =>
|
() =>
|
||||||
!!api?.configuration && (
|
api && (
|
||||||
<div
|
<div
|
||||||
// initial={{
|
// initial={{
|
||||||
// filter: "opacity(0)",
|
// filter: "opacity(0)",
|
||||||
@@ -100,7 +96,7 @@ const AudioPlayer = () => {
|
|||||||
alt={tracks?.[currentTrack]?.Name ?? "track"}
|
alt={tracks?.[currentTrack]?.Name ?? "track"}
|
||||||
className="audio-player-image"
|
className="audio-player-image"
|
||||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
src={getImageUrlsApi(api).getItemImageUrlById(
|
||||||
(!item?.ImageTags?.Primary ? item?.AlbumId : item?.Id) ?? "",
|
(!item?.ImageTags?.Primary ? item?.AlbumId : item.Id) ?? "",
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
quality: 85,
|
quality: 85,
|
||||||
@@ -152,9 +148,9 @@ const AudioPlayer = () => {
|
|||||||
<Fab
|
<Fab
|
||||||
size="small"
|
size="small"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
audioRef.current.paused
|
audioRef.current?.paused
|
||||||
? audioRef.current.play()
|
? audioRef.current.play()
|
||||||
: audioRef.current.pause()
|
: audioRef.current?.pause()
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -170,7 +166,7 @@ const AudioPlayer = () => {
|
|||||||
<PlayNextButton />
|
<PlayNextButton />
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
[tracks?.[currentTrack]?.Id, loading, playing, tracks?.length],
|
[tracks?.[currentTrack]?.Id, playing, tracks?.length],
|
||||||
);
|
);
|
||||||
|
|
||||||
const buttons = useMemo(
|
const buttons = useMemo(
|
||||||
@@ -187,7 +183,7 @@ const AudioPlayer = () => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
<QueueButton />
|
<QueueButton />
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={(e) => {
|
onClick={() => {
|
||||||
setIsMuted(!isMuted);
|
setIsMuted(!isMuted);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -200,7 +196,13 @@ const AudioPlayer = () => {
|
|||||||
step={1}
|
step={1}
|
||||||
max={100}
|
max={100}
|
||||||
onChange={(_, newVal) => {
|
onChange={(_, newVal) => {
|
||||||
Array.isArray(newVal) ? setVolume(newVal[0] / 100) : setVolume(newVal / 100);
|
if (!audioRef.current) {
|
||||||
|
console.error("Audio ref not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Array.isArray(newVal)
|
||||||
|
? setVolume(newVal[0] / 100)
|
||||||
|
: setVolume(newVal / 100);
|
||||||
if (Array.isArray(newVal)) {
|
if (Array.isArray(newVal)) {
|
||||||
audioRef.current.volume = newVal[0] / 100;
|
audioRef.current.volume = newVal[0] / 100;
|
||||||
} else {
|
} else {
|
||||||
@@ -248,13 +250,14 @@ const AudioPlayer = () => {
|
|||||||
[volume, isMuted, currentTrack],
|
[volume, isMuted, currentTrack],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (audioRef.current) {
|
// if (audioRef.current) {
|
||||||
audioRef.current.addEventListener("ended", () => {
|
// audioRef.current.addEventListener("change", () => {
|
||||||
if (tracks?.[currentTrack + 1]?.Id) {
|
// console.log("Audio Player changed state : ", currentTrack);
|
||||||
playItemFromQueue("next", user?.Id, api);
|
// });
|
||||||
}
|
// audioRef.current.addEventListener("ended", () => {
|
||||||
});
|
|
||||||
}
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AnimatePresence mode="sync">
|
<AnimatePresence mode="sync">
|
||||||
@@ -286,10 +289,15 @@ const AudioPlayer = () => {
|
|||||||
autoPlay
|
autoPlay
|
||||||
src={url}
|
src={url}
|
||||||
ref={audioRef}
|
ref={audioRef}
|
||||||
key={item?.Id}
|
key={item?.Id ?? "noItem"}
|
||||||
onTimeUpdate={(e) =>
|
onTimeUpdate={(e) =>
|
||||||
setProgress(secToTicks(e.currentTarget.currentTime))
|
setProgress(secToTicks(e.currentTarget.currentTime))
|
||||||
}
|
}
|
||||||
|
onEnded={() => {
|
||||||
|
if (tracks?.[currentTrack + 1]?.Id && api && user?.Id) {
|
||||||
|
playItemFromQueue("next", user.Id, api);
|
||||||
|
}
|
||||||
|
}}
|
||||||
id="audio-player"
|
id="audio-player"
|
||||||
/>
|
/>
|
||||||
<div className="audio-player-controls">
|
<div className="audio-player-controls">
|
||||||
@@ -324,8 +332,12 @@ const AudioPlayer = () => {
|
|||||||
: setSliderProgress(value);
|
: setSliderProgress(value);
|
||||||
}}
|
}}
|
||||||
onChangeCommitted={(_, value) => {
|
onChangeCommitted={(_, value) => {
|
||||||
|
if (!audioRef.current) {
|
||||||
|
console.error("Audio ref not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
setIsScrubbing(false);
|
setIsScrubbing(false);
|
||||||
// console.log(ticksToSec(value * item?.RunTimeTicks));
|
// console.log(ticksToSec(value * item.RunTimeTicks));
|
||||||
Array.isArray(value)
|
Array.isArray(value)
|
||||||
? setProgress(value[0])
|
? setProgress(value[0])
|
||||||
: setProgress(value);
|
: setProgress(value);
|
||||||
|
|||||||
@@ -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.isDirectPlay ? "Direct Play" : "Transcoding"}</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 = {
|
||||||
|
background: `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,59 @@
|
|||||||
|
import { Button } from "@mui/material";
|
||||||
|
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,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!mediaSegments?.Items?.length ||
|
||||||
|
currentSegmentIndex < 0 ||
|
||||||
|
!activeSegmentId ||
|
||||||
|
mediaSegments?.Items?.[currentSegmentIndex].Type === "Outro"
|
||||||
|
) {
|
||||||
|
return null; // No segments to skip
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
size="large"
|
||||||
|
//@ts-ignore
|
||||||
|
color="white"
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
bottom:
|
||||||
|
isUserHovering || !isPlayerPlaying || isUserSeeking ? "18vh" : "2em",
|
||||||
|
right: "2em",
|
||||||
|
transition: "bottom 0.3s ease-in-out",
|
||||||
|
zIndex: 10000,
|
||||||
|
}}
|
||||||
|
onClick={skipSegment}
|
||||||
|
>
|
||||||
|
Skip {mediaSegments?.Items?.[currentSegmentIndex].Type}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loaded 100 of 205 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user