Пример #1
0
 private void Audio_AddToQueue_Click(object sender, RoutedEventArgs e)
 {
     if (AudioItemList.SelectedIndex >= 0)
     {
         ape.Play(AudioItemList.SelectedIndex, "STARK");
     }
 }
Пример #2
0
        private void TryParsePlay(string line)
        {
            if (ape != null)
            {
                var    parts  = getParts(line, playCmd);
                string player = getPlayer(parts[0]);
                string arg    = parts[1];

                Func <bool> tryPlayByTitle = () => {
                    if (!string.IsNullOrEmpty(arg) && !string.IsNullOrWhiteSpace(arg))
                    {
                        foreach (AudioPlaybackItem item in afm.getCollection())
                        {
                            if (item.name.ToLower() == arg.ToLower())
                            {
                                return(true);
                            }
                        }
                    }

                    return(false);
                };
                bool canPlayByTitle = tryPlayByTitle();

                Func <bool> tryPlayByTag = () => {
                    if (!string.IsNullOrEmpty(arg) && !string.IsNullOrWhiteSpace(arg))
                    {
                        foreach (AudioPlaybackItem item in afm.getCollection())
                        {
                            foreach (string tag in item.tags)
                            {
                                if (tag.ToLower() == arg.ToLower())
                                {
                                    return(true);
                                }
                            }
                        }
                    }


                    return(false);
                };
                bool canPlayByTag = tryPlayByTag();

                string arg1 = new StringBuilder(parts[1]).ToString();
                int    id;
                if (int.TryParse(arg1, out id) && id >= 0)
                {
                    if (id < afm.getCollection().Count)
                    {
                        ape.Play(id, player);
                    }
                }
                else if (canPlayByTitle)
                {
                    foreach (AudioPlaybackItem item in afm.getCollection())
                    {
                        if (item.name.ToLower() == parts[1].ToLower())
                        {
                            ape.Play(item.id, player);
                        }
                    }
                }
                else if (canPlayByTag)
                {
                    foreach (AudioPlaybackItem item in afm.getCollection())
                    {
                        foreach (string tag in item.tags)
                        {
                            if (tag.ToLower() == arg.ToLower())
                            {
                                ape.Play(item.id, player);
                            }
                        }
                    }
                }
            }
        }