private void StartPooling() { var viewPooling = new System.Timers.Timer(100); var wasPlaying = false; viewPooling.Elapsed += (source, e) => { var loadedSound = SoundFunPlayer.LoadedSound(); _menuBarModel.PlayButtonEnabled = !string.IsNullOrEmpty(loadedSound); if (!_menuBarModel.PlayButtonEnabled) { return; } _menuBarModel.NowPlaying = loadedSound; _menuBarModel.Progress = SoundFunPlayer.GetProgess(); var isPlaying = SoundFunPlayer.IsPlaying(); if (wasPlaying == isPlaying) { return; } wasPlaying = isPlaying; if (isPlaying) { _menuBarModel.SetToPauseImage(); } else { _menuBarModel.SetToPlayImage(); } }; viewPooling.AutoReset = true; viewPooling.Enabled = true; var filePooling = new System.Timers.Timer(2000); filePooling.Elapsed += (source, e) => { if (MainWindow.IsShuttingDown) { return; } Dispatcher.Invoke(() => { foreach (Control control in MainPanel.Children) { var row = control as SoundRow; row?.UpdateSoundLabelColor(); } }); }; filePooling.AutoReset = true; filePooling.Enabled = true; }
public void Update(Status status, IIsaacReader reader) { if (!status.Ready) { SoundFunPlayer.ResetTouchedItems(); _firstCheck = true; return; } var numberOfPlayers = MemoryReader.GetNumberOfPlayers(); if (numberOfPlayers == 0) { SoundFunPlayer.ResetTouchedItems(); _firstCheck = true; return; } var timerCounter = reader.GetTimeCounter(); var reseted = timerCounter < 2; // resets on hold "r" if (reseted) { SoundFunPlayer.ResetTouchedItems(); } if (reader.IsGamePaused()) { SoundFunPlayer.Pause(false); return; } // tries to resume SoundFunPlayer.Resume(false); var startCheck = reseted || _firstCheck; _firstCheck = false; SoundFunPlayer.CheckPlaySound(reader.GetItemsTouchedList(), startCheck); }
private void PlayClick(object sender, RoutedEventArgs e) { SoundFunPlayer.PlaySound(_model.File); }
private void PauseResumeClick(object sender, RoutedEventArgs e) { SoundFunPlayer.PausePlay(); }