]> git.sesse.net Git - vlc/commitdiff
* include/vlc/vlc.h: added a b_play parameter to the libvlc VLC_AddIntf() prototype.
authorGildas Bazin <gbazin@videolan.org>
Tue, 20 Apr 2004 15:05:24 +0000 (15:05 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 20 Apr 2004 15:05:24 +0000 (15:05 +0000)
   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".

include/vlc/vlc.h
include/vlc_interface.h
modules/gui/wxwindows/wxwindows.cpp
src/interface/interface.c
src/libvlc.c
src/vlc.c

index 3017b3ad10217d1b54e834c82c8fb94e59131193..091872af5a68f9d13f217bdf32640cc3df6bc3e5 100644 (file)
@@ -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 );
index 7474df5e76884e844acd4670e9b8b44cbf5a165c..e2af220641e46f3428da3a19394a8644a262ef78 100644 (file)
@@ -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 */
index fc52d1c2c994ad523878dd03d1fddeb3703c47e5..0454ef54810eff4e30a9e2462d22e0a1b7c9a538 100644 (file)
@@ -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;
 }
index fc95c5d935fb352bbb492307a01a0ba4218c1630..d2de9a84c27fa56d896252121593fe2b3cfb5859 100644 (file)
@@ -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 )
     {
index d488aa9bb81d393dd6602492f68a9f56df9571e3..51b9fad3bdf25acd1cca1cb4f89d437963cd0cf6 100644 (file)
@@ -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 )
index 1e4d9adea8d98453257ea58782d15a82d0583cb6..e9ab65fa3cdbd11e11ce8063da1b3bb43408af6f 100644 (file)
--- a/src/vlc.c
+++ b/src/vlc.c
@@ -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 );