Added video bitrate sort order

This commit is contained in:
Luke Pulverenti 2013-09-13 16:53:46 -04:00
parent b07a1e67c2
commit 93fdbc17d8
4 changed files with 52 additions and 6 deletions

View File

@ -82,5 +82,6 @@ namespace MediaBrowser.Model.Querying
public const string AlbumCount = "AlbumCount"; public const string AlbumCount = "AlbumCount";
public const string MusicVideoCount = "MusicVideoCount"; public const string MusicVideoCount = "MusicVideoCount";
public const string SeriesSortName = "SeriesSortName"; public const string SeriesSortName = "SeriesSortName";
public const string VideoBitRate = "VideoBitRate";
} }
} }

View File

@ -210,6 +210,7 @@
<Compile Include="Persistence\SqliteUserDataRepository.cs" /> <Compile Include="Persistence\SqliteUserDataRepository.cs" />
<Compile Include="Persistence\SqliteUserRepository.cs" /> <Compile Include="Persistence\SqliteUserRepository.cs" />
<Compile Include="Sorting\TrailerCountComparer.cs" /> <Compile Include="Sorting\TrailerCountComparer.cs" />
<Compile Include="Sorting\VideoBitRateComparer.cs" />
<Compile Include="Udp\UdpMessageReceivedEventArgs.cs" /> <Compile Include="Udp\UdpMessageReceivedEventArgs.cs" />
<Compile Include="Udp\UdpServer.cs" /> <Compile Include="Udp\UdpServer.cs" />
<Compile Include="WebSocket\AlchemyServer.cs" /> <Compile Include="WebSocket\AlchemyServer.cs" />

View File

@ -1,9 +1,4 @@
using System; using MediaBrowser.Controller.Entities;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Sorting; using MediaBrowser.Controller.Sorting;

View File

@ -0,0 +1,49 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Sorting
{
class VideoBitRateComparer : IBaseItemComparer
{
/// <summary>
/// Compares the specified x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
return GetValue(x).CompareTo(GetValue(y));
}
private int GetValue(BaseItem item)
{
var video = item as IHasMediaStreams;
if (video != null)
{
var videoStream = video.MediaStreams
.FirstOrDefault(i => i.Type == MediaStreamType.Video);
if (videoStream != null)
{
return videoStream.BitRate ?? 0;
}
}
return 0;
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name
{
get { return ItemSortBy.VideoBitRate; }
}
}
}