Playhead Lock on-off Lua Resolve Script

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

DorinDXN

  • Posts: 174
  • Joined: Thu Aug 04, 2022 5:07 pm
  • Real Name: Dorin Godja

Playhead Lock on-off Lua Resolve Script

PostWed Oct 16, 2024 4:02 pm

IMPORTANT!
Scripts with UI require Studio license since 19.1.
This script will work in the Free version of DaVinci Resolve only if DR is prior to 19.1



Use Cases Scenarios:
1) Playhead Lock when needed
Then:
2) When Locked, It acts like "Playhead Return" or "Stop and Go to Last Position" even in the Color Page:
a) Pressing space once will start playing; pressing space again will stop playing and return to the locked position.
or
b) JKL keys (Shuttle Controls) play as usual, but when stopped (K), the playhead will return to the locked position.

This is a Lua script for DaVinci Resolve (tested on DR 19.0.2 - the free one).
It creates a small on-top tool, movable, with a button to lock/unlock the playhead
- it is beta, might not work as expected but seems quite light and reliable on my early tests.

A short video about it is here:


Code: Select all
-- Playhead Lock ON-OFF Lua Resolve Script by DorinDXN
-- version 0.6 -- beta
-- license CC0
--
--[[
Save this file as:
Windows
C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Utility\DXN Playhead Lock ON-OFF.lua
Mac
/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Scripts/Utility/DXN Playhead Lock ON-OFF.lua

then you can launch it using the menu:
Workspace \ Scripts \ DXN Playhead Lock ON-OFF
 --]]

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 lockedTimecode = timeline:GetCurrentTimecode()
local function lockPlayhead()
    if isPlayheadLocked then
        local currentPlayheadTimecode = timeline:GetCurrentTimecode()
        if currentPlayheadTimecode ~= lockedTimecode then
            timeline:SetCurrentTimecode(lockedTimecode)
        end
     end
end
local win = disp:AddWindow({
    ID = "Playhead",
    WindowTitle = "DXN Playhead Lock",
    Geometry = { 100, 100, 150, 50 },
     WindowFlags = {
            Tool = true,
            MSWindowsFixedSizeDialogHint = true
        },
    ui:VGroup {
        ID = "playground",
        ui:HGroup {
            Weight = 0,
            ui:Button { ID = "btnLock", Text = "PLAYHEAD FREE" },
        },
    },
})
local itm = win:GetItems()
function win.On.btnLock.Clicked(ev)
    if itm.btnLock.Text == "PLAYHEAD FREE" then
        itm.btnLock.Text = "PLAYHEAD LOCKED"
      lockedTimecode = timeline:GetCurrentTimecode()
        isPlayheadLocked = true
    else
        itm.btnLock.Text = "PLAYHEAD FREE"
        isPlayheadLocked = false
    end
end
local timer_func = {}
local timerPH = ui:Timer {
    ID = "TimerPH",
    Interval = 200,
    SingleShot = false
}
timer_func[timerPH.ID] = function()
    lockPlayhead()
end
function disp.On.Timeout(ev)
    timer_func[ev.who]()
end
function win.On.Playhead.Close(ev)
    disp:ExitLoop()
   timerPH:Stop()
end
win:Show()
timerPH:Start()
disp:RunLoop()
win:Hide()


cheers,
Dorin
Last edited by DorinDXN on Tue Feb 18, 2025 10:12 am, edited 1 time in total.
DaVinci Resolve Anthem
https://www.youtube.com/watch?v=CcKC8R9ku50
DaVinci Resolve Clips
https://www.youtube.com/playlist?list=PLYgg-7sUX2Jh3dqNJ0AVBTIlDFtufrYyn
Playhead Lock Script
https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=210163
Offline

hyuston

  • Posts: 2
  • Joined: Sat Feb 01, 2025 4:16 pm
  • Real Name: Kostia Bebe

Re: Playhead Lock ON-OFF Lua Resolve Script

PostSat Feb 01, 2025 4:18 pm

Hello! Thank you for an amazing work!

I recently stared to use this script for grading multicam clips. And recognized that it don't work in multicam clips. Is there any possibity to modify this script to work in multicam clips?

It would be such a life saver
Offline

DorinDXN

  • Posts: 174
  • Joined: Thu Aug 04, 2022 5:07 pm
  • Real Name: Dorin Godja

Re: Playhead Lock ON-OFF Lua Resolve Script

PostWed Feb 19, 2025 7:21 am

Scripts with UI require Studio license since 19.1.
I can no longer run or test my scripts, so I have stopped scripting in Resolve.

cheers,
Dorin
DaVinci Resolve Anthem
https://www.youtube.com/watch?v=CcKC8R9ku50
DaVinci Resolve Clips
https://www.youtube.com/playlist?list=PLYgg-7sUX2Jh3dqNJ0AVBTIlDFtufrYyn
Playhead Lock Script
https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=210163

Return to DaVinci Resolve

Who is online

Users browsing this forum: Beimo77, Bing [Bot], Chris Tempel, dennis9880, jglejay, johnnie_saxon, suj999 and 280 guests