mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-18 18:24:18 +01:00
Merge branch 'develop' into fix/settings-spacing
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
RepeatMode,
|
RepeatMode,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import {
|
import {
|
||||||
|
getMediaInfoApi,
|
||||||
getPlaystateApi,
|
getPlaystateApi,
|
||||||
getUserLibraryApi,
|
getUserLibraryApi,
|
||||||
} from "@jellyfin/sdk/lib/utils/api";
|
} from "@jellyfin/sdk/lib/utils/api";
|
||||||
@@ -310,6 +311,37 @@ export default function DirectPlayerPage() {
|
|||||||
// Ref to store the stream fetch function for refreshing subtitle tracks
|
// Ref to store the stream fetch function for refreshing subtitle tracks
|
||||||
const refetchStreamRef = useRef<(() => Promise<Stream | null>) | null>(null);
|
const refetchStreamRef = useRef<(() => Promise<Stream | null>) | null>(null);
|
||||||
|
|
||||||
|
// Live TV opens a server-side live stream via autoOpenLiveStream. If it is
|
||||||
|
// never closed, Jellyfin's M3U tuner limit fills up and every channel then
|
||||||
|
// fails with "simultaneous stream limit has been reached". reportPlaybackStopped
|
||||||
|
// handles a clean stop, but a channel switch (the player re-fetches in place)
|
||||||
|
// or an unmount after an error bypass it, so track the open live stream and
|
||||||
|
// release it on those paths too.
|
||||||
|
const apiRef = useRef(api);
|
||||||
|
useEffect(() => {
|
||||||
|
apiRef.current = api;
|
||||||
|
}, [api]);
|
||||||
|
|
||||||
|
const releaseLiveStream = useCallback(
|
||||||
|
(liveStreamId: string | null) => {
|
||||||
|
if (!liveStreamId || !apiRef.current || offline) return;
|
||||||
|
// Best effort: a failed close must not break teardown, and the slot is
|
||||||
|
// also freed by the server's reap as a backstop.
|
||||||
|
getMediaInfoApi(apiRef.current)
|
||||||
|
.closeLiveStream({ liveStreamId })
|
||||||
|
.catch(() => {});
|
||||||
|
},
|
||||||
|
[offline],
|
||||||
|
);
|
||||||
|
|
||||||
|
// The effect cleanup releases the live stream both when it changes (channel
|
||||||
|
// switch, which re-runs the effect) and when the player unmounts, so no
|
||||||
|
// manual previous-id tracking is needed.
|
||||||
|
useEffect(() => {
|
||||||
|
const liveStreamId = stream?.mediaSource?.LiveStreamId ?? null;
|
||||||
|
return () => releaseLiveStream(liveStreamId);
|
||||||
|
}, [stream?.mediaSource?.LiveStreamId, releaseLiveStream]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchStreamData = async (): Promise<Stream | null> => {
|
const fetchStreamData = async (): Promise<Stream | null> => {
|
||||||
setStreamStatus({ isLoading: true, isError: false });
|
setStreamStatus({ isLoading: true, isError: false });
|
||||||
@@ -445,6 +477,12 @@ export default function DirectPlayerPage() {
|
|||||||
MediaSourceId: mediaSourceId,
|
MediaSourceId: mediaSourceId,
|
||||||
PositionTicks: currentTimeInTicks,
|
PositionTicks: currentTimeInTicks,
|
||||||
PlaySessionId: stream.sessionId,
|
PlaySessionId: stream.sessionId,
|
||||||
|
// Release the server-side live stream (and its tuner slot) on stop.
|
||||||
|
// Jellyfin only closes a live stream opened via autoOpenLiveStream when
|
||||||
|
// the stop report carries its LiveStreamId; without it the stream leaks
|
||||||
|
// and Live TV eventually fails for everyone with "M3U simultaneous
|
||||||
|
// stream limit has been reached". Undefined for non-live items (no-op).
|
||||||
|
LiveStreamId: stream.mediaSource?.LiveStreamId ?? undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, [api, item, mediaSourceId, stream, progress, offline]);
|
}, [api, item, mediaSourceId, stream, progress, offline]);
|
||||||
|
|||||||
@@ -35,8 +35,10 @@ const ContinueWatchingPoster: React.FC<ContinueWatchingPosterProps> = ({
|
|||||||
return `${api?.basePath}/Items/${item.Id}/Images/Primary?fillHeight=389&quality=80`;
|
return `${api?.basePath}/Items/${item.Id}/Images/Primary?fillHeight=389&quality=80`;
|
||||||
}
|
}
|
||||||
if (item.Type === "Episode") {
|
if (item.Type === "Episode") {
|
||||||
if (item.ParentBackdropItemId && item.ParentThumbImageTag) {
|
// Matched pair: the parent that owns the Thumb (ParentThumbItemId), not the
|
||||||
return `${api?.basePath}/Items/${item.ParentBackdropItemId}/Images/Thumb?fillHeight=389&quality=80&tag=${item.ParentThumbImageTag}`;
|
// backdrop owner — otherwise the Thumb tag is requested on the wrong item → black.
|
||||||
|
if (item.ParentThumbItemId && item.ParentThumbImageTag) {
|
||||||
|
return `${api?.basePath}/Items/${item.ParentThumbItemId}/Images/Thumb?fillHeight=389&quality=80&tag=${item.ParentThumbImageTag}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${api?.basePath}/Items/${item.Id}/Images/Primary?fillHeight=389&quality=80`;
|
return `${api?.basePath}/Items/${item.Id}/Images/Primary?fillHeight=389&quality=80`;
|
||||||
@@ -61,7 +63,8 @@ const ContinueWatchingPoster: React.FC<ContinueWatchingPosterProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return `${api?.basePath}/Items/${item.Id}/Images/Primary?fillHeight=389&quality=80`;
|
return `${api?.basePath}/Items/${item.Id}/Images/Primary?fillHeight=389&quality=80`;
|
||||||
}, [item]);
|
// useEpisodePoster in deps so flipping the prop re-computes the URL live.
|
||||||
|
}, [api, item, useEpisodePoster]);
|
||||||
|
|
||||||
if (!url)
|
if (!url)
|
||||||
return <View className='aspect-video border border-neutral-800 w-44' />;
|
return <View className='aspect-video border border-neutral-800 w-44' />;
|
||||||
|
|||||||
@@ -65,10 +65,11 @@ const HeroCard: React.FC<HeroCardProps> = React.memo(
|
|||||||
const posterUrl = useMemo(() => {
|
const posterUrl = useMemo(() => {
|
||||||
if (!api) return null;
|
if (!api) return null;
|
||||||
|
|
||||||
// For episodes, always use series thumb
|
// For episodes, always use series thumb.
|
||||||
|
// Matched pair: ParentThumbItemId owns the Thumb tag, not ParentBackdropItemId.
|
||||||
if (item.Type === "Episode") {
|
if (item.Type === "Episode") {
|
||||||
if (item.ParentThumbImageTag) {
|
if (item.ParentThumbItemId && item.ParentThumbImageTag) {
|
||||||
return `${api.basePath}/Items/${item.ParentBackdropItemId}/Images/Thumb?fillHeight=400&quality=80&tag=${item.ParentThumbImageTag}`;
|
return `${api.basePath}/Items/${item.ParentThumbItemId}/Images/Thumb?fillHeight=400&quality=80&tag=${item.ParentThumbImageTag}`;
|
||||||
}
|
}
|
||||||
if (item.SeriesId) {
|
if (item.SeriesId) {
|
||||||
return `${api.basePath}/Items/${item.SeriesId}/Images/Thumb?fillHeight=400&quality=80`;
|
return `${api.basePath}/Items/${item.SeriesId}/Images/Thumb?fillHeight=400&quality=80`;
|
||||||
|
|||||||
@@ -139,9 +139,10 @@ export const TVPosterCard: React.FC<TVPosterCardProps> = ({
|
|||||||
if (orientation === "horizontal") {
|
if (orientation === "horizontal") {
|
||||||
// Episode: prefer series thumb image for consistent look (like hero section)
|
// Episode: prefer series thumb image for consistent look (like hero section)
|
||||||
if (item.Type === "Episode") {
|
if (item.Type === "Episode") {
|
||||||
// First try parent/series thumb (horizontal series artwork)
|
// First try parent/series thumb (horizontal series artwork).
|
||||||
if (item.ParentBackdropItemId && item.ParentThumbImageTag) {
|
// Matched pair: ParentThumbItemId owns the Thumb tag, not ParentBackdropItemId.
|
||||||
return `${api.basePath}/Items/${item.ParentBackdropItemId}/Images/Thumb?fillHeight=700&quality=80&tag=${item.ParentThumbImageTag}`;
|
if (item.ParentThumbItemId && item.ParentThumbImageTag) {
|
||||||
|
return `${api.basePath}/Items/${item.ParentThumbItemId}/Images/Thumb?fillHeight=700&quality=80&tag=${item.ParentThumbImageTag}`;
|
||||||
}
|
}
|
||||||
// Fall back to episode's own primary image
|
// Fall back to episode's own primary image
|
||||||
if (item.ImageTags?.Primary) {
|
if (item.ImageTags?.Primary) {
|
||||||
|
|||||||
Reference in New Issue
Block a user