This commit is contained in:
Fredrik Burmester
2024-10-12 12:55:45 +02:00
parent 091a8ff6c3
commit bf8687a473
12 changed files with 1141 additions and 301 deletions

View File

@@ -97,7 +97,6 @@ export const getStreamUrl = async ({
breakOnNonKeyFrames: false,
copyTimestamps: false,
enableMpegtsM2TsMode: false,
},
}
);
@@ -111,16 +110,16 @@ export const getStreamUrl = async ({
console.log("getStreamUrl ~ ", item.MediaType);
if (item.MediaType === "Video") {
if (mediaSource?.TranscodingUrl) {
if (mediaSource?.SupportsDirectPlay || forceDirectPlay === true) {
return {
url: `${api.basePath}${mediaSource.TranscodingUrl}`,
url: `${api.basePath}/Videos/${itemId}/stream.mp4?playSessionId=${sessionData?.PlaySessionId}&mediaSourceId=${mediaSource?.Id}&static=true&subtitleStreamIndex=${subtitleStreamIndex}&audioStreamIndex=${audioStreamIndex}&deviceId=${api.deviceInfo.id}&api_key=${api.accessToken}`,
sessionId: sessionId,
};
}
if (mediaSource?.SupportsDirectPlay || forceDirectPlay === true) {
if (mediaSource?.TranscodingUrl) {
return {
url: `${api.basePath}/Videos/${itemId}/stream.mp4?playSessionId=${sessionData?.PlaySessionId}&mediaSourceId=${mediaSource?.Id}&static=true&subtitleStreamIndex=${subtitleStreamIndex}&audioStreamIndex=${audioStreamIndex}&deviceId=${api.deviceInfo.id}&api_key=${api.accessToken}`,
url: `${api.basePath}${mediaSource.TranscodingUrl}`,
sessionId: sessionId,
};
}

View File

@@ -35,13 +35,14 @@ export const runtimeTicksToSeconds = (
else return `${minutes}m ${seconds}s`;
};
// t: ms
export const formatTimeString = (
t: number | null | undefined,
tick = false
): string => {
if (t === null || t === undefined) return "0:00";
let seconds = t;
let seconds = t / 1000;
if (tick) {
seconds = Math.floor(t / 10000000); // Convert ticks to seconds
}
@@ -66,5 +67,20 @@ export const secondsToTicks = (seconds?: number | undefined) => {
export const ticksToSeconds = (ticks?: number | undefined) => {
if (!ticks) return 0;
return ticks / 10000000;
return Math.floor(ticks / 10000000);
};
export const msToTicks = (ms?: number | undefined) => {
if (!ms) return 0;
return ms * 10000;
};
export const ticksToMs = (ticks?: number | undefined) => {
if (!ticks) return 0;
return Math.floor(ticks / 10000);
};
export const secondsToMs = (seconds?: number | undefined) => {
if (!seconds) return 0;
return seconds * 1000;
};