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 transcoder pinging to jellyfin-sdk-typescript #680

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: 8 additions & 17 deletions src/components/jellyfinActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ function restartPingInterval(reportingParams: PlaybackProgressInfo): void {

if (reportingParams.PlayMethod == 'Transcode') {
pingInterval = window.setInterval(() => {
pingTranscoder(reportingParams);
if (reportingParams.PlaySessionId) {
pingTranscoder(reportingParams.PlaySessionId);
}
}, 1000);
}
}
Expand Down Expand Up @@ -143,12 +145,10 @@ export function reportPlaybackStopped(
* /Sessions/Playing/Progress does work but may not be called during pause.
* The web client calls that during pause, but this endpoint gets the job done
* as well.
* @param reportingParams - progress information to carry
* @param playSessionId - the playback session ID to ping
* @returns promise for waiting for the request
*/
export function pingTranscoder(
reportingParams: PlaybackProgressInfo
): Promise<void> {
export async function pingTranscoder(playSessionId: string): Promise<void> {
const now = new Date().getTime();

// 10s is the timeout value, so use half that to report often enough
Expand All @@ -162,18 +162,9 @@ export function pingTranscoder(

lastTranscoderPing = new Date().getTime();

// 10.7 oddly wants it as a query string parameter. This is a server bug for now.
return JellyfinApi.authAjax(
`Sessions/Playing/Ping?playSessionId=${reportingParams.PlaySessionId}`,
{
contentType: 'application/json',
data: JSON.stringify({
// jellyfin <= 10.6 wants it in the post data.
PlaySessionId: reportingParams.PlaySessionId
}),
type: 'POST'
}
);
await getPlaystateApi(JellyfinApi.jellyfinApi).pingPlaybackSession({
playSessionId: playSessionId
});
}

/**
Expand Down
Loading