diff --git a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
index a5092ac1d2..67e4503729 100644
--- a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
+++ b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
@@ -30,7 +30,7 @@ namespace Jellyfin.Api.Helpers
///
/// Transcoding job helpers.
///
- public class TranscodingJobHelper
+ public class TranscodingJobHelper : IDisposable
{
///
/// The active transcoding jobs.
@@ -46,7 +46,6 @@ namespace Jellyfin.Api.Helpers
private readonly EncodingHelper _encodingHelper;
private readonly IFileSystem _fileSystem;
private readonly IIsoManager _isoManager;
-
private readonly ILogger _logger;
private readonly IMediaEncoder _mediaEncoder;
private readonly IMediaSourceManager _mediaSourceManager;
@@ -90,10 +89,12 @@ namespace Jellyfin.Api.Helpers
_authorizationContext = authorizationContext;
_isoManager = isoManager;
_loggerFactory = loggerFactory;
-
_encodingHelper = new EncodingHelper(mediaEncoder, fileSystem, subtitleEncoder, configuration);
DeleteEncodedMediaCache();
+
+ sessionManager!.PlaybackProgress += OnPlaybackProgress;
+ sessionManager!.PlaybackStart += OnPlaybackProgress;
}
///
@@ -834,6 +835,14 @@ namespace Jellyfin.Api.Helpers
}
}
+ private void OnPlaybackProgress(object sender, PlaybackProgressEventArgs e)
+ {
+ if (!string.IsNullOrWhiteSpace(e.PlaySessionId))
+ {
+ PingTranscodingJob(e.PlaySessionId, e.IsPaused);
+ }
+ }
+
///
/// Deletes the encoded media cache.
///
@@ -850,5 +859,28 @@ namespace Jellyfin.Api.Helpers
_fileSystem.DeleteFile(file);
}
}
+
+ ///
+ /// Dispose transcoding job helper.
+ ///
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Dispose throttler.
+ ///
+ /// Disposing.
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ _loggerFactory.Dispose();
+ _sessionManager!.PlaybackProgress -= OnPlaybackProgress;
+ _sessionManager!.PlaybackStart -= OnPlaybackProgress;
+ }
+ }
}
}