diff --git a/src/components/appBar/appBar.tsx b/src/components/appBar/appBar.tsx
index 4d43c6f..7a579eb 100644
--- a/src/components/appBar/appBar.tsx
+++ b/src/components/appBar/appBar.tsx
@@ -13,6 +13,7 @@ import { useCentralStore } from "@/utils/store/central";
import useHeaderStore from "@/utils/store/header";
import useSearchStore from "@/utils/store/search";
import BackButton from "../buttons/backButton";
+import CastButton from "../buttons/castButton";
import { UserAvatarMenu } from "../userAvatarMenu";
import { NavigationDrawer } from "./navigationDrawer";
@@ -106,6 +107,7 @@ export const AppBar = () => {
+
search
diff --git a/src/components/buttons/castButton.tsx b/src/components/buttons/castButton.tsx
new file mode 100644
index 0000000..d01e4f2
--- /dev/null
+++ b/src/components/buttons/castButton.tsx
@@ -0,0 +1,27 @@
+import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
+import IconButton from "@mui/material/IconButton";
+import Tooltip from "@mui/material/Tooltip";
+import React from "react";
+import useRemoteControlStore from "@/utils/store/remoteControl";
+
+type CastButtonProps = {
+ item?: BaseItemDto | null;
+ size?: "small" | "medium" | "large";
+};
+
+const CastButton = ({ item, size = "medium" }: CastButtonProps) => {
+ const openDialog = useRemoteControlStore((s) => s.openDialog);
+ return (
+
+ openDialog(item ?? null)}
+ >
+ cast
+
+
+ );
+};
+
+export default CastButton;
diff --git a/src/components/buttons/instantMixButton.tsx b/src/components/buttons/instantMixButton.tsx
new file mode 100644
index 0000000..66f1dbf
--- /dev/null
+++ b/src/components/buttons/instantMixButton.tsx
@@ -0,0 +1,69 @@
+import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
+import IconButton from "@mui/material/IconButton";
+import Tooltip from "@mui/material/Tooltip";
+import { useSnackbar } from "notistack";
+import React, { useState } from "react";
+import { startInstantMix } from "@/utils/methods/instantMix";
+import { useApiInContext } from "@/utils/store/api";
+import { useCentralStore } from "@/utils/store/central";
+
+type InstantMixButtonProps = {
+ item?: BaseItemDto | null;
+ /** Render a text button instead of an icon (e.g. on the album page). */
+ withLabel?: boolean;
+};
+
+const InstantMixButton = ({ item, withLabel = false }: InstantMixButtonProps) => {
+ const api = useApiInContext((s) => s.api);
+ const user = useCentralStore((s) => s.currentUser);
+ const { enqueueSnackbar } = useSnackbar();
+ const [busy, setBusy] = useState(false);
+
+ const handleClick = async () => {
+ if (!api || !user?.Id || !item) return;
+ setBusy(true);
+ try {
+ const { count } = await startInstantMix(api, user.Id, item);
+ if (count === 0) {
+ enqueueSnackbar("No tracks found for this Instant Mix", {
+ variant: "warning",
+ });
+ } else {
+ enqueueSnackbar(`Instant Mix: ${count} tracks`, {
+ variant: "success",
+ });
+ }
+ } catch (error) {
+ console.error("Instant Mix failed", error);
+ enqueueSnackbar("Could not start Instant Mix", { variant: "error" });
+ } finally {
+ setBusy(false);
+ }
+ };
+
+ return (
+
+
+ {withLabel ? (
+
+ radio
+
+ ) : (
+
+ radio
+
+ )}
+
+
+ );
+};
+
+export default InstantMixButton;
diff --git a/src/components/itemDetail/itemDetailLayout.tsx b/src/components/itemDetail/itemDetailLayout.tsx
index ba6e3e4..4dea39d 100644
--- a/src/components/itemDetail/itemDetailLayout.tsx
+++ b/src/components/itemDetail/itemDetailLayout.tsx
@@ -5,6 +5,7 @@ import {
import Typography from "@mui/material/Typography";
import { motion } from "motion/react";
import React, { type ReactNode, useEffect, useRef } from "react";
+import CastButton from "@/components/buttons/castButton";
import LikeButton from "@/components/buttons/likeButton";
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
import TrailerButton from "@/components/buttons/trailerButton";
@@ -74,6 +75,15 @@ const ItemDetailLayout = ({
const containerRef = useRef(null);
const queryKey = ["item", item.Id ?? ""];
+ const canCast =
+ item.Type === BaseItemKind.Movie ||
+ item.Type === BaseItemKind.Episode ||
+ item.Type === BaseItemKind.Audio ||
+ item.Type === BaseItemKind.AudioBook ||
+ item.Type === BaseItemKind.MusicVideo ||
+ item.Type === BaseItemKind.Video ||
+ item.Type === BaseItemKind.Trailer;
+
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
const hash = backdropHash ?? getDefaultBackdropHash(item);
useEffect(() => {
@@ -114,6 +124,7 @@ const ItemDetailLayout = ({
isFavorite={item.UserData?.IsFavorite}
userId={user?.Id}
/>
+ {canCast && }
{showMarkPlayed && (
{
+
search
diff --git a/src/components/libraryItemsGrid/index.tsx b/src/components/libraryItemsGrid/index.tsx
index b640c19..86d6132 100644
--- a/src/components/libraryItemsGrid/index.tsx
+++ b/src/components/libraryItemsGrid/index.tsx
@@ -15,6 +15,7 @@ import React, {
import "./libraryItemsGrid.scss";
import { useShallow } from "zustand/shallow";
import { getLibraryQueryOptions } from "@/utils/queries/library";
+import { AVAILABLE_VIEWS } from "@/utils/constants/library";
import { getLibraryItemsQueryOptions } from "@/utils/queries/libraryItems";
import { useApiInContext } from "@/utils/store/api";
import { useBackdropStore } from "@/utils/store/backdrop";
@@ -66,31 +67,74 @@ const LibraryItemsGrid = () => {
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
);
+ const collectionType = currentLibrary.data.CollectionType;
+ const defaultViewType: BaseItemKind =
+ collectionType === "music"
+ ? BaseItemKind.MusicAlbum
+ : collectionType === "movies"
+ ? BaseItemKind.Movie
+ : collectionType === "tvshows"
+ ? BaseItemKind.Series
+ : collectionType === "boxsets"
+ ? BaseItemKind.BoxSet
+ : collectionType === "books"
+ ? BaseItemKind.Book
+ : collectionType === "playlists"
+ ? BaseItemKind.Playlist
+ : BaseItemKind.Movie;
+
+ // Persisted slices may hold no view type or a view from another collection
+ // type (e.g. CollectionFolder left by an older build). Reset those.
+ const compatibleViews = AVAILABLE_VIEWS.filter((view) =>
+ view.compatibleCollectionTypes.includes(collectionType as any),
+ ).map((view) => view.value);
+ const isViewValid =
+ !!currentViewType &&
+ (compatibleViews.includes(currentViewType) || currentViewType === "Artist");
+
useEffect(() => {
- if (currentLibraryId && !currentViewType && currentLibrary.data?.Type) {
+ if (currentLibraryId && !isViewValid) {
updateLibrary(currentLibraryId, {
- currentViewType: currentLibrary.data.Type as BaseItemKind,
+ currentViewType: defaultViewType,
});
}
- }, [
- currentLibrary.data?.Type,
- currentLibraryId,
- currentViewType,
- updateLibrary,
- ]);
+ }, [currentLibraryId, isViewValid, defaultViewType, updateLibrary]);
+
+ const effectiveViewType: BaseItemKind | "Artist" = isViewValid
+ ? (currentViewType as BaseItemKind | "Artist")
+ : defaultViewType;
const items = useSuspenseQuery(
getLibraryItemsQueryOptions(api, user?.Id, currentLibraryId, {
- currentViewType,
+ currentViewType: effectiveViewType,
sortAscending,
sortBy,
filters,
videoTypesState,
nameStartsWith,
genreIds,
- collectionType: currentLibrary.data.CollectionType as any,
+ collectionType: collectionType as any,
}),
);
+ // A music library with no album grouping (flat audio files) opens on an
+ // empty "Albums" view. Fall back to Songs so the tracks are visible.
+ useEffect(() => {
+ if (collectionType !== "music") return;
+ if (effectiveViewType !== BaseItemKind.MusicAlbum) return;
+ if (!items.isSuccess) return;
+ if ((items.data?.TotalRecordCount ?? 0) > 0) return;
+ updateLibrary(currentLibraryId, {
+ currentViewType: BaseItemKind.Audio,
+ });
+ }, [
+ collectionType,
+ effectiveViewType,
+ items.isSuccess,
+ items.data?.TotalRecordCount,
+ currentLibraryId,
+ updateLibrary,
+ ]);
+
// --- Backdrop ---
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
const backdropItems = useMemo
(() => {
@@ -147,9 +191,8 @@ const LibraryItemsGrid = () => {
const ro = new ResizeObserver(() => measureColumns());
ro.observe(parentRef.current);
- // The header above the grid can change height (filters, wrapping): keep the
- // window-virtualizer offset in sync so rows never jump while scrolling.
- ro.observe(document.body);
+ // The audio player and headers can change the page layout; a resize
+ // listener is enough (observing fires on every image load).
window.addEventListener("resize", measureColumns);
return () => {
ro.disconnect();
diff --git a/src/components/playback/audioPlayer/audioPlayer.scss b/src/components/playback/audioPlayer/audioPlayer.scss
index 4289db2..0b3a1eb 100644
--- a/src/components/playback/audioPlayer/audioPlayer.scss
+++ b/src/components/playback/audioPlayer/audioPlayer.scss
@@ -18,9 +18,9 @@ $art-size: 48px;
padding: 0 0.75rem 0 1rem;
color: white;
- background: rgb(18 18 24 / 0.92);
- backdrop-filter: blur(16px);
- -webkit-backdrop-filter: blur(16px);
+ // Opaque bar: backdrop-filter over the virtualized grid caused constant
+ // compositing/shifting on WebKit.
+ background: rgb(18 18 24 / 0.98);
border: 1px solid rgb(255 255 255 / 0.08);
border-radius: 14px;
box-shadow: 0 12px 40px rgb(0 0 0 / 0.45);
diff --git a/src/components/playback/audioPlayer/components/PlayerActions.tsx b/src/components/playback/audioPlayer/components/PlayerActions.tsx
index b05d3bd..ca200e1 100644
--- a/src/components/playback/audioPlayer/components/PlayerActions.tsx
+++ b/src/components/playback/audioPlayer/components/PlayerActions.tsx
@@ -1,19 +1,26 @@
+import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import React, { type ReactNode } from "react";
+import CastButton from "@/components/buttons/castButton";
+import InstantMixButton from "@/components/buttons/instantMixButton";
import QueueButton from "@/components/buttons/queueButton";
interface PlayerActionsProps {
/** Opens the full-screen player. */
onExpand: () => void;
onClose: () => void;
+ /** The track currently playing (for cast / instant mix). */
+ item?: BaseItemDto | null;
/** Volume control, rendered between the queue and expand buttons. */
children?: ReactNode;
}
-const PlayerActions = ({ onExpand, onClose, children }: PlayerActionsProps) => {
+const PlayerActions = ({ onExpand, onClose, item, children }: PlayerActionsProps) => {
return (
+ {item &&
}
+ {item &&
}
{children}
diff --git a/src/components/playback/audioPlayer/index.tsx b/src/components/playback/audioPlayer/index.tsx
index d906ca7..55a3477 100644
--- a/src/components/playback/audioPlayer/index.tsx
+++ b/src/components/playback/audioPlayer/index.tsx
@@ -245,7 +245,7 @@ const AudioPlayer = () => {
/>
-
+
+
diff --git a/src/components/remoteControl/index.tsx b/src/components/remoteControl/index.tsx
new file mode 100644
index 0000000..914610c
--- /dev/null
+++ b/src/components/remoteControl/index.tsx
@@ -0,0 +1,373 @@
+import {
+ PlayCommand,
+ PlaystateCommand,
+ type SessionInfoDto,
+} from "@jellyfin/sdk/lib/generated-client";
+import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
+import {
+ Button,
+ Chip,
+ CircularProgress,
+ Dialog,
+ DialogContent,
+ DialogTitle,
+ Divider,
+ IconButton,
+ LinearProgress,
+ List,
+ ListItem,
+ Tooltip,
+ Typography,
+} from "@mui/material";
+import { useMutation, useQuery } from "@tanstack/react-query";
+import { useSnackbar } from "notistack";
+import React from "react";
+import { useApiInContext } from "@/utils/store/api";
+import { useCentralStore } from "@/utils/store/central";
+import useRemoteControlStore from "@/utils/store/remoteControl";
+
+const TICKS_PER_SECOND = 10_000_000;
+
+const formatTime = (ticks: number | null | undefined) => {
+ const total = Math.max(0, Math.round((ticks ?? 0) / TICKS_PER_SECOND));
+ const h = Math.floor(total / 3600);
+ const m = Math.floor((total % 3600) / 60);
+ const s = total % 60;
+ return h > 0
+ ? `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`
+ : `${m}:${String(s).padStart(2, "0")}`;
+};
+
+const sessionLabel = (session: SessionInfoDto) =>
+ session.DeviceName || session.Client || session.DeviceId || "Unknown device";
+
+const RemoteControlDialog = () => {
+ const { open, item, closeDialog } = useRemoteControlStore();
+ const api = useApiInContext((s) => s.api);
+ const user = useCentralStore((s) => s.currentUser);
+ const { enqueueSnackbar } = useSnackbar();
+
+ const sessions = useQuery({
+ queryKey: ["remoteSessions"],
+ queryFn: async () => {
+ if (!api || !user?.Id) return [];
+ const result = await getSessionApi(api).getSessions({
+ controllableByUserId: user.Id,
+ });
+ return result.data;
+ },
+ enabled: open && !!api && !!user?.Id,
+ refetchInterval: open ? 3000 : false,
+ networkMode: "always",
+ });
+
+ const sendCommand = useMutation({
+ mutationFn: async ({
+ session,
+ command,
+ seekPositionTicks,
+ }: {
+ session: SessionInfoDto;
+ command: PlaystateCommand;
+ seekPositionTicks?: number;
+ }) => {
+ if (!api || !session.Id) return;
+ await getSessionApi(api).sendPlaystateCommand({
+ sessionId: session.Id,
+ command,
+ seekPositionTicks,
+ controllingUserId: user?.Id,
+ });
+ },
+ onError: () =>
+ enqueueSnackbar("Command failed", { variant: "error" }),
+ onSettled: () => sessions.refetch(),
+ });
+
+ const playOn = useMutation({
+ mutationFn: async (session: SessionInfoDto) => {
+ if (!api || !session.Id || !item?.Id) return;
+ await getSessionApi(api).play({
+ sessionId: session.Id,
+ playCommand: PlayCommand.PlayNow,
+ itemIds: [item.Id],
+ startPositionTicks: 0,
+ mediaSourceId: item.MediaSources?.[0]?.Id ?? undefined,
+ });
+ },
+ onSuccess: (_data, session) => {
+ enqueueSnackbar(`Playing on ${sessionLabel(session)}`, {
+ variant: "success",
+ });
+ closeDialog();
+ },
+ onError: () =>
+ enqueueSnackbar("Could not start playback on the device", {
+ variant: "error",
+ }),
+ });
+
+ const remoteSessions = (sessions.data ?? []).filter(
+ (session) =>
+ session.Id &&
+ session.DeviceId !== api?.deviceInfo.id &&
+ session.SupportsRemoteControl !== false,
+ );
+
+ const seek = (session: SessionInfoDto, offsetSeconds: number) => {
+ const current = (session.PlayState?.PositionTicks ?? 0) / TICKS_PER_SECOND;
+ const next = Math.max(0, current + offsetSeconds);
+ sendCommand.mutate({
+ session,
+ command: PlaystateCommand.Seek,
+ seekPositionTicks: Math.round(next * TICKS_PER_SECOND),
+ });
+ };
+
+ return (
+
+ );
+};
+
+export default RemoteControlDialog;
diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx
index 32f40dd..3ce62c8 100644
--- a/src/routes/__root.tsx
+++ b/src/routes/__root.tsx
@@ -27,6 +27,7 @@ import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import Backdrop from "@/components/backdrop";
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
+import RemoteControlDialog from "@/components/remoteControl";
import RouterLoading from "@/components/routerLoading";
import Search from "@/components/search";
import Updater from "@/components/updater";
@@ -56,6 +57,7 @@ export const Route = createRootRouteWithContext()({
+
diff --git a/src/routes/_api/music/album/$id.tsx b/src/routes/_api/music/album/$id.tsx
index b21f650..7d4b1c7 100644
--- a/src/routes/_api/music/album/$id.tsx
+++ b/src/routes/_api/music/album/$id.tsx
@@ -6,6 +6,7 @@ import Typography from "@mui/material/Typography";
import { useQuery } from "@tanstack/react-query";
import React, { useLayoutEffect, useMemo } from "react";
import LikeButton from "@/components/buttons/likeButton";
+import InstantMixButton from "@/components/buttons/instantMixButton";
import PlayButton from "@/components/buttons/playButton";
import { Card } from "@/components/card/card";
import CardScroller from "@/components/cardScroller/cardScroller";
@@ -186,6 +187,7 @@ function MusicAlbumTitlePage() {
itemType={item.data.Type ?? "Audio"}
userId={user?.Id}
/>
+
+
{item && }
+ {item && }
+ {item && }
=> {
+ if (!api) throw new Error("API is not available");
+ if (!userId) throw new Error("User is not available");
+ if (!item?.Id) throw new Error("Item is not available");
+
+ const params = {
+ userId,
+ limit: 50,
+ fields: [ItemFields.MediaSources],
+ enableImages: true,
+ enableUserData: true,
+ };
+
+ const mixApi = getInstantMixApi(api);
+ let response;
+
+ switch (item.Type) {
+ case BaseItemKind.MusicAlbum:
+ response = await mixApi.getInstantMixFromAlbum({
+ itemId: item.Id,
+ ...params,
+ });
+ break;
+ case BaseItemKind.MusicArtist:
+ response = await mixApi.getInstantMixFromArtists({
+ itemId: item.Id,
+ ...params,
+ });
+ break;
+ case BaseItemKind.Audio:
+ case BaseItemKind.AudioBook:
+ response = await mixApi.getInstantMixFromSong({
+ itemId: item.Id,
+ ...params,
+ });
+ break;
+ case BaseItemKind.Playlist:
+ response = await mixApi.getInstantMixFromPlaylist({
+ itemId: item.Id,
+ ...params,
+ });
+ break;
+ case BaseItemKind.MusicGenre:
+ case BaseItemKind.Genre:
+ response = await mixApi.getInstantMixFromMusicGenreById({
+ id: item.Id,
+ ...params,
+ });
+ break;
+ default:
+ response = await mixApi.getInstantMixFromItem({
+ itemId: item.Id,
+ ...params,
+ });
+ break;
+ }
+
+ const tracks = (response.data.Items ?? []).filter(
+ (track) => track.Id && track.Type !== BaseItemKind.Folder,
+ );
+ if (tracks.length === 0) {
+ return { count: 0 };
+ }
+
+ setQueue(tracks, 0);
+ await playItemFromQueue(0, userId, api);
+ return { count: tracks.length };
+};
diff --git a/src/utils/store/remoteControl.ts b/src/utils/store/remoteControl.ts
new file mode 100644
index 0000000..8cdfdc7
--- /dev/null
+++ b/src/utils/store/remoteControl.ts
@@ -0,0 +1,19 @@
+import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
+import { create } from "zustand";
+
+type RemoteControlState = {
+ open: boolean;
+ /** Item to offer for "Play on ..." when the dialog is opened from a player. */
+ item: BaseItemDto | null;
+ openDialog: (item?: BaseItemDto | null) => void;
+ closeDialog: () => void;
+};
+
+const useRemoteControlStore = create((set) => ({
+ open: false,
+ item: null,
+ openDialog: (item = null) => set({ open: true, item: item ?? null }),
+ closeDialog: () => set({ open: false, item: null }),
+}));
+
+export default useRemoteControlStore;