Hi Andreas,
what a wonderful solution considering execution time overhead. Thank you Andreas! 🥳 Unfortunately, the solution prevents the user from using CueZero and OffCue commands for other purposes without further checks when adding the notify commands, which could be one way of improving upon this solution. Meanwhile I also found a solution that works without needing to modify any objects in the showfile and still works without pollig:
local myplugin = select(4, ...):Parent()
local sequ = {}
local function runningSequChanged()
for _, v in ipairs(DataPool().Sequences:Children()) do
local newState = v:HasActivePlayback()
if sequ[v] ~= newState then
sequ[v] = newState
if newState then
Echo(v:ToAddr() .. " started")
else
Echo(v:ToAddr() .. " stopped")
end
end
end
end
return function()
HookObjectChange(runningSequChanged, Root().Temp.RunningSequences, myplugin)
end
Display More
Since I'm using the hook on Root().Temp.RunningSequences, this only works while the Running Sequences window is open on any of the MA3 screens, otherwise the hook won't fire on status changes. Unfortunately, there is no argument passed to the callback function to know directly what or where the change is without reiterating over all the sequences. This makes this solution more inefficient than it could be, since the execution time grows proportionally to the number of sequences. But at least the sequences are only checked if at least one state change has occurred. So at least for small showfiles you can get a latency and overhead advantage over polling. In addition, the overhead can be reduced further if one is no longer interested in the state of all sequences but only a selection. Then you can only check the relevant sequences to begin with, which extremely reduces overhead.
Since all previous solutions that are better than polling bring restrictions for the user (using CueZero or OffCue, using windows that have to be open at all times, etc.) I sadly have to understand these solutions more as a workaround than as a serious solution that can be used sensibly.
In hope of better solutions
Kind regards 🙌