New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Benchmark & Review: cp.apple.finalcut.main.Viewer.isPlaying #1445
Comments
Currently I'm using |
@randomeizer - As discussed on Messenger... Currently, local checker
checker = delayedTimer.new(0.2, function()
if self.isPlaying:update() then
-----------------------------------------------------------------------
-- It hasn't actually finished yet, so keep running:
-----------------------------------------------------------------------
checker:start()
end
end)
-----------------------------------------------------------------------
-- Watch the `timecode` field and update `isPlaying`:
-----------------------------------------------------------------------
self.timecode:watch(function()
if not checker:running() then
-----------------------------------------------------------------------
-- Update the first time:
-----------------------------------------------------------------------
self.isPlaying:update()
end
checker:start()
end)
--- cp.apple.finalcutpro.main.Viewer.timecode <cp.prop: string; live>
--- Field
--- The current timecode value, with the format "hh:mm:ss:ff". Setting also supports "hh:mm:ss;ff".
--- The property can be watched to get notifications of changes.
function Viewer.lazy.prop:timecode()
return self:timecodeText().value:mutate(
function Viewer.lazy.method:timecodeText()
return StaticText(self, self.bottomToolbarUI:mutate(function(original)
local ui = original()
return ui and childFromLeft(childrenWithRole(ui, "AXStaticText"), 1)
end))
end
--- cp.ui.StaticText.value <cp.prop: anything>
--- Field
--- The current value of the text field.
function StaticText.lazy.prop:value()
local value = self.UI:mutate(
function(original)
local ui = original()
local value = ui and ui:attributeValue("AXValue") or nil
if value and self._convertFn then
value = self._convertFn(value)
end
return value
end,
function(value, original)
local ui = original()
if ui then
value = tostring(value)
local focused = ui:attributeValue("AXFocused")
ui:setAttributeValue("AXFocused", true)
ui:setAttributeValue("AXValue", value)
ui:performAction("AXConfirm")
ui:setAttributeValue("AXFocused", focused)
end
end
)
-----------------------------------------------------------------------
-- Reduce the amount of AX notifications when timecode is updated:
-----------------------------------------------------------------------
local timecodeUpdater
timecodeUpdater = delayedTimer.new(0.001, function()
value:update()
end)
-- wire up a notifier to watch for value changes.
value:preWatch(function()
self:notifier():watchFor("AXValueChanged", function()
timecodeUpdater:start()
end):start()
end)
return value
end This should all be reviewed, to make sure it's the best way we should be handling things. |
I don't think we're ever going to have time to go back and "review" stuff, so I'm just going to close this for now. |
No description provided.
The text was updated successfully, but these errors were encountered: