aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Dlna/StreamInfoSorter.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2015-03-31 15:41:12 -0400
committerLuke <luke.pulverenti@gmail.com>2015-03-31 15:41:12 -0400
commitbe74de0236a3544959722b3a8ff9c9ca26c73d13 (patch)
tree292d0abda239cd3966840b7e93568580209bf189 /MediaBrowser.Model/Dlna/StreamInfoSorter.cs
parentaa079120059699f4778d80f55e68883d75d26b3a (diff)
parent2626b6f3729097e083f381936738d17335f48f1c (diff)
Merge pull request #1058 from MediaBrowser/dev
3.0.5569.0
Diffstat (limited to 'MediaBrowser.Model/Dlna/StreamInfoSorter.cs')
-rw-r--r--MediaBrowser.Model/Dlna/StreamInfoSorter.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/MediaBrowser.Model/Dlna/StreamInfoSorter.cs b/MediaBrowser.Model/Dlna/StreamInfoSorter.cs
new file mode 100644
index 0000000000..0cccd80804
--- /dev/null
+++ b/MediaBrowser.Model/Dlna/StreamInfoSorter.cs
@@ -0,0 +1,47 @@
+using MediaBrowser.Model.MediaInfo;
+using MediaBrowser.Model.Session;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace MediaBrowser.Model.Dlna
+{
+ public class StreamInfoSorter
+ {
+ public static List<StreamInfo> SortMediaSources(List<StreamInfo> streams)
+ {
+ return streams.OrderBy(i =>
+ {
+ // Nothing beats direct playing a file
+ if (i.PlayMethod == PlayMethod.DirectPlay && i.MediaSource.Protocol == MediaProtocol.File)
+ {
+ return 0;
+ }
+
+ return 1;
+
+ }).ThenBy(i =>
+ {
+ switch (i.PlayMethod)
+ {
+ // Let's assume direct streaming a file is just as desirable as direct playing a remote url
+ case PlayMethod.DirectStream:
+ case PlayMethod.DirectPlay:
+ return 0;
+ default:
+ return 1;
+ }
+
+ }).ThenBy(i =>
+ {
+ switch (i.MediaSource.Protocol)
+ {
+ case MediaProtocol.File:
+ return 0;
+ default:
+ return 1;
+ }
+
+ }).ToList();
+ }
+ }
+}