Add temp var to Media condition indicating which source matched
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled

This commit is contained in:
WarmUpTill 2025-08-07 21:09:04 +02:00 committed by WarmUpTill
parent 4cae420ade
commit 3e8d6e103a
2 changed files with 20 additions and 2 deletions

View File

@ -2125,6 +2125,8 @@ AdvSceneSwitcher.tempVar.usb.serialNumber="Serial Number"
AdvSceneSwitcher.tempVar.transform.setting="Setting value" AdvSceneSwitcher.tempVar.transform.setting="Setting value"
AdvSceneSwitcher.tempVar.transform.settings="Settings string" AdvSceneSwitcher.tempVar.transform.settings="Settings string"
AdvSceneSwitcher.tempVar.media.source="Source"
AdvSceneSwitcher.tempVar.media.source.description="The name of the source which matched.\nIf multiple sources matched the last one is returned."
AdvSceneSwitcher.tempVar.media.state="State" AdvSceneSwitcher.tempVar.media.state="State"
AdvSceneSwitcher.tempVar.media.state.description="The current media state represented as an integer value:\n0 being 'None'\n1 being 'Playing'\n2 being 'Opening'\n3 being 'Buffering'\n4 being 'Paused'\n5 being 'Stopped'\n6 being 'Ended'\n7 being 'Error'" AdvSceneSwitcher.tempVar.media.state.description="The current media state represented as an integer value:\n0 being 'None'\n1 being 'Playing'\n2 being 'Opening'\n3 being 'Buffering'\n4 being 'Paused'\n5 being 'Stopped'\n6 being 'Ended'\n7 being 'Error'"
AdvSceneSwitcher.tempVar.media.time="Current time" AdvSceneSwitcher.tempVar.media.time="Current time"

View File

@ -185,6 +185,12 @@ void MacroConditionMedia::SetupTempVars()
MacroCondition::SetupTempVars(); MacroCondition::SetupTempVars();
if (_sourceType != SourceType::SOURCE) { if (_sourceType != SourceType::SOURCE) {
AddTempvar(
"source",
obs_module_text(
"AdvSceneSwitcher.tempVar.media.source"),
obs_module_text(
"AdvSceneSwitcher.tempVar.media.source.description"));
return; return;
} }
@ -351,13 +357,23 @@ bool MacroConditionMedia::CheckCondition()
switch (_sourceType) { switch (_sourceType) {
case SourceType::ANY: case SourceType::ANY:
for (auto &source : _sourceGroup) { for (auto &source : _sourceGroup) {
match = match || source.CheckCondition(); const bool matched = source.CheckCondition();
if (matched) {
SetTempVarValue("source",
source.GetSource().ToString());
}
match = match || matched;
} }
break; break;
case SourceType::ALL: { case SourceType::ALL: {
bool res = true; bool res = true;
for (auto &source : _sourceGroup) { for (auto &source : _sourceGroup) {
res = res && source.CheckCondition(); const bool matched = source.CheckCondition();
if (matched) {
SetTempVarValue("source",
source.GetSource().ToString());
}
res = res && matched;
} }
match = res; match = res;
break; break;