public void Reset()
 {
     SortedPlaylist.Clear();
     ShuffledPlaylist.Clear();
     PlayingItemIndex = NoPlayingItemIndex;
     ShuffleMode      = GroupShuffleMode.Sorted;
     RepeatMode       = GroupRepeatMode.RepeatNone;
     LastChange       = DateTime.UtcNow;
 }
Exemple #2
0
        private void RemoveTrackFromAllTracksList(AudioTrack trackToRemove)
        {
            SortedPlaylist.RemoveAt(trackToRemove.IndexSortedList);

            for (int index = trackToRemove.IndexSortedList; index < SortedPlaylist.Count; index++)
            {
                SortedPlaylist[index].IndexSortedList--;
            }
        }
Exemple #3
0
        public void ClearAudioTracks()
        {
            SortedPlaylist.Clear();

            if (ShuffledPlaylist != null)
            {
                ShuffledPlaylist.Clear();
                UnplayedTracks.Clear();
            }
        }
        public void Queue(IReadOnlyList <Guid> items)
        {
            var newItems = CreateQueueItemsFromArray(items);

            SortedPlaylist.AddRange(newItems);
            if (ShuffleMode.Equals(GroupShuffleMode.Shuffle))
            {
                ShuffledPlaylist.AddRange(newItems);
            }

            LastChange = DateTime.UtcNow;
        }
        public void RestoreSortedPlaylist()
        {
            if (PlayingItemIndex != NoPlayingItemIndex)
            {
                var playingItem = ShuffledPlaylist[PlayingItemIndex];
                PlayingItemIndex = SortedPlaylist.IndexOf(playingItem);
            }

            ShuffledPlaylist.Clear();

            ShuffleMode = GroupShuffleMode.Sorted;
            LastChange  = DateTime.UtcNow;
        }
        public void SetPlaylist(IReadOnlyList <Guid> items)
        {
            SortedPlaylist.Clear();
            ShuffledPlaylist.Clear();

            SortedPlaylist = CreateQueueItemsFromArray(items);
            if (ShuffleMode.Equals(GroupShuffleMode.Shuffle))
            {
                ShuffledPlaylist = new List <QueueItem>(SortedPlaylist);
                Shuffle(ShuffledPlaylist);
            }

            PlayingItemIndex = NoPlayingItemIndex;
            LastChange       = DateTime.UtcNow;
        }
        public void QueueNext(IReadOnlyList <Guid> items)
        {
            var newItems = CreateQueueItemsFromArray(items);

            if (ShuffleMode.Equals(GroupShuffleMode.Shuffle))
            {
                var playingItem            = GetPlayingItem();
                var sortedPlayingItemIndex = SortedPlaylist.IndexOf(playingItem);
                // Append items to sorted and shuffled playlist as they are.
                SortedPlaylist.InsertRange(sortedPlayingItemIndex + 1, newItems);
                ShuffledPlaylist.InsertRange(PlayingItemIndex + 1, newItems);
            }
            else
            {
                SortedPlaylist.InsertRange(PlayingItemIndex + 1, newItems);
            }

            LastChange = DateTime.UtcNow;
        }
        public void ClearPlaylist(bool clearPlayingItem)
        {
            var playingItem = GetPlayingItem();

            SortedPlaylist.Clear();
            ShuffledPlaylist.Clear();
            LastChange = DateTime.UtcNow;

            if (!clearPlayingItem && playingItem != null)
            {
                SortedPlaylist.Add(playingItem);
                if (ShuffleMode.Equals(GroupShuffleMode.Shuffle))
                {
                    ShuffledPlaylist.Add(playingItem);
                }

                PlayingItemIndex = 0;
            }
            else
            {
                PlayingItemIndex = NoPlayingItemIndex;
            }
        }
        public bool RemoveFromPlaylist(IReadOnlyList <Guid> playlistItemIds)
        {
            var playingItem = GetPlayingItem();

            SortedPlaylist.RemoveAll(item => playlistItemIds.Contains(item.PlaylistItemId));
            ShuffledPlaylist.RemoveAll(item => playlistItemIds.Contains(item.PlaylistItemId));

            LastChange = DateTime.UtcNow;

            if (playingItem != null)
            {
                if (playlistItemIds.Contains(playingItem.PlaylistItemId))
                {
                    // Playing item has been removed, picking previous item.
                    PlayingItemIndex--;
                    if (PlayingItemIndex < 0)
                    {
                        // Was first element, picking next if available.
                        // Default to no playing item otherwise.
                        PlayingItemIndex = SortedPlaylist.Count > 0 ? 0 : NoPlayingItemIndex;
                    }

                    return(true);
                }
                else
                {
                    // Restoring playing item.
                    SetPlayingItemByPlaylistId(playingItem.PlaylistItemId);
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemple #10
0
 public void AddAudioTrack(AudioTrack trackToAdd)
 {
     SortedPlaylist.Add(trackToAdd);
 }