[vlc-commits] commit: lua_osd: add some parameters to the osd. message function to allow the user to set duration and position. ( Rémi Duraffort )
git at videolan.org
git at videolan.org
Tue Aug 3 23:10:34 CEST 2010
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue Aug 3 23:07:51 2010 +0200| [f7bf1662025e4d2da20f8d3ace7fd49416d1f2b5] | committer: Rémi Duraffort
lua_osd: add some parameters to the osd.message function to allow the user to set duration and position.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f7bf1662025e4d2da20f8d3ace7fd49416d1f2b5
---
modules/misc/lua/libs/osd.c | 31 ++++++++++++++++++++++++++++++-
share/lua/README.txt | 5 ++++-
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/modules/misc/lua/libs/osd.c b/modules/misc/lua/libs/osd.c
index 8638876..b8ce9ce 100644
--- a/modules/misc/lua/libs/osd.c
+++ b/modules/misc/lua/libs/osd.c
@@ -88,10 +88,38 @@ static int vlclua_osd_icon( lua_State *L )
return 0;
}
+static int vlc_osd_position_from_string( const char *psz_name )
+{
+ static const struct
+ {
+ int i_position;
+ const char *psz_name;
+ } pp_icons[] =
+ { { SUBPICTURE_ALIGN_MASK, "center" },
+ { SUBPICTURE_ALIGN_LEFT, "left" },
+ { SUBPICTURE_ALIGN_RIGHT, "rigth" },
+ { SUBPICTURE_ALIGN_TOP, "top" },
+ { SUBPICTURE_ALIGN_BOTTOM, "bottom" },
+ { SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_LEFT, "top-left" },
+ { SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_RIGHT, "top-right" },
+ { SUBPICTURE_ALIGN_BOTTOM|SUBPICTURE_ALIGN_LEFT, "bottom-left" },
+ { SUBPICTURE_ALIGN_BOTTOM|SUBPICTURE_ALIGN_RIGHT, "bottom-right" },
+ { 0, NULL } };
+ int i;
+ for( i = 0; pp_icons[i].psz_name; i++ )
+ {
+ if( !strcmp( psz_name, pp_icons[i].psz_name ) )
+ return pp_icons[i].i_position;
+ }
+ return 0;
+}
+
static int vlclua_osd_message( lua_State *L )
{
const char *psz_message = luaL_checkstring( L, 1 );
int i_chan = luaL_optint( L, 2, SPU_DEFAULT_CHANNEL );
+ const char *psz_position = luaL_optstring( L, 3, "top-right" );
+ mtime_t duration = luaL_optint( L, 4, 1000000 );
input_thread_t *p_input = vlclua_get_input_internal( L );
if( p_input )
@@ -99,7 +127,8 @@ static int vlclua_osd_message( lua_State *L )
vout_thread_t *p_vout = input_GetVout( p_input );
if( p_vout )
{
- vout_OSDMessage( p_vout, i_chan, "%s", psz_message );
+ vout_OSDText( p_vout, i_chan, vlc_osd_position_from_string( psz_position ),
+ duration, psz_message );
vlc_object_release( p_vout );
}
vlc_object_release( p_input );
diff --git a/share/lua/README.txt b/share/lua/README.txt
index 73dc2d5..c290621 100644
--- a/share/lua/README.txt
+++ b/share/lua/README.txt
@@ -231,7 +231,10 @@ OSD
osd.icon( type, [id] ): Display an icon on the given OSD channel. Uses the
default channel is none is given. Icon types are: "pause", "play",
"speaker" and "mute".
-osd.message( string, [id] ): Display text message on the given OSD channel.
+osd.message( string, [id], [position], [duration]: Display the text message on
+ the given OSD channel. Position types are: "center", "left", "right", "top",
+ "bottom", "top-left", "top-right", "bottom-left" or "bottom-right". The
+ duration is set in microseconds.
osd.slider( position, type, [id] ): Display slider. Position is an integer
from 0 to 100. Type can be "horizontal" or "vertical".
osd.channel_register(): Register a new OSD channel. Returns the channel id.
More information about the vlc-commits
mailing list