In Davinci Resolve this code almost work in having the lock of the playhead controlled…
- User
In Davinci Resolve this code almost work in having the lock of the playhead controlled by a buton, however I need to manually close the window, thus exiting from RunLoop(), in order to have the main loop looping, how can I fix that?
local ui = fu.UIManager local disp = bmd.UIDispatcher(ui) local resolve = app:GetResolve()
local projectManager = resolve:GetProjectManager() local project = projectManager:GetCurrentProject() local timeline = project:GetCurrentTimeline()
if not timeline then print("No timeline is open.") return end
local isPlayheadLocked = false local desiredTimecode = timeline:GetCurrentTimecode()
local function lockPlayhead() if isPlayheadLocked then local currentPlayheadTimecode = timeline:GetCurrentTimecode() if currentPlayheadTimecode ~= desiredTimecode then timeline:SetCurrentTimecode(desiredTimecode) end else desiredTimecode = timeline:GetCurrentTimecode() end end
win = disp:AddWindow( { ID = "MyWin", WindowTitle = "Playhead", BorderStyle = "None", Resizable = false, Geometry = { 100, 100, 220, 50 }, Composition = comp, ui:VGroup { ID = "root", ui:HGroup { Weight = 0, ui:Button{ ID = "btnLock", Text = "PLAYHEAD FREE" }, }, }, } )
itm = win:GetItems()
function win.On.btnLock.Clicked(ev) if itm.btnLock.Text == "PLAYHEAD FREE" then itm.btnLock.Text = "PLAYHEAD LOCKED" isPlayheadLocked = true else itm.btnLock.Text = "PLAYHEAD FREE" isPlayheadLocked = false end end
function win.On.MyWin.Close(ev) disp:ExitLoop() end
win:Show()
-- Periodically check and update the playhead position while true do lockPlayhead() disp:RunLoop() end
win:Hide()
- Assistant