void timer_Tick(object sender, EventArgs e) { try { if (Vidoe_MediaElement.Source != null) { if (Vidoe_MediaElement.NaturalDuration.HasTimeSpan) { if (Convert.ToInt32(Vidoe_MediaElement.NaturalDuration.TimeSpan.TotalSeconds) != SliderVideo.Value) { lblStatus.Content = String.Format("{0} / {1}", Vidoe_MediaElement.Position.ToString(@"mm\:ss"), Vidoe_MediaElement.NaturalDuration.TimeSpan.ToString(@"mm\:ss")); SliderVideo.Value = Vidoe_MediaElement.Position.TotalSeconds; SliderVideo.Maximum = Convert.ToInt32(Vidoe_MediaElement.NaturalDuration.TimeSpan.TotalSeconds); } else { btnPlay.Visibility = Visibility.Visible; btnPause.Visibility = Visibility.Collapsed; SliderVideo.Value = 0; Vidoe_MediaElement.Stop(); timer.Stop(); } } } else { lblStatus.Content = LocalResources.Label2_No_file_selected + "..."; } } catch (Exception exception) { Console.WriteLine(exception); } }
private void Close_OnClick(object sender, RoutedEventArgs e) { try { timer.Stop(); Vidoe_MediaElement.Stop(); this.Close(); } catch (Exception exception) { Console.WriteLine(exception); } }