コード例 #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 PlayAudioSample(SoundboardSample soundboardSample, PlaybackScope playbackScope)
        {
            try
            {
                var outputDevices = SelectedOutputDevicesCollection.Where(x => x.PlaybackScope >= playbackScope).ToList();
                if (outputDevices.Any())
                {
                    outputDevices[0].PlaybackStopped += OnAudioPlaybackStopped;
                    soundboardSample.StartPlaybackTimer();
                }

                outputDevices.ForEach(outputDevice =>
                {
                    AudioAgent.BeginAudioPlayback(soundboardSample.FilePath, outputDevice, (float)soundboardSample.Volume / (float)100, soundboardSample.FileTimeLowerValue, soundboardSample.FileTimeUpperValue);
                });
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
コード例 #4
0
 public void StopAudioPlayback()
 {
     AudioAgent.StopAudioPlayback(SelectedOutputDevicesCollection.ToList());
 }