Пример #1
0
        public async Task DeleteSampleAsync(SoundboardSample soundboardSample)
        {
            try
            {
                // Recursively try to acquire file lock. This can sometimes take a few seconds to release after
                // an audio playback event has ended
                bool success = false;
                while (!success)
                {
                    try
                    {
                        AudioAgent.StopAudioPlayback(SelectedOutputDevicesCollection.ToList());
                        File.Delete(soundboardSample.FilePath);
                        SoundboardSampleCollection.Remove(soundboardSample);

                        success = true;
                    }
                    catch
                    {
                        await Task.Delay(500);
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
Пример #2
0
        private void OnAudioMeterTimerElapsed(object sender, EventArgs e)
        {
            try
            {
                if (SelectedCaptureDevicesCollection.Any())
                {
                    SelectedCaptureDevicesCollection[0].AudioPeak = (int)(WasapiLoopbackCapture.GetDefaultLoopbackCaptureDevice().AudioMeterInformation.MasterPeakValue * 100);
                }

                SelectedOutputDevicesCollection.ToList().ForEach(outputDevice =>
                {
                    outputDevice.AudioPeak = (int)(outputDevice.AudioMeterInformation?.MasterPeakValue ?? 0 * 100);
                });
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
Пример #3
0
 public void StopAudioPlayback()
 {
     AudioAgent.StopAudioPlayback(SelectedOutputDevicesCollection.ToList());
 }