/// <summary>
        /// Determines if a given external player configuration is configured to play a list of files
        /// </summary>
        public static bool CanPlay(ConfigData.ExternalPlayer player, IEnumerable <Media> mediaList)
        {
            List <MediaType>   types   = new List <MediaType>();
            List <VideoFormat> formats = new List <VideoFormat>();

            foreach (Media media in mediaList)
            {
                var video = media as Video;

                if (video != null)
                {
                    if (!string.IsNullOrEmpty(video.VideoFormat))
                    {
                        VideoFormat format = (VideoFormat)Enum.Parse(typeof(VideoFormat), video.VideoFormat);
                        formats.Add(format);
                    }

                    types.Add(video.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(ConfigData.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(ConfigData.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);
        }
        private void btnAddPlayer_Click(object sender, RoutedEventArgs e)
        {
            List<MediaType> list = new List<MediaType>();
            // Provide a list of media types that haven't been used. This is to filter out the selection available to the end user.
            // Don't display media types for players that we already have.
            //
            // This also makes this scalable, we shouldn't have to adjust this code for new media types.
            Boolean found;
            foreach (MediaType item in Enum.GetValues(typeof(MediaType)))
            {
                // See if an external player has been configured for this media type.
                found = false;
                foreach (ConfigData.ExternalPlayer player in lstExternalPlayers.Items)
                    if (player.MediaType == item) {
                        found = true;
                        break;
                    }
                // If a player hasn't been configured then make it an available option to be added
                if (!found)
                    list.Add(item);
            }

            var form = new SelectMediaTypeForm(list);
            form.Owner = this;
            form.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            if (form.ShowDialog() == true)
            {
                ConfigData.ExternalPlayer player = new ConfigData.ExternalPlayer();
                player.MediaType = (MediaType)form.cbMediaType.SelectedItem;
                player.Args = "\"{0}\""; // Assign a default parameter
                config.ExternalPlayers.Add(player);
                lstExternalPlayers.Items.Add(player);
                lstExternalPlayers.SelectedItem = player;
                SaveConfig();
            }
        }