/// <summary> /// Determines if a given external player configuration is configured to play a list of files /// </summary> public static bool CanPlay(CommonConfigData.ExternalPlayer player, IEnumerable <Media> mediaList) { var types = new List <MediaType>(); var formats = new List <VideoFormat>(); foreach (var media in mediaList) { var video = media as Video; if (video != null) { if (!string.IsNullOrEmpty(video.VideoFormat)) { var format = (VideoFormat)Enum.Parse(typeof(VideoFormat), video.VideoFormat); formats.Add(format); } } types.Add(media.MediaType); } bool isMultiFile = mediaList.Count() == 1 ? (mediaList.First().Files.Count() > 1) : (mediaList.Count() > 1); return(CanPlay(player, types, formats, isMultiFile)); }
/// <summary> /// Determines if a given external player configuration is configured to play a list of files /// </summary> public static bool CanPlay(CommonConfigData.ExternalPlayer player, IEnumerable <string> files) { IEnumerable <MediaType> types = files.Select(f => MediaTypeResolver.DetermineType(f)); // See if there's a configured player matching the ExternalPlayerType and MediaType. // We're not able to evaluate VideoFormat in this scenario // If none is found it will return null return(CanPlay(player, types, new List <VideoFormat>(), files.Count() > 1)); }
/// <summary> /// Detmines if a given external player configuration is configured to play: /// - ALL of MediaTypes supplied. This filter is ignored if an empty list is provided. /// - All of the VideoFormats supplied. This filter is ignored if an empty list is provided. /// - And is able to play the number of files requested /// </summary> public static bool CanPlay(CommonConfigData.ExternalPlayer externalPlayer, IEnumerable <MediaType> mediaTypes, IEnumerable <VideoFormat> videoFormats, bool isMultiFile) { // Check options to see if this is not a match if (Application.RunningOnExtender) { return(false); } // If it's not even capable of playing multiple files in sequence, it's no good if (isMultiFile && !externalPlayer.SupportsMultiFileCommandArguments && !externalPlayer.SupportsPlaylists) { return(false); } // If configuration wants specific MediaTypes, check that here // If no MediaTypes are specified, proceed foreach (MediaType mediaType in mediaTypes) { if (!externalPlayer.MediaTypes.Contains(mediaType)) { return(false); } } // If configuration wants specific VideoFormats, check that here // If no VideoFormats are specified, proceed foreach (VideoFormat format in videoFormats) { if (!externalPlayer.VideoFormats.Contains(format)) { return(false); } } return(true); }