Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public void PlayNext()
        {
            if (Queue.Count() < 1)
            {
                return;
            }

            SongItem song = GetNext();

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

            AddHistory(song);

            AudioFile = new AudioFileReader(song.Path);

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

            timer.Start();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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(" -- ");
        }