void ButtonPlay_Click(object sender, RoutedEventArgs e) { BeepPlayer player = PlaybackEngine.Player; bool playing = player != null && player.Playing; switch (playing) { case true: PlaybackEngine.Stop(); //If playing, stop break; case false: BrowseAndPlay(); //If not playing, start break; } }
public MainWindow() { InitializeComponent(); PlaybackEngine.OnPlayerStart += b => UpdateUI(); PlaybackEngine.OnPlayerStop += (b, f) => UpdateUI(); PlaybackEngine.OnThreadStart += (f, t) => UpdateUI(); PlaybackEngine.OnPlayerStop += PlayerStop; PlaybackEngine.OnPlayerStart += PlayerStart; PlaybackEngine.OnThreadStop += t => UpdateUI(); string[] args = Environment.GetCommandLineArgs(); if (args != null && args.Length > 1) { try { FileInfo playbackFile = new FileInfo(args[1]); if (playbackFile.Exists) { LastLoadedFile = playbackFile; PlaybackEngine.Play(playbackFile); } } catch (ArgumentException) { } } }
public static void BrowseAndPlay() { OpenFileDialog ofd = new OpenFileDialog { Filter = "ABC Notation File (*.abc)|*.abc|Any File (*.*)|*.*", CheckPathExists = true, CheckFileExists = true, RestoreDirectory = true, InitialDirectory = RestorePreviousLocation().FullName, Multiselect = false, ShowReadOnly = true }; if (ofd.ShowDialog() == true) { FileInfo playbackFile = new FileInfo(ofd.FileName); if (playbackFile.Exists) { Properties.Settings.Default.PreviousLocation = playbackFile.DirectoryName; Properties.Settings.Default.Save(); LastLoadedFile = playbackFile; PlaybackEngine.Play(playbackFile); } } }
void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { PlaybackEngine.Stop(); }
void ButtonReset_Click(object sender, RoutedEventArgs e) { PlaybackEngine.Stop(); this.Restart(); }
public Form1() { InitializeComponent(); pEngine = new PlaybackEngine(); }