summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian <MyFakeAcc.4@googlemail.com>2016-05-15 02:57:44 +0900
committerwm4 <wm4@nowhere>2016-05-14 20:49:28 +0200
commit6ae7a555bfd0dde6967d716b4439f1c47911b5d4 (patch)
treebaa9a26ba7e1caed7334e59fb2ba5f31f28f90c1
parent449b948ee8b53f17a2dd6469f6a14c8dd4c04ccd (diff)
downloadmpv-6ae7a555bfd0dde6967d716b4439f1c47911b5d4.tar.bz2
mpv-6ae7a555bfd0dde6967d716b4439f1c47911b5d4.tar.xz
lua: add timer:is_enabled() function
Allows to query if some timer is currently running or was stopped/killed.
-rw-r--r--DOCS/man/lua.rst4
-rw-r--r--player/lua/defaults.lua4
2 files changed, 8 insertions, 0 deletions
diff --git a/DOCS/man/lua.rst b/DOCS/man/lua.rst
index 35124a788f..b0d66c1760 100644
--- a/DOCS/man/lua.rst
+++ b/DOCS/man/lua.rst
@@ -350,6 +350,10 @@ The ``mp`` module is preloaded, although it can be loaded manually with
with ``add_timeout()``), this starts the timer from the beginning,
using the initially configured timeout.
+ ``is_enabled()``
+ Whether the timer is currently enabled or was previously disabled
+ (e.g. by ``stop()`` or ``kill()``).
+
``timeout`` (RW)
This field contains the current timeout period. This value is not
updated as time progresses. It's only used to calculate when the
diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua
index a12e5bd3c3..e499ecc917 100644
--- a/player/lua/defaults.lua
+++ b/player/lua/defaults.lua
@@ -275,6 +275,10 @@ function timer_mt.resume(t)
end
end
+function timer_mt.is_enabled(t)
+ return timers[t] ~= nil
+end
+
-- Return the timer that expires next.
local function get_next_timer()
local best = nil