diff options
author | wm4 <wm4@nowhere> | 2014-04-10 23:56:06 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-04-10 23:56:06 +0200 |
commit | fb06e30b7b10a91933e3852d631de916ffbdb700 (patch) | |
tree | 7da355ca7303c02eed8cff194b6b4f6ce8c579a9 | |
parent | f0c8c26e2954165c474919985c198e2469351381 (diff) | |
download | mpv-fb06e30b7b10a91933e3852d631de916ffbdb700.tar.bz2 mpv-fb06e30b7b10a91933e3852d631de916ffbdb700.tar.xz |
lua: add a minor helper function
-rw-r--r-- | DOCS/man/en/lua.rst | 4 | ||||
-rw-r--r-- | player/lua/defaults.lua | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/DOCS/man/en/lua.rst b/DOCS/man/en/lua.rst index e88f4a9c2c..45d8bb983b 100644 --- a/DOCS/man/en/lua.rst +++ b/DOCS/man/en/lua.rst @@ -354,6 +354,10 @@ The ``mp`` module is preloaded, although it can be loaded manually with Undo a previous registration with ``mp.register_script_message``. Does nothing if the ``name`` wasn't registered. +``mp.osd_message(text [,duration])`` + Show an OSD message on the screen. ``duration`` is in seconds, and is + optional (uses ``--osd-duration`` by default). + mp.msg functions ---------------- diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua index 80630d20b6..4904e93b85 100644 --- a/player/lua/defaults.lua +++ b/player/lua/defaults.lua @@ -1,3 +1,5 @@ + +-- these are used internally by lua.c mp.UNKNOWN_TYPE.info = "this value is inserted if the C type is not supported" mp.UNKNOWN_TYPE.type = "UNKNOWN_TYPE" @@ -360,4 +362,15 @@ _G.mp_event_loop = function() end end +-- additional helpers + +function mp.osd_message(text, duration) + if not duration then + duration = "-1" + else + duration = tostring(math.floor(duration * 1000)) + end + mp.commandv("show_text", text, duration) +end + return {} |