fix(ui): unify titlebar and playback state
- window buttons live in the page header on library/search pages and in a shared chrome strip where a page has no header; removed the 44px root padding toggle that made pages jump on navigation - video player gets its own titlebar row with window controls; the audio player hides the global app bar - starting a video stops music and vice versa; a single track queues the rest of its album, or the artist's songs when AlbumId is missing - album page no longer crashes on albums without AlbumArtists - queue summary is localized
This commit is contained in:
1 parent
d9bce4de04
commit
fcf61012db
13 files changed
+245
-171
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import {
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
SortOrder,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getShowApi } from "@jellyfin/sdk/lib/utils/api/show-api";
|
||||
import type { SxProps } from "@mui/material";
|
||||
import Button, { type ButtonProps } from "@mui/material/Button";
|
||||
@@ -131,6 +134,7 @@ const PlayButton = ({
|
||||
|
||||
if (audio) {
|
||||
// Album/Individual audio track playback
|
||||
const playedItem = result?.item?.Items?.[0];
|
||||
const playbackUrl = generateAudioStreamUrl(
|
||||
result?.item?.Items?.[0].Id,
|
||||
userId,
|
||||
@@ -139,7 +143,68 @@ const PlayButton = ({
|
||||
api.accessToken,
|
||||
);
|
||||
playAudio(playbackUrl, result?.item?.Items?.[0], undefined);
|
||||
setQueue(result?.item?.Items ?? [], 0);
|
||||
|
||||
if (
|
||||
playedItem?.Type === BaseItemKind.Audio &&
|
||||
(result?.item?.Items?.length ?? 0) <= 1
|
||||
) {
|
||||
// A single track has no queue of its own. Queue the record it
|
||||
// belongs to; when the server does not expose AlbumId, fall
|
||||
// back to the artist's songs so "Очередь" is never empty.
|
||||
const loadQueue = async (): Promise<{
|
||||
items: BaseItemDto[];
|
||||
index: number;
|
||||
}> => {
|
||||
if (playedItem.AlbumId) {
|
||||
const albumTracks = await getLibraryApi(api).getItems({
|
||||
parentId: playedItem.AlbumId,
|
||||
userId,
|
||||
sortOrder: [SortOrder.Ascending],
|
||||
sortBy: ["IndexNumber"],
|
||||
fields: [ItemFields.MediaSources],
|
||||
});
|
||||
const items = albumTracks.data.Items ?? [];
|
||||
if (items.length > 0) {
|
||||
return {
|
||||
items,
|
||||
index: Math.max(
|
||||
items.findIndex((t) => t.Id === playedItem.Id),
|
||||
0,
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
const artistName =
|
||||
playedItem.Artists?.[0] ?? playedItem.AlbumArtists?.[0]?.Name;
|
||||
if (artistName) {
|
||||
const artistTracks = await getLibraryApi(api).getItems({
|
||||
userId,
|
||||
includeItemTypes: [BaseItemKind.Audio],
|
||||
artists: [artistName],
|
||||
recursive: true,
|
||||
sortBy: ["SortName"],
|
||||
sortOrder: [SortOrder.Ascending],
|
||||
fields: [ItemFields.MediaSources],
|
||||
});
|
||||
const items = artistTracks.data.Items ?? [];
|
||||
const index = items.findIndex((t) => t.Id === playedItem.Id);
|
||||
if (items.length > 1 && index >= 0) {
|
||||
return { items, index };
|
||||
}
|
||||
}
|
||||
return { items: [playedItem], index: 0 };
|
||||
};
|
||||
|
||||
try {
|
||||
const nextQueue = await loadQueue();
|
||||
setQueue(nextQueue.items, nextQueue.index);
|
||||
} catch (error) {
|
||||
console.warn("Could not build the audio queue", error);
|
||||
setQueue([playedItem], 0);
|
||||
}
|
||||
} else {
|
||||
setQueue(result?.item?.Items ?? [], 0);
|
||||
}
|
||||
} else if (item.Type === "Photo") {
|
||||
const index = result?.item?.Items?.map((i) => i.Id).indexOf(item.Id);
|
||||
if (result?.item?.Items && index) {
|
||||
|
||||
Reference in new issue
Block a user