- // Subscribe to 4a events
- m_client.call("ahl-4a", "subscribe", QJsonValue(), [this](bool r, const QJsonValue&) {
- if (r) qDebug() << "MasterVolume::onClientConnected - subscribed to 4a events!";
- else qCritical () << "MasterVolume::onClientConnected - Failed to subscribe to 4a events!";
+ QJsonObject arg;
+ arg.insert("control", "Master");
+ m_client.call("audiomixer", "volume", arg, [this](bool r, const QJsonValue& v) {
+ if (r && v.isObject()) {
+ int volume = v.toObject()["response"].toObject()["volume"].toDouble() * 100;
+ volume = qBound(0, volume, 100);
+ if (m_volume != volume)
+ {
+ m_volume = volume;
+ emit VolumeChanged();
+ }
+ }
+
+ QJsonObject arg;
+ arg.insert("event", "volume_changed");
+ m_client.call("audiomixer", "subscribe", arg);