diff --git a/src/Jellyfin.Plugin.Dlna.Model/Jellyfin.Plugin.Dlna.Model.csproj b/src/Jellyfin.Plugin.Dlna.Model/Jellyfin.Plugin.Dlna.Model.csproj index 1a8ee67..d20b1bd 100644 --- a/src/Jellyfin.Plugin.Dlna.Model/Jellyfin.Plugin.Dlna.Model.csproj +++ b/src/Jellyfin.Plugin.Dlna.Model/Jellyfin.Plugin.Dlna.Model.csproj @@ -5,7 +5,7 @@ - - + + diff --git a/src/Jellyfin.Plugin.Dlna.Playback/Jellyfin.Plugin.Dlna.Playback.csproj b/src/Jellyfin.Plugin.Dlna.Playback/Jellyfin.Plugin.Dlna.Playback.csproj index 6c0952f..8e70c41 100644 --- a/src/Jellyfin.Plugin.Dlna.Playback/Jellyfin.Plugin.Dlna.Playback.csproj +++ b/src/Jellyfin.Plugin.Dlna.Playback/Jellyfin.Plugin.Dlna.Playback.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs b/src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs index 525da47..468f3df 100644 --- a/src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs +++ b/src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Jellyfin.Data.Enums; using Jellyfin.Extensions; using Jellyfin.Plugin.Dlna.Model; using Jellyfin.Plugin.Dlna.Playback.Extensions; @@ -17,7 +18,6 @@ using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; -using MediaBrowser.Model.Entities; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; @@ -129,7 +129,7 @@ public static async Task GetStreamingState( var item = libraryManager.GetItemById(streamingRequest.Id); - state.IsInputVideo = string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase); + state.IsInputVideo = item.MediaType == MediaType.Video; MediaSourceInfo? mediaSource = null; if (string.IsNullOrWhiteSpace(streamingRequest.LiveStreamId)) diff --git a/src/Jellyfin.Plugin.Dlna/ContentDirectory/ControlHandler.cs b/src/Jellyfin.Plugin.Dlna/ContentDirectory/ControlHandler.cs index c04a624..7d51ae4 100644 --- a/src/Jellyfin.Plugin.Dlna/ContentDirectory/ControlHandler.cs +++ b/src/Jellyfin.Plugin.Dlna/ContentDirectory/ControlHandler.cs @@ -494,7 +494,7 @@ private static QueryResult GetChildrenSorted(BaseItem item, User user, { var folder = (Folder)item; - string[] mediaTypes = Array.Empty(); + MediaType[] mediaTypes = Array.Empty(); bool? isFolder = null; switch (search.SearchType) diff --git a/src/Jellyfin.Plugin.Dlna/Didl/DidlBuilder.cs b/src/Jellyfin.Plugin.Dlna/Didl/DidlBuilder.cs index 62091b9..5cdde46 100644 --- a/src/Jellyfin.Plugin.Dlna/Didl/DidlBuilder.cs +++ b/src/Jellyfin.Plugin.Dlna/Didl/DidlBuilder.cs @@ -181,13 +181,14 @@ public void WriteItemElement( if (item is IHasMediaSources) { - if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) + switch (item.MediaType) { - AddAudioResource(writer, item, deviceId, filter, streamInfo); - } - else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) - { - AddVideoResource(writer, item, deviceId, filter, streamInfo); + case MediaType.Audio: + AddAudioResource(writer, item, deviceId, filter, streamInfo); + break; + case MediaType.Video: + AddVideoResource(writer, item, deviceId, filter, streamInfo); + break; } } @@ -828,15 +829,15 @@ private void WriteObjectClass(XmlWriter writer, BaseItem item, StubType? stubTyp writer.WriteString(classType ?? "object.container.storageFolder"); } - else if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) + else if (item.MediaType == MediaType.Audio) { writer.WriteString("object.item.audioItem.musicTrack"); } - else if (string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase)) + else if (item.MediaType == MediaType.Photo) { writer.WriteString("object.item.imageItem.photo"); } - else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) + else if (item.MediaType == MediaType.Video) { if (!_profile.RequiresPlainVideoItems && item is Movie) { @@ -1013,8 +1014,7 @@ private void AddCover(BaseItem item, StubType? stubType, XmlWriter writer) if (!_profile.EnableAlbumArtInDidl) { - if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) - || string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) + if (item.MediaType is MediaType.Audio or MediaType.Video) { if (!stubType.HasValue) { @@ -1023,7 +1023,7 @@ private void AddCover(BaseItem item, StubType? stubType, XmlWriter writer) } } - if (!_profile.EnableSingleAlbumArtLimit || string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase)) + if (!_profile.EnableSingleAlbumArtLimit || item.MediaType == MediaType.Photo) { AddImageResElement(item, writer, 4096, 4096, "jpg", "JPEG_LRG"); AddImageResElement(item, writer, 1024, 768, "jpg", "JPEG_MED"); diff --git a/src/Jellyfin.Plugin.Dlna/Jellyfin.Plugin.Dlna.csproj b/src/Jellyfin.Plugin.Dlna/Jellyfin.Plugin.Dlna.csproj index 8883130..86639a4 100644 --- a/src/Jellyfin.Plugin.Dlna/Jellyfin.Plugin.Dlna.csproj +++ b/src/Jellyfin.Plugin.Dlna/Jellyfin.Plugin.Dlna.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/src/Jellyfin.Plugin.Dlna/PlayTo/PlayToController.cs b/src/Jellyfin.Plugin.Dlna/PlayTo/PlayToController.cs index b648390..5211d35 100644 --- a/src/Jellyfin.Plugin.Dlna/PlayTo/PlayToController.cs +++ b/src/Jellyfin.Plugin.Dlna/PlayTo/PlayToController.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using Jellyfin.Data.Entities; +using Jellyfin.Data.Enums; using Jellyfin.Data.Events; using Jellyfin.Plugin.Dlna.Didl; using Jellyfin.Plugin.Dlna.Extensions; @@ -17,7 +18,6 @@ using MediaBrowser.Controller.Session; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; -using MediaBrowser.Model.Entities; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Session; using Microsoft.AspNetCore.WebUtilities; @@ -580,10 +580,9 @@ private PlaylistItem CreatePlaylistItem( } private PlaylistItem GetPlaylistItem(BaseItem item, MediaSourceInfo[] mediaSources, DeviceProfile profile, string deviceId, string? mediaSourceId, int? audioStreamIndex, int? subtitleStreamIndex) - { - if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) + => item.MediaType switch { - return new PlaylistItem + MediaType.Video => new PlaylistItem { StreamInfo = new StreamBuilder(_mediaEncoder, _logger).GetOptimalVideoStream(new MediaOptions { @@ -596,14 +595,9 @@ private PlaylistItem GetPlaylistItem(BaseItem item, MediaSourceInfo[] mediaSourc AudioStreamIndex = audioStreamIndex, SubtitleStreamIndex = subtitleStreamIndex }), - Profile = profile - }; - } - - if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) - { - return new PlaylistItem + }, + MediaType.Audio => new PlaylistItem { StreamInfo = new StreamBuilder(_mediaEncoder, _logger).GetOptimalAudioStream(new MediaOptions { @@ -614,18 +608,11 @@ private PlaylistItem GetPlaylistItem(BaseItem item, MediaSourceInfo[] mediaSourc MaxBitrate = profile.MaxStreamingBitrate, MediaSourceId = mediaSourceId }), - Profile = profile - }; - } - - if (string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase)) - { - return PlaylistItemFactory.Create((Photo)item, profile); - } - - throw new ArgumentException("Unrecognized item type."); - } + }, + MediaType.Photo => PlaylistItemFactory.Create((Photo)item, profile), + _ => throw new ArgumentException("Unrecognized item type.") + }; /// /// Plays the items. diff --git a/src/Jellyfin.Plugin.Dlna/PlayTo/uBaseObject.cs b/src/Jellyfin.Plugin.Dlna/PlayTo/uBaseObject.cs index 38c6747..d52b0c8 100644 --- a/src/Jellyfin.Plugin.Dlna/PlayTo/uBaseObject.cs +++ b/src/Jellyfin.Plugin.Dlna/PlayTo/uBaseObject.cs @@ -33,19 +33,19 @@ public string MediaType { var classType = UpnpClass ?? string.Empty; - if (classType.IndexOf(MediaBrowser.Model.Entities.MediaType.Audio, StringComparison.Ordinal) != -1) + if (classType.Contains("Audio", StringComparison.Ordinal)) { - return MediaBrowser.Model.Entities.MediaType.Audio; + return "Audio"; } - if (classType.IndexOf(MediaBrowser.Model.Entities.MediaType.Video, StringComparison.Ordinal) != -1) + if (classType.Contains("Video", StringComparison.Ordinal)) { - return MediaBrowser.Model.Entities.MediaType.Video; + return "Video"; } - if (classType.IndexOf("image", StringComparison.Ordinal) != -1) + if (classType.Contains("image", StringComparison.Ordinal)) { - return MediaBrowser.Model.Entities.MediaType.Photo; + return "Photo"; } return null; diff --git a/src/Rssdp/Rssdp.csproj b/src/Rssdp/Rssdp.csproj index 5d92412..0ea3540 100644 --- a/src/Rssdp/Rssdp.csproj +++ b/src/Rssdp/Rssdp.csproj @@ -5,9 +5,9 @@ - - - + + +