[vlc-devel] [PATCH v2 09/11] lua: use vlc_actions_do
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Wed Aug 9 18:16:33 CEST 2017
From: Thomas Guillem <thomas at gllm.fr>
---
modules/lua/libs/misc.c | 9 +++++++++
share/lua/README.txt | 1 +
share/lua/modules/common.lua | 7 +++++--
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/modules/lua/libs/misc.c b/modules/lua/libs/misc.c
index a0472e82a2..0c8c99467e 100644
--- a/modules/lua/libs/misc.c
+++ b/modules/lua/libs/misc.c
@@ -154,6 +154,14 @@ static int vlclua_action_id( lua_State *L )
return 1;
}
+static int vlclua_action_do( lua_State *L )
+{
+ vlc_object_t *p_this = vlclua_get_this( L );
+ int i_ret = vlc_actions_do( p_this, luaL_checkint( L, 1 ),
+ luaL_checkboolean( L, 2 ), 0 );
+ return vlclua_push_ret( L, i_ret );
+}
+
/*****************************************************************************
*
*****************************************************************************/
@@ -163,6 +171,7 @@ static const luaL_Reg vlclua_misc_reg[] = {
{ "license", vlclua_license },
{ "action_id", vlclua_action_id },
+ { "action_do", vlclua_action_do },
{ "mdate", vlclua_mdate },
{ "mwait", vlclua_mwait },
diff --git a/share/lua/README.txt b/share/lua/README.txt
index eb782ee030..2c2fabf0d1 100644
--- a/share/lua/README.txt
+++ b/share/lua/README.txt
@@ -151,6 +151,7 @@ misc.copyright(): Get the VLC copyright statement.
misc.license(): Get the VLC license.
misc.action_id( name ): get the id of the given action.
+misc.action_do( id, notify ): execute the action identified by the id
misc.mdate(): Get the current date (in microseconds).
misc.mwait(): Wait for the given date (in microseconds).
diff --git a/share/lua/modules/common.lua b/share/lua/modules/common.lua
index 8c49c713e5..4c13eeae34 100644
--- a/share/lua/modules/common.lua
+++ b/share/lua/modules/common.lua
@@ -25,8 +25,11 @@ end
function hotkey(arg)
local id = vlc.misc.action_id( arg )
if id ~= nil then
- vlc.var.set( vlc.object.libvlc(), "key-action", id )
- return true
+ if vlc.misc.action_do( id, true ) == 0 then
+ return true
+ else
+ return false
+ end
else
return false
end
--
2.11.0
More information about the vlc-devel
mailing list