diff --git a/src/components/buttons/playButton.tsx b/src/components/buttons/playButton.tsx
index 40b44fe..9a5adf2 100644
--- a/src/components/buttons/playButton.tsx
+++ b/src/components/buttons/playButton.tsx
@@ -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) {
diff --git a/src/components/libraryHeader/index.tsx b/src/components/libraryHeader/index.tsx
index b482a2f..25776f3 100644
--- a/src/components/libraryHeader/index.tsx
+++ b/src/components/libraryHeader/index.tsx
@@ -25,6 +25,7 @@ import BackButton from "../buttons/backButton";
import CastButton from "../buttons/castButton";
import { FiltersDialogTrigger } from "../filtersDialog";
import { UserAvatarMenu } from "../userAvatarMenu";
+import WindowControls from "../windowControls";
import "./libraryHeader.scss";
const route = getRouteApi("/_api/library/$id");
@@ -417,6 +418,7 @@ export const LibraryHeader = () => {
favorite
+
diff --git a/src/components/playback/videoPlayer/controls.scss b/src/components/playback/videoPlayer/controls.scss
index 70f0bb6..3225e0c 100644
--- a/src/components/playback/videoPlayer/controls.scss
+++ b/src/components/playback/videoPlayer/controls.scss
@@ -20,13 +20,24 @@
--media-object-fit: fill;
}
- &-drag-region {
+ &-titlebar {
position: absolute;
inset: 0 0 auto;
- height: 38px;
- z-index: 4;
- cursor: default;
+ z-index: 3;
+ display: flex;
+ align-items: center;
+ gap: 0.75em;
+ padding: 4px 8px;
+ min-height: 46px;
user-select: none;
+
+ &-end {
+ display: flex;
+ align-items: center;
+ gap: 0.5em;
+ margin-left: auto;
+ min-width: 0;
+ }
}
&-osd {
@@ -53,22 +64,16 @@
}
&-back,
&-actions {
- position: absolute;
- top: 2em;
- z-index: 3;
display: flex;
align-items: center;
+ flex: 0 0 auto;
padding: 0.3em;
border-radius: 999px;
border: 1px solid rgb(255 255 255 / 0.08);
background: rgb(0 0 0 / 0.28);
backdrop-filter: blur(12px);
}
- &-back {
- left: 3em;
- }
&-actions {
- right: 3em;
gap: 0.35em;
}
&-info {
@@ -117,4 +122,27 @@
border: 1.2px solid rgb(255 255 255 / 0.1);
}
}
+}
+
+// The window is frameless outside macOS: the player draws the titlebar row and
+// the window buttons in the same strip the rest of the app uses on Windows and
+// Linux, so they sit on the window edge instead of floating over the picture.
+// macOS keeps its native traffic lights inside the overlay titlebar, so the
+// player only has to clear them.
+html.is-macos .video-player-titlebar {
+ padding-left: 84px;
+ padding-top: 14px;
+ min-height: 60px;
+}
+
+html.is-macos .video-player-titlebar.is-fullscreen {
+ padding-left: 8px;
+ padding-top: 4px;
+ min-height: 46px;
+}
+
+// A faded-out OSD keeps its buttons clickable otherwise; the titlebar would
+// then catch clicks in the top corners while invisible.
+.video-player-osd:not(.hovering) .video-player-titlebar {
+ pointer-events: none;
}
\ No newline at end of file
diff --git a/src/components/playback/videoPlayer/controls.tsx b/src/components/playback/videoPlayer/controls.tsx
index f80862d..209f6bc 100644
--- a/src/components/playback/videoPlayer/controls.tsx
+++ b/src/components/playback/videoPlayer/controls.tsx
@@ -15,9 +15,9 @@ 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 WindowControls from "@/components/windowControls";
import { secToTicks, ticksToSec } from "@/utils/date/time";
import { buildPlayDeepLink } from "@/utils/deepLinks";
-import { getPlayerVideoElement } from "@/utils/methods/pictureInPicture";
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
import { useApiInContext } from "@/utils/store/api";
import { useShareStore } from "@/utils/store/share";
@@ -88,6 +88,7 @@ const VideoPlayerControls = ({
isPlayerPlaying,
toggleIsPlaying,
toggleIsPlayerFullscreen,
+ isPlayerFullscreen,
isUserSeeking,
// seekValue,
isPlayerMuted,
@@ -112,6 +113,7 @@ const VideoPlayerControls = ({
playsessionId: state.playsessionId,
toggleIsPlaying: state.toggleIsPlaying,
toggleIsPlayerFullscreen: state.toggleIsPlayerFullscreen,
+ isPlayerFullscreen: state.playerState.isPlayerFullscreen,
isUserSeeking: state.playerState.isUserSeeking,
seekValue: state.playerState.seekValue,
isPlayerMuted: state.playerState.isPlayerMuted,
@@ -153,69 +155,6 @@ const VideoPlayerControls = ({
const [settingsMenuRef, setSettingsMenuRef] =
useState(null);
- const [videoFrame, setVideoFrame] = useState<{
- top: number;
- left: number;
- right: number;
- } | null>(null);
-
- // Keep the back button and the top action buttons on one line inside the
- // visible video area, below any letterbox bars.
- useEffect(() => {
- let frame = 0;
- const update = () => {
- const video = getPlayerVideoElement();
- if (!video) return;
-
- const rect = video.getBoundingClientRect();
- const ratio =
- video.videoWidth > 0 && video.videoHeight > 0
- ? video.videoWidth / video.videoHeight
- : null;
- const contentWidth = ratio
- ? Math.min(rect.width, rect.height * ratio)
- : rect.width;
- const contentHeight = ratio ? contentWidth / ratio : rect.height;
- const contentLeft = rect.left + (rect.width - contentWidth) / 2;
- const contentTop = rect.top + (rect.height - contentHeight) / 2;
-
- setVideoFrame((current) => {
- const next = {
- // 14% keeps the controls inside the picture even when the
- // file has letterbox bars baked into a 16:9 frame.
- top: Math.round(
- contentTop + Math.max(28, contentHeight * 0.14),
- ),
- left: Math.round(contentLeft + 24),
- right: Math.round(
- window.innerWidth - contentLeft - contentWidth + 24,
- ),
- };
- return current?.top === next.top &&
- current?.left === next.left &&
- current?.right === next.right
- ? current
- : next;
- });
- };
- const schedule = () => {
- cancelAnimationFrame(frame);
- frame = requestAnimationFrame(update);
- };
-
- schedule();
- const video = getPlayerVideoElement();
- video?.addEventListener("loadedmetadata", schedule);
- window.addEventListener("resize", schedule);
- const interval = window.setInterval(schedule, 1000);
-
- return () => {
- cancelAnimationFrame(frame);
- window.clearInterval(interval);
- video?.removeEventListener("loadedmetadata", schedule);
- window.removeEventListener("resize", schedule);
- };
- }, [playsessionId]);
// const creditInfo = mediaSegments?.Items?.find(
// (segment) => segment.Type === "Outro",
@@ -301,64 +240,60 @@ const VideoPlayerControls = ({
}}
>
-
- arrow_back
-
-
-
-
- useShareStore
- .getState()
- .openShareDialog(
- buildPlayDeepLink(
- itemId ?? "",
- currentTime > 0 ? ticksToSec(currentTime) : getCurrentTime(),
- ),
- "Поделиться этой сценой",
- )
- }
- aria-label="Поделиться сценой"
- title="Поделиться сценой"
- >
- share
-
-
- groups
-
-
setSettingsMenuRef(e.currentTarget)}
- aria-label="Настройки плеера"
- title="Настройки плеера"
- >
- settings
-
-
setSettingsMenuRef(null)}
- />
+
+
+ arrow_back
+
+
+
+
+
+ useShareStore
+ .getState()
+ .openShareDialog(
+ buildPlayDeepLink(
+ itemId ?? "",
+ currentTime > 0
+ ? ticksToSec(currentTime)
+ : getCurrentTime(),
+ ),
+ "Поделиться этой сценой",
+ )
+ }
+ aria-label="Поделиться сценой"
+ title="Поделиться сценой"
+ >
+ share
+
+
+ groups
+
+ setSettingsMenuRef(e.currentTarget)}
+ aria-label="Настройки плеера"
+ title="Настройки плеера"
+ >
+ settings
+
+ setSettingsMenuRef(null)}
+ />
+
+ {!isPlayerFullscreen &&
}
+
diff --git a/src/components/queue/queueView.tsx b/src/components/queue/queueView.tsx
index 24f3e35..d5e1a0d 100644
--- a/src/components/queue/queueView.tsx
+++ b/src/components/queue/queueView.tsx
@@ -132,9 +132,19 @@ const QueueView = ({ variant, onClose }: QueueViewProps) => {
]);
};
+ const tracksLabel = (count: number) => {
+ const mod10 = count % 10;
+ const mod100 = count % 100;
+ if (mod10 === 1 && mod100 !== 11) return `${count} трек`;
+ if (mod10 >= 2 && mod10 <= 4 && (mod100 < 12 || mod100 > 14)) {
+ return `${count} трека`;
+ }
+ return `${count} треков`;
+ };
+
const summary =
upcoming.length > 0
- ? `${upcoming.length} ${upcoming.length === 1 ? "track" : "tracks"} · ${getRuntimeCompact(upcomingTicks)}`
+ ? `${tracksLabel(upcoming.length)} · ${getRuntimeCompact(upcomingTicks)}`
: "Очередь пуста";
return (
diff --git a/src/components/windowControls/windowChrome.tsx b/src/components/windowControls/windowChrome.tsx
index 91e61eb..154a7ce 100644
--- a/src/components/windowControls/windowChrome.tsx
+++ b/src/components/windowControls/windowChrome.tsx
@@ -1,5 +1,5 @@
import { useLocation } from "@tanstack/react-router";
-import React, { useEffect } from "react";
+import React from "react";
import { shouldShowAppBar } from "@/components/appBar/appBar";
import WindowControls from ".";
@@ -7,11 +7,29 @@ import "./windowControls.scss";
const isMac = navigator.userAgent.includes("Macintosh");
-const WindowChromeContent = () => {
- useEffect(() => {
- document.body.classList.add("has-window-chrome");
- return () => document.body.classList.remove("has-window-chrome");
- }, []);
+/**
+ * Frameless-window fallback for pages that do not draw the app header:
+ * a small drag strip plus the window buttons in the top-right corner.
+ *
+ * Pages with a header (home, library, search, player) put the window buttons
+ * in that header's row instead, so every page has one titlebar plane and the
+ * buttons never float over the avatar or the page controls.
+ */
+const WindowChrome = () => {
+ const { pathname } = useLocation();
+ if (isMac) return null;
+ // The global app header owns the window buttons on these routes.
+ if (shouldShowAppBar(pathname)) return null;
+ // The home page draws its own header inside the hero frame.
+ if (pathname === "/home") return null;
+ // The video/photo players have their own fullscreen UI.
+ if (pathname.startsWith("/player")) return null;
+ // Library and search headers draw the window buttons themselves.
+ if (pathname.startsWith("/library") || pathname.startsWith("/search")) {
+ return null;
+ }
+ // The remote control page has its own titlebar with window buttons.
+ if (pathname.startsWith("/remote")) return null;
return (
@@ -23,18 +41,4 @@ const WindowChromeContent = () => {
);
};
-/**
- * Frameless-window fallback for pages that do not draw the app header:
- * a small drag strip plus the window buttons in the top-right corner.
- */
-const WindowChrome = () => {
- const { pathname } = useLocation();
- if (isMac) return null;
- if (pathname === "/home" || shouldShowAppBar(pathname)) return null;
- // The video player has its own fullscreen UI.
- if (pathname.startsWith("/player")) return null;
-
- return
;
-};
-
export default WindowChrome;
diff --git a/src/components/windowControls/windowControls.scss b/src/components/windowControls/windowControls.scss
index 9db0ae3..c08aad9 100644
--- a/src/components/windowControls/windowControls.scss
+++ b/src/components/windowControls/windowControls.scss
@@ -41,18 +41,6 @@ html.is-linux .home-header .window-controls {
margin-left: 0.6rem;
}
-// Reserve a strip for the custom titlebar on routes without the app header.
-html.is-windows body.has-window-chrome #root,
-html.is-linux body.has-window-chrome #root {
- padding-top: 44px;
-}
-
-// Search uses a fixed header; move it below the custom titlebar strip.
-html.is-windows body.has-window-chrome .search-header,
-html.is-linux body.has-window-chrome .search-header {
- top: calc(1em + 44px) !important;
-}
-
.window-resize-handles {
position: fixed;
inset: 0;
diff --git a/src/routes/_api/library/$id.tsx b/src/routes/_api/library/$id.tsx
index 0fa2e03..b182141 100644
--- a/src/routes/_api/library/$id.tsx
+++ b/src/routes/_api/library/$id.tsx
@@ -98,14 +98,29 @@ function Library() {
} */
return (
-
+
}>
-
+
diff --git a/src/routes/_api/player/index.tsx b/src/routes/_api/player/index.tsx
index f10f862..70b1d0a 100644
--- a/src/routes/_api/player/index.tsx
+++ b/src/routes/_api/player/index.tsx
@@ -768,7 +768,6 @@ export function VideoPlayer() {
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave}
>
-
{debouncedSearchTerm ? (
@@ -361,6 +362,7 @@ function SearchAppBar({
favorite
+
{
+ // Only one medium at a time: starting music stops video playback.
+ if (typeof document !== "undefined") {
+ const video = (document
+ .querySelector("hls-video")
+ ?.shadowRoot?.querySelector("video") ??
+ document.querySelector("video")) as HTMLVideoElement | null;
+ if (video && !video.paused) video.pause();
+ }
+ void import("./playback").then(({ usePlaybackStore }) => {
+ const state = usePlaybackStore.getState();
+ if (state.mediaSource?.id || state.playerState.isPlayerPlaying) {
+ usePlaybackStore.setState(usePlaybackStore.getInitialState());
+ }
+ });
+
useAudioPlayback.setState({
display: true,
url,
diff --git a/src/utils/store/playback.ts b/src/utils/store/playback.ts
index d974bda..bf9985a 100644
--- a/src/utils/store/playback.ts
+++ b/src/utils/store/playback.ts
@@ -29,7 +29,7 @@ import {
} from "../storage/player";
import type audioPlaybackInfo from "../types/audioPlaybackInfo";
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
-import { generateAudioStreamUrl, playAudio } from "./audioPlayback";
+import { generateAudioStreamUrl, playAudio, stopPlayback } from "./audioPlayback";
import useQueue, { setQueue } from "./queue";
type PlaybackStoreState = {
@@ -731,6 +731,9 @@ export const initializePlayback = async (args: {
subtitleStreamIndex,
} = args;
+ // Only one medium at a time: starting a video stops music playback.
+ stopPlayback();
+
if (!mediaSource.MediaSources?.[0]?.Id) {
throw new Error("Media source is undefined in initializePlayback");
}