Commit a8a66a68 authored by Antoine Cellerier's avatar Antoine Cellerier

* luaplaylist.c, README.txt: add .duration option for playlist items. Should...

* luaplaylist.c, README.txt: add .duration option for playlist items. Should now be possible to rewrite our m3u parser entirely in Lua :D
* m3u.c: indentation fix.
parent ba62457a
...@@ -479,6 +479,7 @@ static int Demux( demux_t *p_demux ) ...@@ -479,6 +479,7 @@ static int Demux( demux_t *p_demux )
const char *psz_name = NULL; const char *psz_name = NULL;
char **ppsz_options = NULL; char **ppsz_options = NULL;
int i_options = 0; int i_options = 0;
mtime_t i_duration = -1;
/* Read path and name */ /* Read path and name */
psz_path = lua_tostring( p_state, t+3 ); psz_path = lua_tostring( p_state, t+3 );
...@@ -494,6 +495,15 @@ static int Demux( demux_t *p_demux ) ...@@ -494,6 +495,15 @@ static int Demux( demux_t *p_demux )
psz_name = psz_path; psz_name = psz_path;
} }
/* Read duration */
lua_getfield( p_state, t+2, "duration" );
if( lua_isnumber( p_state, t+5 ) )
{
i_duration = (mtime_t)lua_tointeger( p_state, t+5 );
i_duration *= 1000000;
}
lua_pop( p_state, 1 ); /* pop "duration" */
/* Read options */ /* Read options */
lua_getfield( p_state, t+2, "options" ); lua_getfield( p_state, t+2, "options" );
if( lua_istable( p_state, t+5 ) ) if( lua_istable( p_state, t+5 ) )
...@@ -524,7 +534,7 @@ static int Demux( demux_t *p_demux ) ...@@ -524,7 +534,7 @@ static int Demux( demux_t *p_demux )
p_input = input_ItemNewExt( p_playlist, psz_path, p_input = input_ItemNewExt( p_playlist, psz_path,
psz_name, i_options, psz_name, i_options,
(const char **)ppsz_options, (const char **)ppsz_options,
-1 ); i_duration );
lua_pop( p_state, 1 ); /* pop "name" */ lua_pop( p_state, 1 ); /* pop "name" */
/* Read meta data */ /* Read meta data */
......
...@@ -184,7 +184,7 @@ static int Demux( demux_t *p_demux ) ...@@ -184,7 +184,7 @@ static int Demux( demux_t *p_demux )
i_options, ppsz_options, i_duration ); i_options, ppsz_options, i_duration );
if ( psz_artist && *psz_artist ) if ( psz_artist && *psz_artist )
input_ItemAddInfo( p_input, _(VLC_META_INFO_CAT), input_ItemAddInfo( p_input, _(VLC_META_INFO_CAT),
_(VLC_META_ARTIST), "%s", psz_artist ); _(VLC_META_ARTIST), "%s", psz_artist );
playlist_BothAddInput( p_playlist, p_input, p_item_in_category, playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL, VLC_FALSE ); PLAYLIST_END, NULL, NULL, VLC_FALSE );
......
...@@ -30,6 +30,7 @@ VLC Lua playlist modules should define two functions: ...@@ -30,6 +30,7 @@ VLC Lua playlist modules should define two functions:
.trackid: the item's TrackID (OPTIONAL, meta data) .trackid: the item's TrackID (OPTIONAL, meta data)
.options: a list of VLC options (OPTIONAL) .options: a list of VLC options (OPTIONAL)
example: .options = { "fullscreen" } example: .options = { "fullscreen" }
.duration: stream duration in seconds (OPTIONAL)
Invalid playlist items will be discarded by VLC. Invalid playlist items will be discarded by VLC.
VLC defines a global vlc object with the following members: VLC defines a global vlc object with the following members:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment