Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate stopping active encodings to jellyfin-sdk-typescript #681

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -400,21 +404,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({
3flex marked this conversation as resolved.
Show resolved Hide resolved
deviceId: JellyfinApi.deviceId,
PlaySessionId: ''
};

if (state.playSessionId) {
options.PlaySessionId = state.playSessionId;
}

return JellyfinApi.authAjax('Videos/ActiveEncodings', {
query: options,
type: 'DELETE'
playSessionId: playSessionId
});
}
Loading