public void IntiFile(MusicElement file) { //stop a song currently playing this.StopAndCloseStream(); //and close the stream of current song if (!System.IO.File.Exists(file.Path))//if file not exsist than return { return; } try { if (file.Type == MusicElement.Extension.MP3) { InitMP3(file.Path); } else { InitWAV(file.Path); } } catch { MessageBox.Show("Exception occurs"); ActiveStream = null; } MusicLength = ActiveStream.TotalTime.TotalSeconds; this.Play(); }
//BeforeFileButton private void BeforeExecuteMethod(object obj) { if (!IsIndexOfSelectedItemCurrent) { this.UpdateIndexOfSelectedItem(); } if (IndexOfSelectedItem <= 0) { IndexOfSelectedItem = PlayList.Count - 1; } else { IndexOfSelectedItem--; } selectedItem = PlayList[IndexOfSelectedItem]; MusicEngine.IntiFile(selectedItem); }
//NextFileButton private void NextExecuteMethod(object obj) { if (!IsIndexOfSelectedItemCurrent) { this.UpdateIndexOfSelectedItem(); } if (IndexOfSelectedItem >= PlayList.Count - 1) { IndexOfSelectedItem = 0; } else { IndexOfSelectedItem++; } selectedItem = PlayList[IndexOfSelectedItem]; MusicEngine.IntiFile(selectedItem); }