示例#1
0
        private SongItem GetNext()
        {
            if (Queue.Count < 1)
            {
                return(null);
            }

            switch (PlayMode)
            {
            case 0:
                if (Queue.Count > 1)
                {
                    // since .Move cannot move to the last index
                    // (learned this the hard way)
                    SongItem tmp = Queue[0];
                    Queue.RemoveAt(0);
                    Queue.Add(tmp);
                }
                return(Queue[0]);

            case 1:
                int rnd = new Random().Next(0, Queue.Count());
                return(Queue.ElementAt(rnd));

            case 2:
                return(Queue[0]);
            }

            return(null);
        }
示例#2
0
        public void PlayNext()
        {
            if (Queue.Count() < 1)
            {
                return;
            }

            SongItem song = GetNext();

            WavePlay(song);
        }
示例#3
0
 public void AddNext(SongItem song)
 {
     if (Queue.Contains(song))
     {
         Queue.Move(Queue.IndexOf(song), 1);
     }
     else
     {
         Queue.Insert(1, song);
     }
 }
示例#4
0
 public void Add(SongItem song)
 {
     if (Queue.Contains(song))
     {
         Queue.Move(Queue.IndexOf(song), 0);
     }
     else
     {
         Queue.Add(song);
     }
 }
示例#5
0
        private void WavePlay(SongItem song)
        {
            StopPlayBack();

            AddHistory(song);

            AudioFile = new AudioFileReader(song.Path);

            WavePlayer.Init(AudioFile);
            WavePlayer.Play();

            timer.Start();
        }
示例#6
0
        private void AddHistory(SongItem item)
        {
            if (History.Count == MaxHistory)
            {
                History.RemoveAt(MaxHistory - 1);
            }

            if (History.Contains(item))
            {
                History.Remove(item);
            }

            History.Insert(0, item);
        }
示例#7
0
        public void PlayNow(SongItem song)
        {
            WavePlay(song);

            // make the new song as the first one
            if (Queue.Contains(song))
            {
                Queue.Move(Queue.IndexOf(song), 0);
            }
            else
            {
                Queue.Insert(0, song);
            }

            for (int i = 0; i < Queue.Count; i++)
            {
                Console.WriteLine(i + " - " + Queue[i].Name);
            }

            Console.WriteLine(" -- ");
        }