public CachedSoundSampleProvider(CachedSound cachedSound) { this.cachedSound = cachedSound; }
public void PlaySound(CachedSound sound) { AddMixerInput(new CachedSoundSampleProvider(sound)); }
protected override void OnStartup(StartupEventArgs evtArgs) { const string appName = "fiphwinfo"; _mutex = new Mutex(true, appName, out var createdNew); if (!createdNew) { //app is already running! Exiting the application Current.Shutdown(); } GetExePath(); base.OnStartup(evtArgs); log4net.Config.XmlConfigurator.Configure(); _clickSound = null; if (File.Exists(Path.Combine(ExePath, "appSettings.config")) && ConfigurationManager.GetSection("appSettings") is NameValueCollection appSection) { if (File.Exists(Path.Combine(ExePath, "Sounds", appSection["clickSound"]))) { try { _clickSound = new CachedSound(Path.Combine(ExePath, "Sounds", appSection["clickSound"])); } catch (Exception ex) { _clickSound = null; Log.Error($"CachedSound: {ex}"); } } } //create the notifyicon (it's a resource declared in NotifyIconResources.xaml _notifyIcon = (TaskbarIcon)FindResource("NotifyIcon"); _notifyIcon.IconSource = new BitmapImage(new Uri("pack://*****:*****@"Data\hwinfo.json"); } Dispatcher.Invoke(() => { var window = Current.MainWindow = new MainWindow(); window.ShowActivated = false; }); splashScreen.Dispatcher.Invoke(() => splashScreen.ProgressText.Text = "Initializing FIP..."); if (!FipHandler.Initialize()) { Current.Shutdown(); } Log.Info("fiphwinfo started"); Dispatcher.Invoke(() => { var window = Current.MainWindow; window?.Hide(); }); Dispatcher.Invoke(() => { splashScreen.Close(); }); var hwInfoToken = _hwInfoTokenSource.Token; HWInfoTask = Task.Run(async() => { var result = await MQTT.Connect(); Log.Info("HWInfo task started"); while (true) { if (hwInfoToken.IsCancellationRequested) { hwInfoToken.ThrowIfCancellationRequested(); } HWInfo.ReadMem("HWINFO.INC"); FipHandler.RefreshHWInfoPages(); await Task.Delay(5 * 1000, _hwInfoTokenSource.Token); // repeat every 5 seconds } }, hwInfoToken); }); }