added preset activation

master
Boernsman 2020-02-14 16:21:56 +05:00
parent 8a23a4dc59
commit 6026f487c1
2 changed files with 48 additions and 3 deletions

View File

@ -242,15 +242,38 @@ void DevicePluginBose::executeAction(DeviceActionInfo *info)
QUuid requestId;
QString status = action.param(soundtouchPlaybackStatusActionPlaybackStatusParamTypeId).value().toString();
if (status == "Playing") {
soundTouch->setKey(KEY_VALUE::KEY_VALUE_PLAY);
requestId = soundTouch->setKey(KEY_VALUE::KEY_VALUE_PLAY);
} else if (status == "Paused") {
soundTouch->setKey(KEY_VALUE::KEY_VALUE_PAUSE);
requestId = soundTouch->setKey(KEY_VALUE::KEY_VALUE_PAUSE);
} else if (status == "Stopped") {
soundTouch->setKey(KEY_VALUE::KEY_VALUE_STOP);
requestId = soundTouch->setKey(KEY_VALUE::KEY_VALUE_STOP);
}
m_pendingActions.insert(requestId, info);
connect(info, &DeviceActionInfo::aborted, this, [requestId, this] {m_pendingActions.remove(requestId);});
} else if (action.actionTypeId() == soundtouchActivatePresetActionTypeId) {
QUuid requestId;
QString preset = action.param(soundtouchActivatePresetActionPresetNumberParamTypeId).value().toString();
if (preset.contains("1")) {
requestId = soundTouch->setKey(KEY_VALUE::KEY_VALUE_PRESET_1);
} else if (preset.contains("2")) {
requestId = soundTouch->setKey(KEY_VALUE::KEY_VALUE_PRESET_2);
} else if (preset.contains("3")) {
requestId = soundTouch->setKey(KEY_VALUE::KEY_VALUE_PRESET_3);
} else if (preset.contains("4")) {
requestId = soundTouch->setKey(KEY_VALUE::KEY_VALUE_PRESET_4);
} else if (preset.contains("5")) {
requestId = soundTouch->setKey(KEY_VALUE::KEY_VALUE_PRESET_5);
} else if (preset.contains("6")) {
requestId = soundTouch->setKey(KEY_VALUE::KEY_VALUE_PRESET_6);
} else {
qCWarning(dcBose()) << "Unhandled preset number: " << preset;
info->finish(Device::DeviceErrorInvalidParameter);
return;
}
m_pendingActions.insert(requestId, info);
connect(info, &DeviceActionInfo::aborted, this, [requestId, this] {m_pendingActions.remove(requestId);});
} else {
qCWarning(dcBose()) << "ActionTypeId not found" << action.actionTypeId();
return info->finish(Device::DeviceErrorActionTypeNotFound);

View File

@ -199,6 +199,28 @@
"id": "85d7126a-b123-4a28-aeb4-d84bcfb4d14f",
"name": "skipNext",
"displayName": "Skip Next"
},
{
"id": "69969904-5bb4-401d-bede-9f31fe52d16a",
"name": "activatePreset",
"displayName": "Activate preset",
"paramTypes": [
{
"id": "2a69f545-41a9-4e84-9cc6-65a5a9600b7e",
"name": "presetNumber",
"displayName": "Preset number",
"type": "QString",
"defaultValue": "Preset 1",
"allowedValues": [
"Preset 1",
"Preset 2",
"Preset 3",
"Preset 4",
"Preset 5",
"Preset 6"
]
}
]
}
]
}