public void CalculateSliderValueTest() { var playControlViewModel = new PlayControlViewModel(); Assert.AreEqual(0, playControlViewModel.CalculateSliderValue()); playControlViewModel.mediaPlayer.Open(new Uri(path)); Thread.Sleep(200); Assert.AreNotEqual(0, playControlViewModel.GetSongSecondsCount()); playControlViewModel.mediaPlayer.Position = TimeSpan.FromSeconds(127); Assert.AreEqual(50, playControlViewModel.CalculateSliderValue()); }
private void timeSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (playControlViewModel.GetSongSecondsCount() > 0) { Slider slider = sender as Slider; playControlViewModel.SetMediaPlayerSongPosition(); ControlExtensions.InvokeIfRequired(this, (x) => { durationSlider.Value = x; sliderNewValue = playControlViewModel.CalculateSliderValue(); }, sliderNewValue); playControlViewModel.PlayOrPauseSong(); } }