Extend MediaInformationCustomData for Jellyfin custom data

This commit is contained in:
Matthew Haughton 2024-10-20 18:31:10 +11:00
parent 9c767429a5
commit b29d732706
3 changed files with 19 additions and 4 deletions

View File

@ -247,7 +247,7 @@ window.playerManager.addEventListener(
() => {
setTextTrack(
window.playerManager.getMediaInformation()?.customData
.subtitleStreamIndex
?.subtitleStreamIndex ?? null
);
}
);
@ -494,7 +494,7 @@ export async function changeStream(
params: any = undefined // eslint-disable-line @typescript-eslint/no-explicit-any
): Promise<void> {
if (
window.playerManager.getMediaInformation()?.customData.canClientSeek &&
window.playerManager.getMediaInformation()?.customData?.canClientSeek &&
params == null
) {
window.playerManager.seek(ticksToSeconds(ticks));
@ -847,7 +847,6 @@ export function createMediaInformation(
mediaInfo.contentId = streamInfo.url;
mediaInfo.contentType = streamInfo.contentType;
// TODO make a type for this
mediaInfo.customData = {
audioStreamIndex: streamInfo.audioStreamIndex,
canClientSeek: streamInfo.canClientSeek,

View File

@ -22,7 +22,7 @@ export function getCurrentPositionTicks(state: PlaybackState): number {
window.playerManager.getCurrentTimeSec() * TicksPerSecond;
const mediaInformation = window.playerManager.getMediaInformation();
if (mediaInformation && !mediaInformation.customData.canClientSeek) {
if (mediaInformation && !mediaInformation.customData?.canClientSeek) {
positionTicks += state.startPositionTicks || 0;
}

16
src/types/global.d.ts vendored
View File

@ -103,3 +103,19 @@ declare global {
volume: SystemVolumeData;
}
}
declare module 'chromecast-caf-receiver/cast.framework.messages' {
interface MediaInformationCustomData {
audioStreamIndex: string;
canClientSeek: boolean;
canSeek: boolean;
itemId: string | undefined;
liveStreamId: number;
mediaSourceId: number;
playMethod: 'DirectStream' | 'Transcode';
playSessionId: string;
runtimeTicks: number;
startPositionTicks: number;
subtitleStreamIndex: number;
}
}