Пример #1
0
        public void PlayTrack(QueuedTrack trackToPlay)
        {
            logger.Trace("MusicService.PlayTrack");
            logger.Debug("Attempting to play track {0}", trackToPlay.ToLoggerFriendlyTrackName());

            //Reset the paused data
            lastPaused          = null;
            totalPausedDuration = 0;

            currentProvider = musicProviderFactory.GetMusicProviderByIdentifier(trackToPlay.Track.MusicProvider.Identifier);

            //Either play the original queued track or the Big Rick if tthe track is rickrolled
            var rickRollTrack = rickRollService.RickRoll(trackToPlay.Track, trackToPlay.User);

            currentProvider.PlayTrack(rickRollTrack);
            trackToPlay.StartedPlayingDateTime = nowHelper.Now;
            queuedTrackDataService.InsertOrUpdate(trackToPlay);
            int total;
            var recentlyPlayed = queuedTrackDataService.GetAll()
                                 .GetQueuedTracksByUser(null, 1, 5, out total)
                                 .Select(r => alreadyQueuedHelper.ResetAlreadyQueued(r, trackToPlay.User)).ToList();

            callbackClient.TrackHistoryChanged(new PagedResult <QueuedTrack> {
                HasMorePages = false, PageData = recentlyPlayed
            });

            currentlyPlayingTrack = trackToPlay;
            callbackClient.PlayingTrackChanged(CurrentlyPlayingTrack);
            logger.Debug("Playing track {0} queued by {1}", trackToPlay.ToLoggerFriendlyTrackName(), trackToPlay.User);
        }