public void SetMediaPlayerSongPositionTest() { var playControlViewModel = new PlayControlViewModel(); playControlViewModel.mediaPlayer.Open(new Uri(path)); Thread.Sleep(200); playControlViewModel.SliderDurationValue = 0; playControlViewModel.SetMediaPlayerSongPosition(); Assert.AreEqual(0, playControlViewModel.GetActualSongSecond()); playControlViewModel.SliderDurationValue = 2; playControlViewModel.SetMediaPlayerSongPosition(); Assert.AreEqual(5, playControlViewModel.GetActualSongSecond()); }
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(); } }