예제 #1
0
        private void ActivateTrackItem(BufferItem item)
        {
            var tbi       = item as TrackBufferItem;
            var playQueue = buffers[0];

            if (playbackManager.PlayingTrack != null && tbi.Model.TrackPtr == playbackManager.PlayingTrack.TrackPtr)
            {
                TogglePlayPause(playbackManager.IsPaused);
                return;
            }
            ClearCurrentlyPlayingTrack();
            if (buffers.CurrentListIndex == 0 && playQueue.Contains(tbi)) // if they've picked it from the play queue
            {
                int indexOfChosenTrack = playQueue.IndexOf(tbi);
                if (indexOfChosenTrack > 0)
                {
                    var skippedTracks = playQueue.Take(indexOfChosenTrack).Cast <TrackBufferItem>().Select(i => i.Model);
                    playbackManager.PutTracksIntoPreviousTracks(skippedTracks);
                    playQueue.RemoveRange(0, indexOfChosenTrack);
                }
            }
            else
            {
                playQueue.Clear();
                playbackManager.ClearPreviousTracks();
                playQueue.Add(tbi);
                if (buffers.CurrentList is PlaylistBufferList || buffers.CurrentList is AlbumBufferList) // add the remaining playlist or album to the queue
                {
                    AddRemainingTracksToQueue(item, playQueue);
                }
            }
            PlayNewTrackBufferItem(tbi);
            if (playQueue.Any())
            {
                playQueue.CurrentItemIndex = 0;
            }
        }