private void StartPlayAt(int barIndex, bool countIn) { axWindowsMediaPlayer1.URL = GetMIDIFile(); axWindowsMediaPlayer1.Ctlcontrols.stop(); SeeScore.PlayData.IPlayData pd = GetMIDIPlayData(); int bar_ms = pd.durationUpToBar(barIndex); axWindowsMediaPlayer1.Ctlcontrols.currentPosition = (double)bar_ms / 1000.0F; DelayedStarter starter = new DelayedStarter(this, barIndex, countIn); testingDelay = true; mediaPlayerStartDelayTestStartTime = DateTime.Now; postDelayTestStartHandler = starter.postDelayTestStartHandler; axWindowsMediaPlayer1.Ctlcontrols.play(); }
// called after testing mediaplayer start delay. We start the notifier and the mediaplayer with compensation for its start delay private void StartPlayerWithDelay(TimeSpan startDelay, int barIndex, bool countIn) { SeeScore.PlayData.IPlayData pd = GetMIDIPlayData(); SeeScore.PlayData.IBarEnumerator barIter = pd.GetBarEnumerator(); barIter.ChangeToBar(barIndex); SeeScore.PlayData.IBar bar = barIter.CurrentBar(); DateTime mediaPlayerStartTime = DateTime.Now.AddMilliseconds(1000); DateTime notifierStartTime = mediaPlayerStartTime; if (countIn) { bar = bar.CreateCountIn(); mediaPlayerStartTime = notifierStartTime.AddMilliseconds(bar.Duration() - startDelay.TotalMilliseconds); } else { mediaPlayerStartTime = notifierStartTime.AddMilliseconds(-startDelay.TotalMilliseconds); } int bar_ms = pd.durationUpToBar(barIndex); axWindowsMediaPlayer1.Ctlcontrols.currentPosition = (double)bar_ms / 1000.0F; new PlayerStartDispatch(mediaPlayerStartTime, this); notifier.StartAt(notifierStartTime, barIndex, countIn);// start count-in. MediaPlayer will be started after this }