Exemplo n.º 1
0
        private void PublishAudio(bool DiscoveryPacket = false)
        {
            if (DiscoveryPacket == true)
            {
                string     fullltopic  = _mqtt.FullTopic("switch/mute");
                MqttConfig _MqttConfig = new MqttConfig();
                _MqttConfig.device_class = "switch";
                _MqttConfig.name         = MqttSettings.MqttTopic + "switch-mute";
                _MqttConfig.state_topic  = fullltopic + "/set";
                string configTopic   = "switch/mute/config";
                string ConfigPayload = JsonConvert.SerializeObject(_MqttConfig, Newtonsoft.Json.Formatting.None, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                });
                _mqtt.Publish(configTopic, ConfigPayload);
            }



            _mqtt.Publish("volume", _audioobj.GetVolume(), true);

            try
            {
                if (_audioobj.IsMuted() == true)
                {
                    _mqtt.Publish("mute", "1");
                }
                else
                {
                    _mqtt.Publish("mute", "0");
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
        private void PublishAudio()
        {
            _mqtt.Publish("volume", _audioobj.GetVolume(), true);

            try
            {
                if (_audioobj.IsMuted() == true)
                {
                    _mqtt.Publish("mute", "1");
                }
                else
                {
                    _mqtt.Publish("mute", "0");
                }
            }
            catch (Exception)
            {
            }
        }