diff --git a/src/components/jellyfinActions.ts b/src/components/jellyfinActions.ts index 20fe252c..a84b2684 100644 --- a/src/components/jellyfinActions.ts +++ b/src/components/jellyfinActions.ts @@ -16,6 +16,7 @@ import { AppStatus } from '../types/appStatus'; import { JellyfinApi } from './jellyfinApi'; import { DocumentManager } from './documentManager'; import { PlaybackManager, type PlaybackState } from './playbackManager'; +import type { JellyfinMediaInformationCustomData } from '~/types/global'; let pingInterval: number; let lastTranscoderPing = 0; @@ -164,8 +165,10 @@ export async function pingTranscoder(playSessionId: string): Promise { * @param customData - data to set on playback state. * @param serverItem - item that is playing */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function load(customData: any, serverItem: BaseItemDto): void { +export function load( + customData: JellyfinMediaInformationCustomData, + serverItem: BaseItemDto +): void { PlaybackManager.resetPlaybackScope(); const state = PlaybackManager.playbackState; diff --git a/src/components/playbackManager.ts b/src/components/playbackManager.ts index 1d3aa292..96efa96d 100644 --- a/src/components/playbackManager.ts +++ b/src/components/playbackManager.ts @@ -31,12 +31,12 @@ import type { ItemIndex, PlayRequest } from '~/types/global'; export interface PlaybackState { startPositionTicks: number; mediaType: string | null | undefined; - itemId: string; + itemId: string | undefined; audioStreamIndex: number | null; subtitleStreamIndex: number | null; mediaSource: MediaSourceInfo | null; - mediaSourceId: string; + mediaSourceId: string | null; PlaybackMediaSource: MediaSourceInfo | null; playMethod: PlayMethod | undefined; @@ -45,10 +45,10 @@ export interface PlaybackState { playNextItemBool: boolean; item: BaseItemDto | null; - liveStreamId: string; + liveStreamId: string | null; playSessionId: string; - runtimeTicks: number; + runtimeTicks: number | null; } // eslint-disable-next-line @typescript-eslint/no-extraneous-class @@ -295,7 +295,10 @@ export abstract class PlaybackManager { const isChangingStream = this.playbackState.isChangingStream; - load(mediaInfo.customData, item); + if (mediaInfo.customData) { + load(mediaInfo.customData, item); + } + this.playbackState.isChangingStream = isChangingStream; this.playerManager.load(loadRequestData); diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 9d0b448e..9b07561f 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -6,6 +6,7 @@ import { SystemVolumeData } from 'chromecast-caf-receiver/cast.framework.system' import type { BaseItemDto, MediaSourceInfo, + PlayMethod, RepeatMode } from '@jellyfin/sdk/lib/generated-client'; import type { @@ -106,17 +107,21 @@ declare global { } declare module 'chromecast-caf-receiver/cast.framework.messages' { - interface MediaInformationCustomData { - audioStreamIndex: number | null; - canClientSeek: boolean; - canSeek: boolean; - itemId: string | undefined; - liveStreamId: string | null; - mediaSourceId: string | null; - playMethod: 'DirectStream' | 'Transcode'; - playSessionId: string; - runtimeTicks: number | null; - startPositionTicks: number; - subtitleStreamIndex: number | null; - } + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface MediaInformationCustomData + extends JellyfinMediaInformationCustomData {} +} + +interface JellyfinMediaInformationCustomData { + audioStreamIndex: number | null; + canClientSeek: boolean; + canSeek: boolean; + itemId: string | undefined; + liveStreamId: string | null; + mediaSourceId: string | null; + playMethod: PlayMethod; + playSessionId: string; + runtimeTicks: number | null; + startPositionTicks: number; + subtitleStreamIndex: number | null; }