aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2024-02-06 16:23:18 -0500
committerPatrick Barron <barronpm@gmail.com>2024-02-07 10:52:36 -0500
commitc9311c9e7e048eadb1abb62a1904098adb740a76 (patch)
tree188a5f0b167588ce8a87c9b16464293799eed71b /src
parent690e603b90ae9d856386d5fb6bf3e32d4cb46a9c (diff)
Use IHostedService for Live TV
Diffstat (limited to 'src')
-rw-r--r--src/Jellyfin.LiveTv/EmbyTV/EntryPoint.cs21
-rw-r--r--src/Jellyfin.LiveTv/EmbyTV/LiveTvHost.cs31
2 files changed, 31 insertions, 21 deletions
diff --git a/src/Jellyfin.LiveTv/EmbyTV/EntryPoint.cs b/src/Jellyfin.LiveTv/EmbyTV/EntryPoint.cs
deleted file mode 100644
index e750c05ac..000000000
--- a/src/Jellyfin.LiveTv/EmbyTV/EntryPoint.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma warning disable CS1591
-
-using System.Threading.Tasks;
-using MediaBrowser.Controller.Plugins;
-
-namespace Jellyfin.LiveTv.EmbyTV
-{
- public sealed class EntryPoint : IServerEntryPoint
- {
- /// <inheritdoc />
- public Task RunAsync()
- {
- return EmbyTV.Current.Start();
- }
-
- /// <inheritdoc />
- public void Dispose()
- {
- }
- }
-}
diff --git a/src/Jellyfin.LiveTv/EmbyTV/LiveTvHost.cs b/src/Jellyfin.LiveTv/EmbyTV/LiveTvHost.cs
new file mode 100644
index 000000000..dc15d53ff
--- /dev/null
+++ b/src/Jellyfin.LiveTv/EmbyTV/LiveTvHost.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Controller.LiveTv;
+using Microsoft.Extensions.Hosting;
+
+namespace Jellyfin.LiveTv.EmbyTV;
+
+/// <summary>
+/// <see cref="IHostedService"/> responsible for initializing Live TV.
+/// </summary>
+public sealed class LiveTvHost : IHostedService
+{
+ private readonly EmbyTV _service;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LiveTvHost"/> class.
+ /// </summary>
+ /// <param name="services">The available <see cref="ILiveTvService"/>s.</param>
+ public LiveTvHost(IEnumerable<ILiveTvService> services)
+ {
+ _service = services.OfType<EmbyTV>().First();
+ }
+
+ /// <inheritdoc />
+ public Task StartAsync(CancellationToken cancellationToken) => _service.Start();
+
+ /// <inheritdoc />
+ public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
+}