fix(chromecast): add missing MediaInfo fields
Some checks failed
🏗️ Build Apps / 🤖 Build Android APK (Phone) (push) Has been cancelled
🏗️ Build Apps / 🤖 Build Android APK (TV) (push) Has been cancelled
🏗️ Build Apps / 🍎 Build iOS IPA (Phone) (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (actions) (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🚦 Security & Quality Gate / 📝 Validate PR Title (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Vulnerable Dependencies (push) Has been cancelled
🚦 Security & Quality Gate / 🚑 Expo Doctor Check (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Lint & Test (check) (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Lint & Test (format) (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Lint & Test (lint) (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Lint & Test (typecheck) (push) Has been cancelled

This commit is contained in:
Fredrik Burmester
2026-01-10 21:32:09 +01:00
parent f1575ca48b
commit 399eb0a351
2 changed files with 23 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import { useTranslation } from "react-i18next";
import { Alert, Platform, TouchableOpacity, View } from "react-native"; import { Alert, Platform, TouchableOpacity, View } from "react-native";
import CastContext, { import CastContext, {
CastButton, CastButton,
MediaStreamType,
PlayServicesState, PlayServicesState,
useMediaStatus, useMediaStatus,
useRemoteMediaClient, useRemoteMediaClient,
@@ -185,11 +186,23 @@ export const PlayButton: React.FC<Props> = ({
return; return;
} }
// Calculate start time in seconds from playback position
const startTimeSeconds =
(item?.UserData?.PlaybackPositionTicks ?? 0) / 10000000;
// Calculate stream duration in seconds from runtime
const streamDurationSeconds = item.RunTimeTicks
? item.RunTimeTicks / 10000000
: undefined;
client client
.loadMedia({ .loadMedia({
mediaInfo: { mediaInfo: {
contentId: item.Id,
contentUrl: data?.url, contentUrl: data?.url,
contentType: "video/mp4", contentType: "video/mp4",
streamType: MediaStreamType.BUFFERED,
streamDuration: streamDurationSeconds,
metadata: metadata:
item.Type === "Episode" item.Type === "Episode"
? { ? {
@@ -241,7 +254,7 @@ export const PlayButton: React.FC<Props> = ({
], ],
}, },
}, },
startTime: 0, startTime: startTimeSeconds,
}) })
.then(() => { .then(() => {
// state is already set when reopening current media, so skip it here. // state is already set when reopening current media, so skip it here.

View File

@@ -3,6 +3,7 @@ import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { useCallback } from "react"; import { useCallback } from "react";
import CastContext, { import CastContext, {
CastState, CastState,
MediaStreamType,
PlayServicesState, PlayServicesState,
useCastState, useCastState,
useRemoteMediaClient, useRemoteMediaClient,
@@ -82,10 +83,18 @@ export const useMusicCast = ({ api, userId }: UseMusicCastOptions) => {
streamResult.mediaSource?.Container, streamResult.mediaSource?.Container,
); );
// Calculate stream duration in seconds from runtime ticks
const streamDurationSeconds = track.RunTimeTicks
? track.RunTimeTicks / 10000000
: undefined;
return { return {
mediaInfo: { mediaInfo: {
contentId: track.Id,
contentUrl: streamResult.url, contentUrl: streamResult.url,
contentType, contentType,
streamType: MediaStreamType.BUFFERED,
streamDuration: streamDurationSeconds,
metadata: { metadata: {
type: "musicTrack" as const, type: "musicTrack" as const,
title: track.Name || "Unknown Track", title: track.Name || "Unknown Track",