示例#1
0
 protected override void OnStop()
 {
     AudioMeterEvent.Stop();
     AudioMeterEvent.Wait();
     AudioMeterEvent.Dispose();
     AudioMeterEvent = null;
 }
示例#2
0
        static AudioMeterEvent CreateAudioMeterEvent(Options options, Logger logger)
        {
            var audioMeterEvent = new AudioMeterEvent(
                options.AudioDeviceId,
                new SignalRatio {
                FieldDecibels = options.MinimumLevelDecibels
            },
                options.MinimumDuration,
                options.Period,
                options.KeepaliveInterval,
                options.KeepaliveDuration,
                logger);

            if (options.Uri != null)
            {
                var httpClient = new HttpClient(options.PayloadContentType, options.HttpUsername, options.HttpPassword, logger);
                audioMeterEvent.Sounding        += (object sender, System.EventArgs eventArgs) => { httpClient.SendHttpRequest(options.Uri, options.SoundingPayload, logger); };
                audioMeterEvent.StoppedSounding += (object sender, System.EventArgs eventArgs) => { httpClient.SendHttpRequest(options.Uri, options.StoppedSoundingPayload, logger); };
            }

            return(audioMeterEvent);
        }
示例#3
0
 protected override void OnStart(string[] args)
 {
     AudioMeterEvent = CreateAudioMeterEvent(Options, new EventLogLogger(EventLog));
     AudioMeterEvent.Start();
 }