Skip to content

Commit

Permalink
Accept StreamInfo in createMediaInformation function
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex committed Nov 11, 2024
1 parent f4bb985 commit 0e35f1d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/maincontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { JellyfinApi } from './jellyfinApi';
import { PlaybackManager, PlaybackState } from './playbackManager';
import { CommandHandler } from './commandHandler';
import { getMaxBitrateSupport } from './codecSupportHelper';
import { PlayRequest } from '~/types/global';
import { PlayRequest, StreamInfo } from '~/types/global';

window.castReceiverContext = cast.framework.CastReceiverContext.getInstance();
window.playerManager = window.castReceiverContext.getPlayerManager();
Expand Down Expand Up @@ -808,7 +808,6 @@ export function setTextTrack(index: number | null): void {
}
}

// TODO no any types
/**
* createMediaInformation
* @param playSessionId - playSessionId
Expand All @@ -819,8 +818,7 @@ export function setTextTrack(index: number | null): void {
export function createMediaInformation(
playSessionId: string,
item: BaseItemDto,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
streamInfo: any
streamInfo: StreamInfo
): framework.messages.MediaInformation {
const mediaInfo = new cast.framework.messages.MediaInformation();

Expand All @@ -831,12 +829,12 @@ export function createMediaInformation(
canClientSeek: streamInfo.canClientSeek,
canSeek: streamInfo.canSeek,
itemId: item.Id,
liveStreamId: streamInfo.mediaSource.LiveStreamId,
mediaSourceId: streamInfo.mediaSource.Id,
liveStreamId: streamInfo.mediaSource?.LiveStreamId ?? null,
mediaSourceId: streamInfo.mediaSource?.Id ?? null,
playMethod: streamInfo.isStatic ? 'DirectStream' : 'Transcode',
playSessionId: playSessionId,
runtimeTicks: streamInfo.mediaSource.RunTimeTicks,
startPositionTicks: streamInfo.startPositionTicks || 0,
runtimeTicks: streamInfo.mediaSource?.RunTimeTicks ?? null,
startPositionTicks: streamInfo.startPositionTicks ?? 0,
subtitleStreamIndex: streamInfo.subtitleStreamIndex
};

Expand All @@ -845,7 +843,7 @@ export function createMediaInformation(
mediaInfo.streamType = cast.framework.messages.StreamType.BUFFERED;
mediaInfo.tracks = streamInfo.tracks;

if (streamInfo.mediaSource.RunTimeTicks) {
if (streamInfo.mediaSource?.RunTimeTicks) {
mediaInfo.duration = Math.floor(
ticksToSeconds(streamInfo.mediaSource.RunTimeTicks)
);
Expand Down

0 comments on commit 0e35f1d

Please sign in to comment.