From 70d9c17052b2ca3abdf31e8b1007fa77ad28534c Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:34:34 +1100 Subject: [PATCH] Migrate stopping active encodings to jellyfin-sdk-typescript --- src/components/jellyfinActions.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/components/jellyfinActions.ts b/src/components/jellyfinActions.ts index 07115929..112a693a 100644 --- a/src/components/jellyfinActions.ts +++ b/src/components/jellyfinActions.ts @@ -7,7 +7,11 @@ import type { PlaybackProgressInfo, PlayRequest } from '@jellyfin/sdk/lib/generated-client'; -import { getMediaInfoApi, getPlaystateApi } from '@jellyfin/sdk/lib/utils/api'; +import { + getHlsSegmentApi, + getMediaInfoApi, + getPlaystateApi +} from '@jellyfin/sdk/lib/utils/api'; import { getSenderReportingData, broadcastToMessageBus } from '../helpers'; import { AppStatus } from '../types/appStatus'; import { JellyfinApi } from './jellyfinApi'; @@ -400,21 +404,14 @@ export async function detectBitrate(numBytes = 500000): Promise { /** * Tell Jellyfin to kill off our active transcoding session - * @param state - playback state. + * @param playSessionId - the play session ID to stop encoding * @returns Promise for the http request to go through */ -export function stopActiveEncodings(state: PlaybackState): Promise { - const options = { +export async function stopActiveEncodings( + playSessionId: string +): Promise { + await getHlsSegmentApi(JellyfinApi.jellyfinApi).stopEncodingProcess({ deviceId: JellyfinApi.deviceId, - PlaySessionId: '' - }; - - if (state.playSessionId) { - options.PlaySessionId = state.playSessionId; - } - - return JellyfinApi.authAjax('Videos/ActiveEncodings', { - query: options, - type: 'DELETE' + playSessionId: playSessionId }); }