示例#1
0
        public static void playRandomFromFolder(string relpath, bool checkIfInLast)
        {
            try
            {
                string        currentdir = Environment.CurrentDirectory;
                string[]      Files      = Directory.GetFiles(currentdir + relpath);
                Random        randNum    = new Random();
                List <string> list_paths = (from c in lastFiveActive select c.FileName).ToList();

                string randomFile = "";
                int    i          = 0;
                while (true)
                {
                    int zufall = randNum.Next(0, Files.Length);
                    if (!list_paths.Contains(Files[zufall]) || i > 10)
                    {
                        randomFile = Files[zufall];
                        break;
                    }
                }

                MP3Player playIt = new MP3Player();
                playIt.Open(randomFile);
                playIt.Play();
            }
            catch (Exception ersr)
            {
                //  MessageBox.Show(err.Message);
            }
        }
示例#2
0
 private void stackLastFive(MP3Player latest)
 {
     if (lastFiveActive.Count() > 5)
     {
         lastFiveActive.Reverse();
         lastFiveActive = lastFiveActive.Take(4).ToList();
     }
     lastFiveActive.Add(latest);
 }