Example #1
0
        // -- Other methods
        public virtual void UpdateProgress(PlayerUpdate update)
        {
            if (update.Measure > NumberOfMeasures)
            {
                Player.Stop();
            }
            else
            {
                //if (update.Beat != CurrentBeat) CurrentBeat = update.Beat;
                //if (update.Measure != CurrentMeasure) CurrentMeasure = update.Measure;

                //// Update marker position.
                //int leftOffset = 30 + (((update.Measure % 4) - 1) * 160) + (update.Beat * 40) + (int)Math.Round((update.BeatCompleteness * 40));
                //int topOffset = 20 + (update.Measure / 4 ) * 70;
                //MarkerMargin = leftOffset + "," + topOffset + ",0,0";
            }
        }
Example #2
0
        protected virtual void WorkerCycle(DateTime now, DateTime prev)
        {
            PlayerUpdate update = new PlayerUpdate();

            // Update time sync.
            _beatSpan = _beatSpan - (now - prev);

            // Update speed.
            _beatDouble = GetBeatDurationAsSeconds(_document.TempoInt);
            _beatPeriod = TimeSpan.FromSeconds(_beatDouble);

            // If beat time has ellapsed
            if (_beatSpan <= TimeSpan.Zero)
            {
                // Add another period.
                _beatSpan += _beatPeriod;

                if (_beat == 4)
                {
                    _beat = 1;
                    _measure += 1;
                }
                else _beat++;
            }

            // Prepare update message.
            update.BeatCompleteness = (double)(((double)_beatPeriod.Ticks - (double)_beatSpan.Ticks) / (double)_beatPeriod.Ticks);
            update.Beat = _beat;
            update.Measure = _measure;

            _bgw.ReportProgress(0, update);
            Thread.Sleep(5);
        }
 public void DocumentVM_UpdateProgress_SendsStopIfFinished()
 {
     PlayerUpdate update = new PlayerUpdate
     {
         Beat = 4,
         Measure = 5,
         BeatCompleteness = 0
     };
     FakeDocumentViewModel document = new FakeDocumentViewModel();
     document.ChordLines.Add(new ChordLine());
     document.UpdateProgress(update);
     var stopDidRun = (document.GetPlayer() as StubbDocumentPlayer).StopWasRun;
     Assert.IsTrue(stopDidRun, "Stop should have been run, since the player was done playing.");
 }
 public override void UpdateProgress(PlayerUpdate update)
 {
     HasBeenUpdated = true;
     Player.Pause();
 }