diff options
author | Kevin Mitchell <kevmitch@gmail.com> | 2014-05-04 12:54:03 -0700 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2014-05-04 12:54:03 -0700 |
commit | c91373a20204237110556c81507cdbbf3991c61b (patch) | |
tree | 9a8f8a32b41b08b167f666b9fc9c74f8b51dadc6 /TOOLS/lua | |
parent | 74984aaff190becd9779f92582107db3b48d42a6 (diff) | |
download | mpv-c91373a20204237110556c81507cdbbf3991c61b.tar.bz2 mpv-c91373a20204237110556c81507cdbbf3991c61b.tar.xz |
TOOLS/lua/autocrop: handle case of user hitting hotkey while cropdetection already running
Diffstat (limited to 'TOOLS/lua')
-rw-r--r-- | TOOLS/lua/autocrop.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/TOOLS/lua/autocrop.lua b/TOOLS/lua/autocrop.lua index 55cf817950..0da94796df 100644 --- a/TOOLS/lua/autocrop.lua +++ b/TOOLS/lua/autocrop.lua @@ -25,6 +25,7 @@ -- -- to mpv's arguments. This may be desirable to allow cropdetect more -- time to collect data. +require "mp.msg" script_name=mp.get_script_name() cropdetect_label=string.format("%s-cropdetect",script_name) @@ -51,10 +52,17 @@ function del_filter_if_present(label) end function autocrop_start() - -- if there's a crop filter, just remove it and exit + -- exit if cropdetection is already in progress + if timer then + mp.msg.warn("already cropdetecting!") + return + end + + -- if there's a crop filter, remove it and exit if del_filter_if_present(crop_label) then return end + -- insert the cropdetect filter ret=mp.command( string.format( @@ -63,11 +71,10 @@ function autocrop_start() ) ) -- wait to gather data - mp.add_timeout(detect_seconds, do_crop) + timer=mp.add_timeout(detect_seconds, do_crop) end function do_crop() - require 'mp.msg' -- get the metadata local cropdetect_metadata = mp.get_property_native( string.format('vf-metadata/%s', cropdetect_label) @@ -100,6 +107,7 @@ function do_crop() end -- remove the cropdetect filter del_filter_if_present(cropdetect_label) + timer=nil end mp.add_key_binding("C","auto_crop",autocrop_start) |