public void Enqueue(PlaylistItem playlistItem, PlaylistQueueFlags flags) { var playlist = this.GetPlaylist(playlistItem); var queue = default(List <PlaylistItem>); if (this.Queue.TryGetValue(playlist, out queue)) { //TODO: We should use WaitAsync for >NET40. this.Semaphore.Wait(); try { queue.Remove(playlistItem); if (queue.Count == 0) { this.Queue.TryRemove(playlist); } } finally { this.Semaphore.Release(); } } switch (flags) { case PlaylistQueueFlags.None: this.Queue.GetOrAdd(playlist, key => new List <PlaylistItem>()).Add(playlistItem); break; case PlaylistQueueFlags.Next: this.Queue.GetOrAdd(playlist, key => new List <PlaylistItem>()).Insert(0, playlistItem); break; } }
public void Enqueue(IEnumerable <PlaylistItem> playlistItems, PlaylistQueueFlags flags) { if (flags == PlaylistQueueFlags.Next) { playlistItems = playlistItems.Reverse(); } foreach (var playlistItem in playlistItems) { this.Enqueue(playlistItem, flags); } }