Skip to content

Commit

Permalink
Merge pull request #681 from 3flex/patch-4
Browse files Browse the repository at this point in the history
Migrate stopping active encodings to jellyfin-sdk-typescript
  • Loading branch information
nielsvanvelzen authored Nov 7, 2024
2 parents f46690e + 70d9c17 commit a5db014
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/components/jellyfinActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -391,21 +395,14 @@ export async function detectBitrate(numBytes = 500000): Promise<number> {

/**
* 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<void> {
const options = {
export async function stopActiveEncodings(
playSessionId: string
): Promise<void> {
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
});
}

0 comments on commit a5db014

Please sign in to comment.