/// <summary> /// Open file for playing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MenuOpenFile_OnClick(object sender, RoutedEventArgs e) { try { var objDialog = new OpenFileDialog() { Filter = "Media files| *.mp4; *.avi; *.mp3; *.wav; *.pl" }; bool? result = objDialog.ShowDialog(); if(result == true) { var objFileInfo = new FileInfo(objDialog.FileName); //rewrite current play list _PlayList = new PlayList(); //if we opened playlist if(objFileInfo.Extension == ".pl") { _PlayList.Open(objDialog.FileName); UpdatePlayListView(); } else { //if we opened standart media file var objMediaFile = new MediaFile(objFileInfo); _PlayList.MediaFiles.Add(objMediaFile); ListBoxPlayList.Items.Add(objMediaFile); } ListBoxPlayList.SelectedIndex = 0; ListBoxPlayList_OnMouseDoubleClick(sender, null); } } catch(Exception ex) { MessageBox.Show(ex.Message); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { _Timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 1) }; _Timer.Tick += new EventHandler(dispatcherTimer_Tick); _PlayList = new PlayList(); sliderVolume.Value = mediaElement.Volume; }