Ejemplo n.º 1
0
        private void VetoCurrentTrack(Guid queuedTrackId, string user)
        {
            var foundTrack = musicPlayer.CurrentlyPlayingTrack;

            if (foundTrack == null || foundTrack.Id != queuedTrackId)
            {
                return;
            }

            if (vetoHelper.CantVetoTrack(user, foundTrack))
            {
                return;
            }

            foundTrack.Vetoes = foundTrack.Vetoes.ToList();
            foundTrack.Vetoes.Add(new Veto {
                ByUser = user
            });
            queuedTrackDataService.Update(foundTrack);
            logger.Info("Track {0} vetoed by {1}", foundTrack.ToLoggerFriendlyTrackName(), user);
            var requiredVetos = skipHelper.RequiredVetoCount(foundTrack);

            soundBoardService.PlayFinishHim(requiredVetos, foundTrack);
            if (foundTrack.Vetoes.Count >= requiredVetos)
            {
                SkipTrackViaMaxVetoesExceeded(queuedTrackId, user);
                logger.Info("Maximum vetoes reached on track {0}. Skipping", foundTrack.ToLoggerFriendlyTrackName());
                foundTrack.IsSkipped = true;
            }
            else
            {
                callbackClient.PlayingTrackChanged(foundTrack);
            }
        }
Ejemplo n.º 2
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);
        }