mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-17 18:03:01 +01:00
feat(casting): embed CastSelection in cast customData
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
import type { Api } from "@jellyfin/sdk";
|
import type { Api } from "@jellyfin/sdk";
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { MediaStreamType } from "react-native-google-cast";
|
import { MediaStreamType } from "react-native-google-cast";
|
||||||
|
import type { CastSelection } from "@/utils/casting/types";
|
||||||
import { getParentBackdropImageUrl } from "@/utils/jellyfin/image/getParentBackdropImageUrl";
|
import { getParentBackdropImageUrl } from "@/utils/jellyfin/image/getParentBackdropImageUrl";
|
||||||
import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl";
|
import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl";
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ export const buildCastMediaInfo = ({
|
|||||||
contentType,
|
contentType,
|
||||||
isLive = false,
|
isLive = false,
|
||||||
playSessionId,
|
playSessionId,
|
||||||
|
selection,
|
||||||
}: {
|
}: {
|
||||||
item: BaseItemDto;
|
item: BaseItemDto;
|
||||||
streamUrl: string;
|
streamUrl: string;
|
||||||
@@ -34,6 +36,8 @@ export const buildCastMediaInfo = ({
|
|||||||
isLive?: boolean;
|
isLive?: boolean;
|
||||||
/** Jellyfin PlaySessionId, embedded in customData for progress reporting. */
|
/** Jellyfin PlaySessionId, embedded in customData for progress reporting. */
|
||||||
playSessionId?: string;
|
playSessionId?: string;
|
||||||
|
/** Active track / quality / version selection, embedded in customData. */
|
||||||
|
selection?: CastSelection;
|
||||||
}) => {
|
}) => {
|
||||||
if (!item.Id) {
|
if (!item.Id) {
|
||||||
throw new Error("Missing item.Id for media load — cannot build contentId");
|
throw new Error("Missing item.Id for media load — cannot build contentId");
|
||||||
@@ -87,8 +91,12 @@ export const buildCastMediaInfo = ({
|
|||||||
// Build a slim customData payload with only the fields the casting-player needs.
|
// Build a slim customData payload with only the fields the casting-player needs.
|
||||||
// Sending the full BaseItemDto can exceed the Cast protocol's ~64KB message limit,
|
// Sending the full BaseItemDto can exceed the Cast protocol's ~64KB message limit,
|
||||||
// especially for movies with many chapters, media sources, and people.
|
// especially for movies with many chapters, media sources, and people.
|
||||||
const slimCustomData: Partial<BaseItemDto> & { playSessionId?: string } = {
|
const slimCustomData: Partial<BaseItemDto> & {
|
||||||
|
playSessionId?: string;
|
||||||
|
selection?: CastSelection;
|
||||||
|
} = {
|
||||||
playSessionId,
|
playSessionId,
|
||||||
|
selection,
|
||||||
Id: item.Id,
|
Id: item.Id,
|
||||||
Name: item.Name,
|
Name: item.Name,
|
||||||
Type: item.Type,
|
Type: item.Type,
|
||||||
|
|||||||
Reference in New Issue
Block a user