fix: trickplay images not showing up
This commit is contained in:
5 files changed
+45
-42
No files matched your search
@@ -18,6 +18,7 @@ import {
|
|||||||
ItemFilter,
|
ItemFilter,
|
||||||
LocationType,
|
LocationType,
|
||||||
MediaProtocol,
|
MediaProtocol,
|
||||||
|
type MediaSegmentDtoQueryResult,
|
||||||
type PlaybackInfoResponse,
|
type PlaybackInfoResponse,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
type UserItemDataDto,
|
type UserItemDataDto,
|
||||||
@@ -42,9 +43,9 @@ import { axiosClient, useApiInContext } from "@/utils/store/api";
|
|||||||
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
||||||
import type IntroMediaInfo from "@/utils/types/introMediaInfo";
|
import type IntroMediaInfo from "@/utils/types/introMediaInfo";
|
||||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||||
|
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
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";
|
||||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
|
||||||
import type { SxProps } from "@mui/material";
|
import type { SxProps } from "@mui/material";
|
||||||
import type { AxiosResponse } from "axios";
|
import type { AxiosResponse } from "axios";
|
||||||
|
|
||||||
@@ -130,8 +131,11 @@ const PlayButton = ({
|
|||||||
setPlaybackDataLoading(true);
|
setPlaybackDataLoading(true);
|
||||||
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
||||||
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
||||||
let introInfo: undefined | IntroMediaInfo;
|
let introInfo: undefined | MediaSegmentDtoQueryResult;
|
||||||
const indexNumber = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
const indexNumber = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
||||||
|
if (!api) {
|
||||||
|
throw new Error("API is not available");
|
||||||
|
}
|
||||||
if (playlistItem) {
|
if (playlistItem) {
|
||||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
result = await getPlaylistsApi(api).getPlaylistItems({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
@@ -172,14 +176,10 @@ const PlayButton = ({
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
introInfo = (
|
introInfo = (
|
||||||
await axiosClient.get(
|
await getMediaSegmentsApi(api).getItemSegments({
|
||||||
`${api.basePath}/Episode/${result.data.Items?.[0]?.Id}/IntroSkipperSegments`,
|
itemId: item.Id,
|
||||||
{
|
includeSegmentTypes: ["Intro"],
|
||||||
headers: {
|
})
|
||||||
Authorization: `MediaBrowser Token=${api.accessToken}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
)?.data;
|
)?.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -248,7 +248,7 @@ const PlayButton = ({
|
|||||||
break;
|
break;
|
||||||
case BaseItemKind.MusicArtist:
|
case BaseItemKind.MusicArtist:
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
artistIds: [item.Id],
|
artistIds: [item.Id ?? ""],
|
||||||
recursive: true,
|
recursive: true,
|
||||||
includeItemTypes: [BaseItemKind.Audio],
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
userId: userId,
|
userId: userId,
|
||||||
@@ -279,7 +279,7 @@ const PlayButton = ({
|
|||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
parentId: photo.ParentId,
|
parentId: photo.ParentId ?? "",
|
||||||
filters: [ItemFilter.IsNotFolder],
|
filters: [ItemFilter.IsNotFolder],
|
||||||
recursive: false,
|
recursive: false,
|
||||||
sortBy: ["SortName"],
|
sortBy: ["SortName"],
|
||||||
@@ -291,7 +291,7 @@ const PlayButton = ({
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
ids: [item.Id],
|
ids: [item.Id ?? ""],
|
||||||
userId: userId,
|
userId: userId,
|
||||||
fields: [
|
fields: [
|
||||||
ItemFields.MediaSources,
|
ItemFields.MediaSources,
|
||||||
@@ -306,11 +306,11 @@ const PlayButton = ({
|
|||||||
audioStreamIndex: currentAudioTrack,
|
audioStreamIndex: currentAudioTrack,
|
||||||
subtitleStreamIndex:
|
subtitleStreamIndex:
|
||||||
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||||
itemId: item.Id,
|
itemId: item.Id ?? "",
|
||||||
startTimeTicks:
|
startTimeTicks:
|
||||||
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
result.data.Items?.[0].UserData?.PlaybackPositionTicks,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
mediaSourceId: result.data.Items?.[0].MediaSources?.[0].Id,
|
mediaSourceId: result.data.Items?.[0].MediaSources?.[0].Id ?? "",
|
||||||
playbackInfoDto: {
|
playbackInfoDto: {
|
||||||
DeviceProfile: playbackProfile,
|
DeviceProfile: playbackProfile,
|
||||||
},
|
},
|
||||||
@@ -321,18 +321,15 @@ const PlayButton = ({
|
|||||||
return { item: result?.data, mediaSource: mediaSource?.data, introInfo };
|
return { item: result?.data, mediaSource: mediaSource?.data, introInfo };
|
||||||
},
|
},
|
||||||
onSuccess: (result: PlayResult | null) => {
|
onSuccess: (result: PlayResult | null) => {
|
||||||
|
if (!api) {
|
||||||
|
console.error("API is not available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (trackIndex) {
|
if (trackIndex) {
|
||||||
// Playlist Playback
|
// Playlist Playback
|
||||||
enqueueSnackbar("Playlist playback is WIP", { variant: "info" });
|
enqueueSnackbar("Playlist playback is WIP", { variant: "info" });
|
||||||
} else if (audio) {
|
} else 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,
|
||||||
@@ -350,11 +347,13 @@ const PlayButton = ({
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const episodeIndex = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
const episodeIndex = item.IndexNumber ? item.IndexNumber - 1 : 0;
|
||||||
|
|
||||||
// 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
|
||||||
@@ -381,9 +380,9 @@ 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(
|
playItem(
|
||||||
@@ -399,8 +398,8 @@ const PlayButton = ({
|
|||||||
playItemValue,
|
playItemValue,
|
||||||
queue,
|
queue,
|
||||||
episodeIndex,
|
episodeIndex,
|
||||||
result?.mediaSource.MediaSources?.[0]?.Id,
|
result?.mediaSource?.MediaSources?.[0]?.Id,
|
||||||
result?.mediaSource.PlaySessionId,
|
result?.mediaSource?.PlaySessionId,
|
||||||
subtitle,
|
subtitle,
|
||||||
result?.introInfo,
|
result?.introInfo,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,13 +26,12 @@ import PlayButton from "../buttons/playButton";
|
|||||||
* @property {Array} queryKey
|
* @property {Array} queryKey
|
||||||
* @property {string} userId
|
* @property {string} userId
|
||||||
* @property {boolean} disableRunTime
|
* @property {boolean} disableRunTime
|
||||||
* @property {() => {}} onClick
|
* @property {() => {} | undefined} onClick
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Hero section for item pages
|
* @description Hero section for item pages
|
||||||
* @param {Props}
|
* @param {Props}
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const EpisodeCard = ({
|
export const EpisodeCard = ({
|
||||||
@@ -53,7 +52,6 @@ export const EpisodeCard = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="card card-episode"
|
className="card card-episode"
|
||||||
elevation={0}
|
|
||||||
onClick={onClick ? onClick : defaultOnClick}
|
onClick={onClick ? onClick : defaultOnClick}
|
||||||
>
|
>
|
||||||
<div className="card-box">
|
<div className="card-box">
|
||||||
@@ -107,7 +105,7 @@ export const EpisodeCard = ({
|
|||||||
|
|
||||||
<div className="card-overlay">
|
<div className="card-overlay">
|
||||||
<PlayButton
|
<PlayButton
|
||||||
itemId={item.Id}
|
item={item}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
itemType={item.Type}
|
itemType={item.Type}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
|
|||||||
@@ -467,6 +467,7 @@ function VideoPlayer() {
|
|||||||
const trickplayResolutions = mediaSource.id
|
const trickplayResolutions = mediaSource.id
|
||||||
? item?.Trickplay?.[mediaSource.id]
|
? item?.Trickplay?.[mediaSource.id]
|
||||||
: null;
|
: null;
|
||||||
|
console.log(item);
|
||||||
if (trickplayResolutions) {
|
if (trickplayResolutions) {
|
||||||
let bestWidth: number | undefined;
|
let bestWidth: number | undefined;
|
||||||
const maxWidth = window.screen.width * window.devicePixelRatio * 0.2;
|
const maxWidth = window.screen.width * window.devicePixelRatio * 0.2;
|
||||||
@@ -553,6 +554,7 @@ function VideoPlayer() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentChapter?.[0]?.Name) {
|
if (currentChapter?.[0]?.Name) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-column video-osb-bubble glass">
|
<div className="flex flex-column video-osb-bubble glass">
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ import TrailerButton from "@/components/buttons/trailerButton";
|
|||||||
import ShowMoreText from "@/components/showMoreText";
|
import ShowMoreText from "@/components/showMoreText";
|
||||||
import { SeasonSelectorSkeleton } from "@/components/skeleton/seasonSelector";
|
import { SeasonSelectorSkeleton } from "@/components/skeleton/seasonSelector";
|
||||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import EpisodeSkeleton from "@/components/skeleton/episode";
|
import EpisodeSkeleton from "@/components/skeleton/episode";
|
||||||
@@ -103,6 +103,8 @@ function SeriesTitlePage() {
|
|||||||
|
|
||||||
const api = Route.useRouteContext().api;
|
const api = Route.useRouteContext().api;
|
||||||
|
|
||||||
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||||
|
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const item = useQuery({
|
const item = useQuery({
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import type { MediaStream } from "@jellyfin/sdk/lib/generated-client";
|
|||||||
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
|
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
|
||||||
|
|
||||||
export default function getSubtitle(
|
export default function getSubtitle(
|
||||||
track: number | "nosub",
|
track: number | "nosub" | undefined,
|
||||||
mediaStreams: MediaStream[] | undefined | null,
|
mediaStreams: MediaStream[] | undefined | null,
|
||||||
): subtitlePlaybackInfo {
|
): subtitlePlaybackInfo | undefined {
|
||||||
const availableSubtitles = mediaStreams?.filter(
|
const availableSubtitles = mediaStreams?.filter(
|
||||||
(stream) => stream.Type === "Subtitle",
|
(stream) => stream.Type === "Subtitle",
|
||||||
);
|
);
|
||||||
@@ -29,11 +29,13 @@ export default function getSubtitle(
|
|||||||
);
|
);
|
||||||
const url = requiredSubtitle?.[0]?.DeliveryUrl;
|
const url = requiredSubtitle?.[0]?.DeliveryUrl;
|
||||||
console.log(track);
|
console.log(track);
|
||||||
return {
|
if (track) {
|
||||||
track,
|
return {
|
||||||
enable: true,
|
track,
|
||||||
format: requiredSubtitle?.[0]?.Codec,
|
enable: true,
|
||||||
allTracks: availableSubtitles,
|
format: requiredSubtitle?.[0]?.Codec,
|
||||||
url,
|
allTracks: availableSubtitles,
|
||||||
};
|
url,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user