]> git.sesse.net Git - vlc/commitdiff
Add --play-and-exit option to quit after no more items are in playlist.
authorClément Stenac <zorglub@videolan.org>
Sat, 2 Sep 2006 21:22:19 +0000 (21:22 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 2 Sep 2006 21:22:19 +0000 (21:22 +0000)
To be backported, but will need some manual merging (diff in vlc-devel should apply pristine to 0.8.5).
Thanks to Georgi Chorbadzhiyski for the patch

src/libvlc.h
src/playlist/engine.c

index c6684ed5cef79facacd947cb71a893e565aa826f..26fe6f268c7c0c765f8ca2bbc299cb1ce667a959 100644 (file)
@@ -954,6 +954,10 @@ static char *ppsz_clock_descriptions[] =
 #define PAS_LONGTEXT N_( \
     "Stop the playlist after each played playlist item." )
 
+#define PAE_TEXT N_("Play and exit")
+#define PAE_LONGTEXT N_( \
+                "Exit if there are no more items in the playlist." )
+
 #define ML_TEXT N_("Use media library")
 #define ML_LONGTEXT N_( \
     "The media library is automatically saved and reloaded each time you " \
@@ -1618,6 +1622,7 @@ vlc_module_begin();
         change_short('L');
     add_bool( "repeat", 0, NULL, REPEAT_TEXT, REPEAT_LONGTEXT, VLC_FALSE );
         change_short('R');
+    add_bool( "play-and-exit", 0, NULL, PAE_TEXT, PAE_LONGTEXT, VLC_FALSE );
     add_bool( "play-and-stop", 0, NULL, PAS_TEXT, PAS_LONGTEXT, VLC_FALSE );
     add_bool( "media-library", 1, NULL, ML_TEXT, ML_LONGTEXT, VLC_FALSE );
     add_integer( "playlist-tree", 0, NULL, PLTREE_TEXT, PLTREE_LONGTEXT,
index dae3f170259cd876029d409fc63e6a4a853e445c..10d9500d6c88bf9865042d8e40bf384031e0feb5 100644 (file)
@@ -143,6 +143,7 @@ void playlist_Destroy( playlist_t *p_playlist )
     var_Destroy( p_playlist, "intf-popmenu" );
     var_Destroy( p_playlist, "intf-show" );
     var_Destroy( p_playlist, "play-and-stop" );
+    var_Destroy( p_playlist, "play-and-exit" );
     var_Destroy( p_playlist, "random" );
     var_Destroy( p_playlist, "repeat" );
     var_Destroy( p_playlist, "loop" );
@@ -209,8 +210,7 @@ static mtime_t ObjectGarbageCollector( playlist_t *p_playlist, int i_type,
 void playlist_MainLoop( playlist_t *p_playlist )
 {
     playlist_item_t *p_item = NULL;
-
-
+    vlc_bool_t b_playexit = var_GetBool( p_playlist, "play-and-exit" );
     PL_LOCK
 
     /* First, check if we have something to do */
@@ -321,6 +321,11 @@ void playlist_MainLoop( playlist_t *p_playlist )
              if( p_item == NULL )
              {
                 msg_Dbg( p_playlist, "nothing to play" );
+                if( b_playexit == VLC_TRUE )
+                {
+                    msg_Info( p_playlist, "end of playlist, exiting" );
+                    p_playlist->p_vlc->b_die = VLC_TRUE;
+                }
                 p_playlist->status.i_status = PLAYLIST_STOPPED;
                 PL_UNLOCK
                 return;
@@ -510,6 +515,7 @@ static void VariablesInit( playlist_t *p_playlist )
 
     /* Variables to control playback */
     var_CreateGetBool( p_playlist, "play-and-stop" );
+    var_CreateGetBool( p_playlist, "play-and-exit" );
     var_CreateGetBool( p_playlist, "random" );
     var_CreateGetBool( p_playlist, "repeat" );
     var_CreateGetBool( p_playlist, "loop" );