fix playback

This commit is contained in:
Chris Kruining 2025-06-03 10:16:38 +02:00
parent 20aed86123
commit ac28de56d3
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
6 changed files with 18 additions and 7 deletions

View file

@ -82,10 +82,17 @@ export const listItemIds = query(
}
return Object.fromEntries(
data.Items?.map((item) => ([
`${item.MediaType as any}-${item.ProviderIds!["Tmdb"]!}`,
{ jellyfin: item.Id! },
])) ?? []
data.Items?.map((item) => {
const type = {
Movie: 'movie',
Series: 'tv',
}[item.Type as string] ?? 'unknown';
return [
`${type}-${item.ProviderIds!["Tmdb"]!}`,
{ jellyfin: item.Id! },
];
}) ?? []
);
},
"jellyfin.listItemIds",

View file

@ -16,8 +16,12 @@ const lookupTable = query(async () => listItemIds(), 'content.lookupTable');
export const getHighlights = () => getContinueWatching(jellyfinUserId);
export const getStream = query(async (type: Entry['type'], id: string, range: string) => {
console.log(type, id);
const table = await lookupTable();
console.log(table, table[`${type}-${id}`].jellyfin);
return getItemStream(table[`${type}-${id}`].jellyfin, range);
}, 'content.stream');

View file

@ -90,7 +90,7 @@ export const Player: Component<PlayerProps> = (props) => {
<video
ref={setVideo}
src={`/api/content/${props.entry.id}/stream`}
src={`/api/content/${props.entry.type}/${props.entry.id}/stream`}
// src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
poster={props.entry.image}
lang="en"

View file

@ -3,7 +3,7 @@ import { getStream } from "~/features/content";
// const CHUNK_SIZE = 1 * 1e6; // 1MB
export const GET = async ({ request, params }: APIEvent) => {
export const GET = async ({ request, params: { type, id } }: APIEvent) => {
"use server";
const range = request.headers.get("range");
@ -12,7 +12,7 @@ export const GET = async ({ request, params }: APIEvent) => {
return new Response("Requires Range header", { status: 400 });
}
return getStream(params.id, range);
return getStream(type, id, range);
// try {
// const file = Bun.file(