Commit a5ee53f7 authored by Gildas Bazin's avatar Gildas Bazin

* include/vlc/vlc.h: added a b_play parameter to the libvlc VLC_AddIntf() prototype.

   When true, the interface will automatically start playing the playlist when (and only when) it is ready. (particularly useful for embedded vouts).
* src/libvlc.c, src/vlc.c: new VLC_AddIntf() prototype.
* src/interface/interface.c: if the interface doesn't support "playing on start", do it ourselves.
* modules/gui/wxwindows/wxwindows.cpp: implement "play on start".
parent 1741388f
......@@ -226,7 +226,7 @@ int VLC_Set ( int, char const *, vlc_value_t );
*/
int VLC_Get ( int, char const *, vlc_value_t * );
int VLC_AddIntf ( int, char const *, vlc_bool_t );
int VLC_AddIntf ( int, char const *, vlc_bool_t, vlc_bool_t );
int VLC_AddTarget ( int, char const *, const char **, int, int, int );
int VLC_Play ( int );
......
......@@ -50,6 +50,7 @@ struct intf_thread_t
/* Thread properties and locks */
vlc_bool_t b_block;
vlc_bool_t b_play;
/* Specific interfaces */
intf_console_t * p_console; /** console */
......
......@@ -148,6 +148,9 @@ static int Open( vlc_object_t *p_this )
p_intf->pf_show_dialog = NULL;
/* We support play on start */
p_intf->b_play = VLC_TRUE;
return VLC_SUCCESS;
}
......@@ -306,6 +309,19 @@ bool Instance::OnInit()
/* OK, initialization is over */
vlc_thread_ready( p_intf );
/* Check if we need to start playing */
if( p_intf->b_play )
{
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
}
/* Return TRUE to tell program to continue (FALSE would terminate) */
return TRUE;
}
......
......@@ -278,6 +278,9 @@ static void RunInterface( intf_thread_t *p_intf )
/* Give control to the interface */
p_intf->pf_run( p_intf );
/* Reset play on start status */
p_intf->b_play = VLC_FALSE;
/* Provide ability to switch the main interface on the fly */
while( p_intf->psz_switch_intf )
{
......
......@@ -616,7 +616,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
if( psz_temp )
{
sprintf( psz_temp, "%s,none", psz_module );
VLC_AddIntf( 0, psz_temp, VLC_FALSE );
VLC_AddIntf( 0, psz_temp, VLC_FALSE, VLC_FALSE );
free( psz_temp );
}
}
......@@ -628,7 +628,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
/*
* Allways load the hotkeys interface if it exists
*/
VLC_AddIntf( 0, "hotkeys,none", VLC_FALSE );
VLC_AddIntf( 0, "hotkeys,none", VLC_FALSE, VLC_FALSE );
/*
* FIXME: kludge to use a p_vlc-local variable for the Mozilla plugin
......@@ -661,9 +661,11 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
* This function opens an interface plugin and runs it. If b_block is set
* to 0, VLC_AddIntf will return immediately and let the interface run in a
* separate thread. If b_block is set to 1, VLC_AddIntf will continue until
* user requests to quit.
* user requests to quit. If b_play is set to 1, VLC_AddIntf will start playing
* the playlist when it is completely initialised.
*****************************************************************************/
int VLC_AddIntf( int i_object, char const *psz_module, vlc_bool_t b_block )
int VLC_AddIntf( int i_object, char const *psz_module,
vlc_bool_t b_block, vlc_bool_t b_play )
{
int i_err;
intf_thread_t *p_intf;
......@@ -684,7 +686,11 @@ int VLC_AddIntf( int i_object, char const *psz_module, vlc_bool_t b_block )
return VLC_EGENERIC;
}
/* Interface doesn't handle play on start so do it ourselves */
if( !p_intf->b_play && b_play ) VLC_Play( i_object );
/* Try to run the interface */
p_intf->b_play = b_play;
p_intf->b_block = b_block;
i_err = intf_RunThread( p_intf );
if( i_err )
......
......@@ -2,7 +2,7 @@
* vlc.c: the vlc player
*****************************************************************************
* Copyright (C) 1998-2004 VideoLAN
* $Id: vlc.c,v 1.21 2004/01/25 17:16:05 zorglub Exp $
* $Id$
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -98,11 +98,8 @@ int main( int i_argc, char *ppsz_argv[] )
return i_ret;
}
/* Run libvlc, in non-blocking mode */
i_ret = VLC_Play( 0 );
/* Add a blocking interface and keep the return value */
i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE );
/* Add a blocking interface, start playing, and keep the return value */
i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );
/* Finish the threads */
VLC_Stop( 0 );
......
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