private void SetFanArtType(AbstractProperty property, object value) { if (MediaItem == null) { return; } if (string.IsNullOrEmpty(FanArtMediaType)) { FanArtMediaType = FanArtMediaTypes.Undefined; } if (FanArtMediaTypes.TryGetMediaItemFanArtType(MediaItem, out var detectedType)) { FanArtMediaType = detectedType; } }
public static ImageSource CreateFanArtImageSource(object source, int width, int height) { MediaItem mediaItem = source as MediaItem; if (mediaItem == null) { return(null); } // Use the ThumbnailAspect as fallback for non-ML imported MediaItems if (mediaItem.MediaItemId == Guid.Empty) { return(ImageSourceFactory.CreateMediaItemThumbnailAspectSource(source, width, height)); } string mediaType = FanArtMediaTypes.Undefined; if (FanArtMediaTypes.TryGetMediaItemFanArtType(mediaItem, out var detectedType)) { mediaType = detectedType; } // Special handling for ImageThumbs that might require rotation if (mediaItem.Aspects.ContainsKey(ImageAspect.ASPECT_ID)) { mediaType = FanArtMediaTypes.Image; } FanArtImageSource fanArtImageSource = new FanArtImageSource { FanArtMediaType = mediaType, FanArtType = FanArtTypes.Thumbnail, MaxWidth = MAX_SIZE_THUMBS, MaxHeight = MAX_SIZE_THUMBS, // Order matters here: if all arguments are complete, download will start. We control the start time by setting FanArtName after all required properties are set FanArtName = mediaItem.MediaItemId.ToString() }; return(fanArtImageSource); }