本文整理汇总了C#中IApiClient.GetImageUrl方法的典型用法代码示例。如果您正苦于以下问题:C# IApiClient.GetImageUrl方法的具体用法?C# IApiClient.GetImageUrl怎么用?C# IApiClient.GetImageUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApiClient
的用法示例。
在下文中一共展示了IApiClient.GetImageUrl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImages
/// <summary>
/// Gets the images.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="apiClient">The API client.</param>
/// <param name="imageWidth">Width of the image.</param>
/// <param name="imageHeight">Height of the image.</param>
/// <param name="includeNonBackdrops">if set to <c>true</c> [include non backdrops].</param>
/// <returns>List{System.String}.</returns>
public static List<string> GetImages(BaseItemDto item, IApiClient apiClient, int? imageWidth, int? imageHeight, bool includeNonBackdrops)
{
var images = new List<string> { };
if (item.BackdropCount > 0)
{
for (var i = 0; i < item.BackdropCount; i++)
{
images.Add(apiClient.GetImageUrl(item, new ImageOptions
{
ImageType = ImageType.Backdrop,
ImageIndex = i,
Width = imageWidth,
Height = imageHeight
}));
}
}
if (includeNonBackdrops)
{
if (item.HasThumb)
{
images.Add(apiClient.GetImageUrl(item, new ImageOptions
{
ImageType = ImageType.Thumb,
Width = imageWidth,
Height = imageHeight
}));
}
if (item.HasArtImage)
{
images.Add(apiClient.GetImageUrl(item, new ImageOptions
{
ImageType = ImageType.Art,
Width = imageWidth,
Height = imageHeight
}));
}
if (item.HasDiscImage)
{
images.Add(apiClient.GetImageUrl(item, new ImageOptions
{
ImageType = ImageType.Disc,
Width = imageWidth,
Height = imageHeight
}));
}
if (item.HasMenuImage)
{
images.Add(apiClient.GetImageUrl(item, new ImageOptions
{
ImageType = ImageType.Menu,
Width = imageWidth,
Height = imageHeight
}));
}
if (item.HasBoxImage)
{
images.Add(apiClient.GetImageUrl(item, new ImageOptions
{
ImageType = ImageType.Box,
Width = imageWidth,
Height = imageHeight
}));
}
if (item.HasBoxImage)
{
images.Add(apiClient.GetImageUrl(item, new ImageOptions
{
ImageType = ImageType.Box,
Width = imageWidth,
Height = imageHeight
}));
}
if (item.HasBoxRearImage)
{
images.Add(apiClient.GetImageUrl(item, new ImageOptions
{
ImageType = ImageType.BoxRear,
Width = imageWidth,
Height = imageHeight
}));
}
}
//.........这里部分代码省略.........
示例2: GetImageAddToList
private async Task GetImageAddToList(BaseItemDto item, IApiClient apiClient, List<Stream> list)
{
try
{
var options = new ImageOptions
{
ImageType = ImageType.Primary,
MaxWidth = 112,
Quality = Constants.ImageQuality,
EnableImageEnhancers = false
};
var url = apiClient.GetImageUrl(item, options);
using (var client = CreateClient())
{
var response = await client.GetAsync(url);
var stream = await response.Content.ReadAsStreamAsync();
list.Add(stream);
}
}
catch (HttpException ex)
{
_logger.ErrorException("CreateNewWideTileAsync()", ex);
}
}
示例3: GetDtoImage
private static object GetDtoImage(BaseItemDto item, string imageType, IApiClient apiClient)
{
if (item.ImageTags.IsNullOrEmpty() && item.BackdropImageTags.IsNullOrEmpty())
{
return "";
}
var imageOptions = new ImageOptions
{
EnableImageEnhancers = App.SpecificSettings.EnableImageEnhancers,
Quality = Constants.ImageQuality,
MaxHeight = 336,
ImageType = ImageType.Primary
};
if (item.Type == "Recording")
{
imageOptions.MaxHeight = 250;
}
else if (item.Type == "Program")
{
imageOptions.MaxHeight = 250;
}
else if (imageType.Equals("logo", StringComparison.OrdinalIgnoreCase))
{
imageOptions.ImageType = ImageType.Logo;
}
else if (imageType.Equals("backdrop"))
{
imageOptions.MaxHeight = 800;
imageOptions.ImageType = ImageType.Backdrop;
var images = apiClient.GetBackdropImageUrls(item, imageOptions);
if (!images.IsNullOrEmpty())
{
return images.FirstOrDefault();
}
}
else if (imageType.Equals("primaryorbackdrop"))
{
if (!item.HasPrimaryImage)
{
imageOptions.MaxHeight = 800;
imageOptions.ImageType = ImageType.Backdrop;
var images = apiClient.GetBackdropImageUrls(item, imageOptions);
if (!images.IsNullOrEmpty())
{
return images.FirstOrDefault();
}
}
}
else if (imageType.Equals("backdropsmall", StringComparison.OrdinalIgnoreCase))
{
imageOptions.MaxHeight = 336;
imageOptions.ImageType = ImageType.Backdrop;
var images = apiClient.GetBackdropImageUrls(item, imageOptions);
if (!images.IsNullOrEmpty())
{
return images.FirstOrDefault();
}
}
else if (imageType.Equals("banner", StringComparison.OrdinalIgnoreCase))
{
imageOptions.MaxHeight = 140;
imageOptions.ImageType = ImageType.Banner;
}
else if (imageType.Equals("art", StringComparison.OrdinalIgnoreCase))
{
imageOptions.ImageType = ImageType.Art;
}
else if (imageType.Equals("thumbnail", StringComparison.OrdinalIgnoreCase))
{
imageOptions.ImageType = ImageType.Thumb;
}
else if (imageType.Equals("icon", StringComparison.OrdinalIgnoreCase))
{
imageOptions.MaxHeight = 159;
}
else if (imageType.Equals("poster", StringComparison.OrdinalIgnoreCase))
{
imageOptions.MaxHeight = 675;
}
else if (imageType.Equals("episode", StringComparison.OrdinalIgnoreCase))
{
imageOptions.MaxHeight = 382;
}
else
{
imageOptions.MaxHeight = 300;
}
try
{
string url = item.Type == "Series" ? apiClient.GetImageUrl(item.Id, imageOptions) : apiClient.GetImageUrl(item, imageOptions);
return url;
}
catch
{
return "";
//.........这里部分代码省略.........
示例4: GetImageStream
private async Task GetImageStream(IApiClient apiClient, BaseItemDto item, List<Stream> list)
{
var url = apiClient.GetImageUrl(item, CollageOptions);
try
{
using (var client = TileService.CreateClient())
{
var response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync();
list.Add(stream);
}
}
}
catch (HttpException ex)
{
_logger.ErrorException("GetImageStream()", ex);
}
list = null;
}
示例5: DownloadImage
private async Task DownloadImage(IApiClient apiClient,
string serverId,
string itemId,
string imageTag,
ImageType imageType,
CancellationToken cancellationToken)
{
var hasImage = await _localAssetManager.HasImage(serverId, itemId, imageTag).ConfigureAwait(false);
if (hasImage)
{
return;
}
var url = apiClient.GetImageUrl(itemId, new ImageOptions
{
ImageType = imageType,
Tag = imageTag
});
using (var response = await apiClient.GetResponse(url, cancellationToken).ConfigureAwait(false))
{
await _localAssetManager.SaveImage(serverId, itemId, imageTag, response.Content).ConfigureAwait(false);
}
}