Skip to content

Commit

Permalink
Merge pull request #624 from 3flex/add-customdata-type
Browse files Browse the repository at this point in the history
Extend MediaInformationCustomData for Jellyfin custom data
  • Loading branch information
nielsvanvelzen authored Oct 21, 2024
2 parents 8d6b78b + b29d732 commit 1f4d425
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/components/maincontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ window.playerManager.addEventListener(
() => {
setTextTrack(
window.playerManager.getMediaInformation()?.customData
.subtitleStreamIndex
?.subtitleStreamIndex ?? null
);
}
);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 16 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 1f4d425

Please sign in to comment.