public void ShouldGetAllFilteredTracksByName()
        {
            List <TrackViewModel> _Track = repos.SearchTrackByName("Track1");
            var _TrackId = _Track.Find(i => i.TrackName == "Track1").TrackId;

            Assert.AreEqual(1, _TrackId);
        }
Exemple #2
0
 public ActionResult PlayLocal(int ID)
 {
     using (var context = new Uow(this.context))
     {
         List <TrackViewModel> ThisTrack = new List <TrackViewModel>();
         var repos = new RepositoryTrack(context);
         ThisTrack.Add(repos.SearchTrackByName("").Find(i => i.TrackId == ID));
         return(PartialView(ThisTrack));
     }
 }
Exemple #3
0
 public ActionResult TrackData(int ID)
 {
     using (var context = new Uow(this.context))
     {
         TrackViewModel ThisTrack;
         var            repos = new RepositoryTrack(context);
         ThisTrack = (repos.SearchTrackByName("").Find(i => i.TrackId == ID));
         return(PartialView(ThisTrack));
     }
 }
Exemple #4
0
        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();
                        }
                    }
                }
            }
        }