-- Super-snappy Play/Stop that only shows the Video window -- when starting playback, and does not touch it when stopping. -- Behaviour is very close to: -- 1) View: Video window -- 2) Transport: Play/stop -- in a custom action, but wrapped in one script. local VIDEO_CMD = 50125 -- View: Video window (check ID in Actions list) local PLAYSTOP_CMD = 40044 -- Transport: Play/stop local SWS_FOCUS_ARR = reaper.NamedCommandLookup("_BR_FOCUS_ARRANGE_WND") -- SWS focus arrange :contentReference[oaicite:0]{index=0} -- Is the Video window currently shown? (toggle state) local function video_is_shown() -- section 0 = Main local state = reaper.GetToggleCommandStateEx(0, VIDEO_CMD) -- 1=shown, 0=hidden :contentReference[oaicite:1]{index=1} return state == 1 end local function show_video_if_hidden() if not video_is_shown() then reaper.Main_OnCommand(VIDEO_CMD, 0) -- show/open video window :contentReference[oaicite:2]{index=2} end end local function focus_arrange_if_available() if SWS_FOCUS_ARR ~= 0 then reaper.Main_OnCommand(SWS_FOCUS_ARR, 0) end end local function main() -- Bitmask: &1=playing, &2=paused, &4=recording :contentReference[oaicite:3]{index=3} local play_state = reaper.GetPlayState() -- If currently stopped, we're about to start playback: -- ensure video is visible *before* Play/stop. if play_state == 0 then show_video_if_hidden() end -- Use REAPER's native Play/stop, so timing is exactly like the normal shortcut. reaper.Main_OnCommand(PLAYSTOP_CMD, 0) -- Transport: Play/stop :contentReference[oaicite:4]{index=4} -- Optional: throw focus back to Arrange (shouldn’t affect transport timing, -- because it happens after Play/stop). focus_arrange_if_available() end main()