added new image params & GameSystem constants
This commit is contained in:
parent
f87454336e
commit
7dae0069d6
|
@ -56,11 +56,11 @@ namespace MediaBrowser.Api.Images
|
|||
[ApiMember(Name = "Format", Description = "Determines the output foramt of the image - original,gif,jpg,png", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public ImageOutputFormat Format { get; set; }
|
||||
|
||||
[ApiMember(Name = "Indicator", Description = "Determines what overlay to render, if any. none, watched.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public ImageOverlay? Indicator { get; set; }
|
||||
[ApiMember(Name = "AddPlayedIndicator", Description = "Optional. Add a played indicator", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool AddPlayedIndicator { get; set; }
|
||||
|
||||
[ApiMember(Name = "PercentPlayed", Description = "Percent to render for the percent played overlay", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public int PercentPlayed { get; set; }
|
||||
[ApiMember(Name = "PercentPlayed", Description = "Optional percent to render for the percent played overlay", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public int? PercentPlayed { get; set; }
|
||||
|
||||
[ApiMember(Name = "BackgroundColor", Description = "Optional. Apply a background color for transparent images.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string BackgroundColor { get; set; }
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace MediaBrowser.Api.Images
|
|||
Quality = Request.Quality,
|
||||
Width = Request.Width,
|
||||
OutputFormat = Request.Format,
|
||||
Indicator = Request.Indicator,
|
||||
AddPlayedIndicator = Request.AddPlayedIndicator,
|
||||
PercentPlayed = Request.PercentPlayed,
|
||||
BackgroundColor = Request.BackgroundColor
|
||||
};
|
||||
|
|
|
@ -35,9 +35,9 @@ namespace MediaBrowser.Controller.Drawing
|
|||
|
||||
public ImageOutputFormat OutputFormat { get; set; }
|
||||
|
||||
public ImageOverlay? Indicator { get; set; }
|
||||
public bool AddPlayedIndicator { get; set; }
|
||||
|
||||
public int PercentPlayed { get; set; }
|
||||
public int? PercentPlayed { get; set; }
|
||||
|
||||
public string BackgroundColor { get; set; }
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -17,5 +18,11 @@ namespace MediaBrowser.Controller.LiveTv
|
|||
/// </summary>
|
||||
/// <value>The name of the service.</value>
|
||||
public string ServiceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the channel.
|
||||
/// </summary>
|
||||
/// <value>The type of the channel.</value>
|
||||
public ChannelType ChannelType { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,9 +86,6 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Drawing\ImageOutputFormat.cs">
|
||||
<Link>Drawing\ImageOutputFormat.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Drawing\ImageOverlay.cs">
|
||||
<Link>Drawing\ImageOverlay.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\BaseItemDto.cs">
|
||||
<Link>Dto\BaseItemDto.cs</Link>
|
||||
</Compile>
|
||||
|
@ -203,6 +200,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Extensions\ModelExtensions.cs">
|
||||
<Link>Extensions\ModelExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Games\GameSystem.cs">
|
||||
<Link>Games\GameSystem.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Globalization\CountryInfo.cs">
|
||||
<Link>Globalization\CountryInfo.cs</Link>
|
||||
</Compile>
|
||||
|
@ -218,6 +218,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
|
||||
<Link>LiveTv\ChannelInfoDto.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelType.cs">
|
||||
<Link>LiveTv\ChannelType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
|
||||
<Link>LiveTv\LiveTvServiceInfo.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -70,9 +70,6 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Drawing\ImageOutputFormat.cs">
|
||||
<Link>Drawing\ImageOutputFormat.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Drawing\ImageOverlay.cs">
|
||||
<Link>Drawing\ImageOverlay.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\BaseItemDto.cs">
|
||||
<Link>Dto\BaseItemDto.cs</Link>
|
||||
</Compile>
|
||||
|
@ -187,6 +184,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Extensions\ModelExtensions.cs">
|
||||
<Link>Extensions\ModelExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Games\GameSystem.cs">
|
||||
<Link>Games\GameSystem.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Globalization\CountryInfo.cs">
|
||||
<Link>Globalization\CountryInfo.cs</Link>
|
||||
</Compile>
|
||||
|
@ -202,6 +202,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
|
||||
<Link>LiveTv\ChannelInfoDto.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelType.cs">
|
||||
<Link>LiveTv\ChannelType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
|
||||
<Link>LiveTv\LiveTvServiceInfo.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
namespace MediaBrowser.Model.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum ImageOverlay
|
||||
/// </summary>
|
||||
public enum ImageOverlay
|
||||
{
|
||||
/// <summary>
|
||||
/// The watched
|
||||
/// </summary>
|
||||
Played,
|
||||
/// <summary>
|
||||
/// The percent played
|
||||
/// </summary>
|
||||
PercentPlayed
|
||||
}
|
||||
}
|
|
@ -70,10 +70,33 @@ namespace MediaBrowser.Model.Dto
|
|||
/// <value><c>true</c> if [enable image enhancers]; otherwise, <c>false</c>.</value>
|
||||
public bool EnableImageEnhancers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the format.
|
||||
/// </summary>
|
||||
/// <value>The format.</value>
|
||||
public ImageOutputFormat Format { get; set; }
|
||||
|
||||
public ImageOverlay? Indicator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [add played indicator].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [add played indicator]; otherwise, <c>false</c>.</value>
|
||||
public bool AddPlayedIndicator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the percent played.
|
||||
/// </summary>
|
||||
/// <value>The percent played.</value>
|
||||
public int? PercentPlayed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the background.
|
||||
/// </summary>
|
||||
/// <value>The color of the background.</value>
|
||||
public string BackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ImageOptions" /> class.
|
||||
/// </summary>
|
||||
public ImageOptions()
|
||||
{
|
||||
EnableImageEnhancers = true;
|
||||
|
|
48
MediaBrowser.Model/Games/GameSystem.cs
Normal file
48
MediaBrowser.Model/Games/GameSystem.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
namespace MediaBrowser.Model.Games
|
||||
{
|
||||
public class GameSystem
|
||||
{
|
||||
public const string Nintendo = "Nintendo";
|
||||
public const string SuperNintendo = "Super Nintendo";
|
||||
public const string Panasonic3DO = "3DO";
|
||||
public const string Amiga = "Amiga";
|
||||
public const string Arcade = "Arcade";
|
||||
public const string Atari2600 = "Atari 2600";
|
||||
public const string Atari5200 = "Atari 5200";
|
||||
public const string Atari7800 = "Atari 7800";
|
||||
public const string AtariXE = "Atari XE";
|
||||
public const string AtariJaguar = "Atari Jaguar";
|
||||
public const string AtariJaguarCD = "Atari Jaguar CD";
|
||||
public const string Colecovision = "Colecovision";
|
||||
public const string Commodore64 = "Commodore 64";
|
||||
public const string CommodoreVic20 = "Commodore Vic-20";
|
||||
public const string Intellivision = "Intellivision";
|
||||
public const string MicrosoftXBox = "Xbox";
|
||||
public const string NeoGeo = "Neo Geo";
|
||||
public const string Nintendo64 = "Nintendo 64";
|
||||
public const string NintendoDS = "Nintendo DS";
|
||||
public const string NintendoGameBoy = "Game Boy";
|
||||
public const string NintendoGameBoyAdvance = "Game Boy Advance";
|
||||
public const string NintendoGameBoyColor = "Game Boy Color";
|
||||
public const string NintendoGameCube = "Gamecube";
|
||||
public const string VirtualBoy = "Virtual Boy";
|
||||
public const string Wii = "Nintendo Wii";
|
||||
public const string DOS = "DOS";
|
||||
public const string Windows = "Windows";
|
||||
public const string Sega32X = "Sega 32X";
|
||||
public const string SegaCD = "Sega CD";
|
||||
public const string SegaDreamcast = "Dreamcast";
|
||||
public const string SegaGameGear = "Game Gear";
|
||||
public const string SegaGenesis = "Sega Genesis";
|
||||
public const string SegaMasterSystem = "Sega Master System";
|
||||
public const string SegaMegaDrive = "Sega Mega Drive";
|
||||
public const string SegaSaturn = "Sega Saturn";
|
||||
public const string SonyPlaystation = "Sony Playstation";
|
||||
public const string SonyPlaystation2 = "PS2";
|
||||
public const string SonyPSP = "PSP";
|
||||
public const string TurboGrafx16 = "TurboGrafx 16";
|
||||
public const string TurboGrafxCD = "TurboGrafx CD";
|
||||
public const string ZxSpectrum = "ZX Spectrum";
|
||||
}
|
||||
}
|
|
@ -17,5 +17,11 @@ namespace MediaBrowser.Model.LiveTv
|
|||
/// </summary>
|
||||
/// <value>The name of the service.</value>
|
||||
public string ServiceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the channel.
|
||||
/// </summary>
|
||||
/// <value>The type of the channel.</value>
|
||||
public ChannelType ChannelType { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
19
MediaBrowser.Model/LiveTv/ChannelType.cs
Normal file
19
MediaBrowser.Model/LiveTv/ChannelType.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
namespace MediaBrowser.Model.LiveTv
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum ChannelType
|
||||
/// </summary>
|
||||
public enum ChannelType
|
||||
{
|
||||
/// <summary>
|
||||
/// The TV
|
||||
/// </summary>
|
||||
TV,
|
||||
|
||||
/// <summary>
|
||||
/// The radio
|
||||
/// </summary>
|
||||
Radio
|
||||
}
|
||||
}
|
|
@ -48,7 +48,6 @@
|
|||
<Compile Include="Configuration\BaseApplicationConfiguration.cs" />
|
||||
<Compile Include="Configuration\ManualLoginCategory.cs" />
|
||||
<Compile Include="Configuration\ServerConfiguration.cs" />
|
||||
<Compile Include="Drawing\ImageOverlay.cs" />
|
||||
<Compile Include="Drawing\ImageOutputFormat.cs" />
|
||||
<Compile Include="Dto\BaseItemPerson.cs" />
|
||||
<Compile Include="Dto\ChapterInfoDto.cs" />
|
||||
|
@ -63,10 +62,12 @@
|
|||
<Compile Include="Entities\MediaUrl.cs" />
|
||||
<Compile Include="Entities\MetadataFields.cs" />
|
||||
<Compile Include="Entities\Video3DFormat.cs" />
|
||||
<Compile Include="Games\GameSystem.cs" />
|
||||
<Compile Include="IO\IIsoManager.cs" />
|
||||
<Compile Include="IO\IIsoMount.cs" />
|
||||
<Compile Include="IO\IIsoMounter.cs" />
|
||||
<Compile Include="LiveTv\ChannelInfoDto.cs" />
|
||||
<Compile Include="LiveTv\ChannelType.cs" />
|
||||
<Compile Include="LiveTv\LiveTvServiceInfo.cs" />
|
||||
<Compile Include="Net\WebSocketMessage.cs" />
|
||||
<Compile Include="Net\WebSocketMessageType.cs" />
|
||||
|
|
|
@ -109,7 +109,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||
|
||||
var quality = options.Quality ?? 90;
|
||||
|
||||
var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, options.OutputFormat, options.Indicator, options.PercentPlayed, options.BackgroundColor);
|
||||
var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, options.OutputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.BackgroundColor);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||
|
||||
thumbnailGraph.DrawImage(originalImage, 0, 0, newWidth, newHeight);
|
||||
|
||||
DrawIndicator(thumbnailGraph, newWidth, newHeight, options.Indicator, options.PercentPlayed);
|
||||
DrawIndicator(thumbnailGraph, newWidth, newHeight, options);
|
||||
|
||||
var outputFormat = GetOutputFormat(originalImage, options.OutputFormat);
|
||||
|
||||
|
@ -277,28 +277,31 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||
/// <param name="graphics">The graphics.</param>
|
||||
/// <param name="imageWidth">Width of the image.</param>
|
||||
/// <param name="imageHeight">Height of the image.</param>
|
||||
/// <param name="indicator">The indicator.</param>
|
||||
/// <param name="percentPlayed">The percent played.</param>
|
||||
private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageOverlay? indicator, int percentPlayed)
|
||||
/// <param name="options">The options.</param>
|
||||
private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageProcessingOptions options)
|
||||
{
|
||||
if (!indicator.HasValue)
|
||||
if (!options.AddPlayedIndicator && !options.PercentPlayed.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (indicator.Value == ImageOverlay.Played)
|
||||
var percentOffset = 0;
|
||||
|
||||
if (options.AddPlayedIndicator)
|
||||
{
|
||||
var currentImageSize = new Size(imageWidth, imageHeight);
|
||||
|
||||
new WatchedIndicatorDrawer().Process(graphics, currentImageSize);
|
||||
|
||||
percentOffset = 0 - WatchedIndicatorDrawer.IndicatorWidth;
|
||||
}
|
||||
if (indicator.Value == ImageOverlay.PercentPlayed)
|
||||
if (options.PercentPlayed.HasValue)
|
||||
{
|
||||
var currentImageSize = new Size(imageWidth, imageHeight);
|
||||
|
||||
new PercentPlayedDrawer().Process(graphics, currentImageSize, percentPlayed);
|
||||
new PercentPlayedDrawer().Process(graphics, currentImageSize, options.PercentPlayed.Value, percentOffset);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -400,7 +403,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||
/// <summary>
|
||||
/// Gets the cache file path based on a set of parameters
|
||||
/// </summary>
|
||||
private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageOutputFormat format, ImageOverlay? overlay, int percentPlayed, string backgroundColor)
|
||||
private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageOutputFormat format, bool addPlayedIndicator, int? percentPlayed, string backgroundColor)
|
||||
{
|
||||
var filename = originalPath;
|
||||
|
||||
|
@ -417,10 +420,14 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||
filename += "f=" + format;
|
||||
}
|
||||
|
||||
if (overlay.HasValue)
|
||||
if (addPlayedIndicator)
|
||||
{
|
||||
filename += "o=" + overlay.Value;
|
||||
filename += "p=" + percentPlayed;
|
||||
filename += "pl=true";
|
||||
}
|
||||
|
||||
if (percentPlayed.HasValue)
|
||||
{
|
||||
filename += "p=" + percentPlayed.Value;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(backgroundColor))
|
||||
|
|
|
@ -10,9 +10,9 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||
private const int FontSize = 30;
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
|
||||
public void Process(Graphics graphics, Size imageSize, int percent)
|
||||
public void Process(Graphics graphics, Size imageSize, int percent, int rightOffset)
|
||||
{
|
||||
var x = imageSize.Width - IndicatorWidth;
|
||||
var x = imageSize.Width - IndicatorWidth + rightOffset;
|
||||
|
||||
using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 102, 192, 16)))
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||
|
||||
var text = string.Format("{0}%", percent.ToString(_usCulture));
|
||||
|
||||
x = imageSize.Width - (percent < 10 ? 66 : 75);
|
||||
x = imageSize.Width - (percent < 10 ? 66 : 75) + rightOffset;
|
||||
|
||||
using (var font = new Font(FontFamily.GenericSansSerif, FontSize, FontStyle.Regular, GraphicsUnit.Pixel))
|
||||
{
|
||||
|
|
|
@ -5,15 +5,16 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
|||
public class WatchedIndicatorDrawer
|
||||
{
|
||||
private const int IndicatorHeight = 50;
|
||||
public const int IndicatorWidth = 50;
|
||||
private const int FontSize = 50;
|
||||
|
||||
public void Process(Graphics graphics, Size imageSize)
|
||||
{
|
||||
var x = imageSize.Width - IndicatorHeight;
|
||||
var x = imageSize.Width - IndicatorWidth;
|
||||
|
||||
using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 204, 51, 51)))
|
||||
{
|
||||
graphics.FillRectangle(backdroundBrush, x, 0, IndicatorHeight, IndicatorHeight);
|
||||
graphics.FillRectangle(backdroundBrush, x, 0, IndicatorWidth, IndicatorHeight);
|
||||
|
||||
const string text = "a";
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||
return new ChannelInfoDto
|
||||
{
|
||||
Name = info.Name,
|
||||
ServiceName = info.ServiceName
|
||||
ServiceName = info.ServiceName,
|
||||
ChannelType = info.ChannelType
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user