예제 #1
0
        public async void GoForward()
        {
            if (CurrentPlaylist == null || CurrentPlaylist.Tracks.Count == 0)
            {
                return;
            }
            PlayableBase nextTrack;

            if (Queue.HasTracks)
            {
                var tuple = Queue.PlayNextTrack();
                nextTrack       = tuple.Item1;
                CurrentPlaylist = tuple.Item2;
            }
            else
            {
                int currenttrackindex = CurrentPlaylist.Tracks.IndexOf(CSCoreEngine.CurrentTrack);
                int nexttrackindex    = currenttrackindex;
                if (CheckIfTracksExists(CurrentPlaylist))
                {
                    if (IsShuffleEnabled)
                    {
                        nextTrack = CurrentPlaylist.GetRandomTrack(CSCoreEngine.CurrentTrack);
                        if (nextTrack == null)
                        {
                            return;
                        }
                    }
                    else
                    {
                        while (true)
                        {
                            nexttrackindex++;
                            if (CurrentPlaylist.Tracks.Count - 1 < nexttrackindex)
                            {
                                nexttrackindex = 0;
                            }
                            if (CurrentPlaylist.Tracks[nexttrackindex].TrackExists)
                            {
                                break;
                            }
                        }
                        nextTrack = CurrentPlaylist.Tracks[nexttrackindex];
                    }
                }
                else
                {
                    return;
                }
            }

            if (await CSCoreEngine.OpenTrack(nextTrack))
            {
                CSCoreEngine.TogglePlayPause();
            }
        }
예제 #2
0
 async void CSCoreEngine_TrackFinished(object sender, EventArgs e)
 {
     if (IsLoopEnabled)
     {
         if (await CSCoreEngine.OpenTrack(CSCoreEngine.CurrentTrack))
         {
             CSCoreEngine.TogglePlayPause();
         }
     }
     else
     {
         GoForward();
     }
 }
예제 #3
0
        public async void PlayTrack(PlayableBase track, IPlaylist playlist)
        {
            CSCoreEngine.StopPlayback();

            if (Queue.HasTracks && Queue.FirstOrDefault(t => t.TrackID == track.AuthenticationCode) != null)
            {
                Queue.RemoveTrack(track);
            }

            if (await CSCoreEngine.OpenTrack(track))
            {
                CSCoreEngine.TogglePlayPause();
                CurrentPlaylist = playlist;
            }
        }
예제 #4
0
        public async void GoBackward()
        {
            if (CurrentPlaylist == null || CurrentPlaylist.Tracks.Count == 0)
            {
                return;
            }
            PlayableBase newtrack;

            if (Lasttracks.Count > 1) //Check if there are more than two tracks, because the current track is the last one in the list
            {
                Lasttracks.Remove(Lasttracks.Last(x => x.Track == CSCoreEngine.CurrentTrack));
                newtrack        = Lasttracks.Last().Track;
                CurrentPlaylist = Lasttracks.Last().Playlist;
            }
            else
            {
                int currenttrackindex = CurrentPlaylist.Tracks.IndexOf(CSCoreEngine.CurrentTrack);
                int nexttrackindex    = currenttrackindex;
                if (CheckIfTracksExists(CurrentPlaylist))
                {
                    while (true)
                    {
                        nexttrackindex--;
                        if (0 > nexttrackindex)
                        {
                            nexttrackindex = CurrentPlaylist.Tracks.Count - 1;
                        }
                        if (CurrentPlaylist.Tracks[nexttrackindex].TrackExists)
                        {
                            break;
                        }
                    }
                }
                _openedTrackWithStandardBackward = true;
                newtrack = CurrentPlaylist.Tracks[nexttrackindex];
            }

            CSCoreEngine.StopPlayback();
            if (await CSCoreEngine.OpenTrack(newtrack))
            {
                CSCoreEngine.TogglePlayPause();
            }
        }