public HttpResponseMessage GetPlaying() { IEnumerable <PlayHistoryViewModel> playHistory; playHistory = _playHistory.GetCurrentlyPlaying().Select(i => i.ToAPIModel()); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JsonConvert.SerializeObject(playHistory), System.Text.Encoding.UTF8, "application/json"); return(response); }
public ActionResult GetCurrentlyPlaying() { using (var context = new Uow(this.context)) { var repos = new RepositoryPlayHistory(context); var item = repos.GetCurrentlyPlaying(); AuthHelper _ah = new AuthHelper(context); ViewBag.ThisUser = _ah.GetHostName().ToLower(); return(PartialView(item)); } }
public bool IsPlayingTrack() { return(repo.GetCurrentlyPlaying().Any()); }
public void ShouldGetCurrentlyPlayingTrack() { var items = repos.GetCurrentlyPlaying(); Assert.IsTrue(items.Count == 1); }
static void Main(string[] args) { int JukeBoxWakeUp = 8; int JukeBoxSleep = 18; Console.CursorVisible = false; Player = new WMPLib.WindowsMediaPlayer(); Player.settings.volume = 50; var sleepTimer = 0; var jukeBoxOffset = 0; using (var _uow = new Uow(new MusicFarmerEntities())) { var currentVolume = 0; RepositoryPlayHistory repo; RepositoryVote repoVote; var spin = new ConsoleSpinner(); while (true) { repo = new RepositoryPlayHistory(_uow); repoVote = new RepositoryVote(_uow); var currentList = repo.GetCurrentlyPlaying(); PlayHistoryViewModel _CurrentTrack = currentList.FirstOrDefault(); if (!currentList.Any()) { if (repo.GetCurrentlyQueued().Any()) { _CurrentTrack = repo.GetCurrentlyQueued().FirstOrDefault(); repo.SetTrackToPlay(_CurrentTrack.PlayHistoryId); } else { Console.Write("\rThe DJ has left the building... "); spin.SleepTurn(); Thread.Sleep(1000); if (DateTime.Now.Hour >= JukeBoxWakeUp && DateTime.Now.Hour <= JukeBoxSleep) { sleepTimer += 1; if (sleepTimer >= 20) { var jukeBoxRepo = new RepositoryJukeBox(_uow); List <JukeBoxViewModel> items = jukeBoxRepo.GetJukeBoxTracks(); JukeBoxViewModel jbvm = items.ElementAt(jukeBoxOffset); repo.Queue(jbvm.TrackId); jukeBoxOffset += 1; if (jukeBoxOffset > items.Count()) { jukeBoxOffset = 0; } } } } } else { RepositoryTrack repoTrack = new RepositoryTrack(_uow); var nextSong = repoTrack.SearchTrackByName("").Find(i => i.TrackId == _CurrentTrack.TrackId).TrackURL; Uri songUri = new Uri(nextSong); Player.URL = nextSong; Player.controls.play(); while (Player.playState == WMPPlayState.wmppsPlaying || Player.playState == WMPPlayState.wmppsBuffering || Player.playState == WMPPlayState.wmppsTransitioning) { sleepTimer = 0; _CurrentTrack = repo.GetCurrentlyPlaying().FirstOrDefault(); Thread.Sleep(500); //Console.WriteLine("{0}", _CurrentTrack == null ? "" : _CurrentTrack.TrackName); Console.Write("\r{0} / {1} Volume level: ({3})", Player.controls.currentPositionString, Player.currentMedia.durationString, _CurrentTrack == null ? "" : _CurrentTrack.TrackName, Player.settings.volume.ToString()); DJDrop(Player.controls.currentPosition, Player.currentMedia.duration); spin.Turn(); try { if ((_CurrentTrack.PlayCompleted == true) || (_CurrentTrack == null)) { Console.Clear(); break; } } catch { Player.controls.stop(); Console.Clear(); break; } var currentVotes = repoVote.GetUpVotes(_CurrentTrack.PlayHistoryId).Count - repoVote.GetDownVotes(_CurrentTrack.PlayHistoryId).Count; if (currentVotes < 0) { VolumeDown(50, currentVotes); } else if (currentVotes > 0) { VolumeUp(50, currentVotes); } else { Player.settings.volume = 50; } } if (_CurrentTrack != null) { repo.AnonSetTrackToStop(_CurrentTrack.PlayHistoryId); Console.Clear(); } } } } }