Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend MediaInformationCustomData for Jellyfin custom data #624

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this can also be DirectPlay, might be worth re-using the PlayMethod type from our TypeScript SDK

playSessionId: string;
runtimeTicks: number;
startPositionTicks: number;
subtitleStreamIndex: number;
}
}
Loading