Commit f20532c0 authored by Sam Hocevar's avatar Sam Hocevar

* ./src/playlist/playlist.c: added -Z (--random) for endless random playing.

parent ba97736a
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.210 2002/08/12 22:12:51 massiot Exp $ * $Id: input.c,v 1.211 2002/08/16 12:31:04 sam Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -153,8 +153,8 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, ...@@ -153,8 +153,8 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
msg_Info( p_input, "playlist item `%s'", p_input->psz_source ); msg_Info( p_input, "playlist item `%s'", p_input->psz_source );
p_info = input_InfoCategory( p_input, "General"); p_info = input_InfoCategory( p_input, "General" );
input_AddInfo( p_info, "Playlist item", p_input->psz_source ); input_AddInfo( p_info, "playlist item", p_input->psz_source );
vlc_object_attach( p_input, p_parent ); vlc_object_attach( p_input, p_parent );
/* Create thread and wait for its readiness. */ /* Create thread and wait for its readiness. */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.h: main libvlc header * libvlc.h: main libvlc header
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.h,v 1.13 2002/08/12 22:12:51 massiot Exp $ * $Id: libvlc.h,v 1.14 2002/08/16 12:31:04 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -263,17 +263,22 @@ ...@@ -263,17 +263,22 @@
"If your processor supports the AltiVec instructions set, vlc can take "\ "If your processor supports the AltiVec instructions set, vlc can take "\
"advantage of them.") "advantage of them.")
#define PL_LAUNCH_TEXT N_("launch playlist on startup") #define RANDOM_TEXT N_("play files randomly forever")
#define PL_LAUNCH_LONGTEXT N_( \ #define RANDOM_LONGTEXT N_( \
"When selected, vlc will randomly play files in the playlist until " \
"interrupted.")
#define LAUNCH_TEXT N_("launch playlist on startup")
#define LAUNCH_LONGTEXT N_( \
"If you want vlc to start playing on startup, then enable this option.") "If you want vlc to start playing on startup, then enable this option.")
#define PL_ENQUEUE_TEXT N_("enqueue items in playlist") #define ENQUEUE_TEXT N_("enqueue items in playlist")
#define PL_ENQUEUE_LONGTEXT N_( \ #define ENQUEUE_LONGTEXT N_( \
"If you want vlc to add items to the playlist as you open them, then " \ "If you want vlc to add items to the playlist as you open them, then " \
"enable this option.") "enable this option.")
#define PL_LOOP_TEXT N_("loop playlist on end") #define LOOP_TEXT N_("loop playlist on end")
#define PL_LOOP_LONGTEXT N_( \ #define LOOP_LONGTEXT N_( \
"If you want vlc to keep playing the playlist indefinitely then enable " \ "If you want vlc to keep playing the playlist indefinitely then enable " \
"this option.") "this option.")
...@@ -421,9 +426,10 @@ vlc_module_begin(); ...@@ -421,9 +426,10 @@ vlc_module_begin();
/* Playlist options */ /* Playlist options */
add_category_hint( N_("Playlist"), NULL ); add_category_hint( N_("Playlist"), NULL );
add_bool( "playlist", 0, NULL, PL_LAUNCH_TEXT, PL_LAUNCH_LONGTEXT ); add_bool_with_short( "random", 'Z', 0, NULL, RANDOM_TEXT, RANDOM_LONGTEXT );
add_bool( "enqueue", 0, NULL, PL_ENQUEUE_TEXT, PL_ENQUEUE_LONGTEXT ); add_bool( "playlist", 0, NULL, LAUNCH_TEXT, LAUNCH_LONGTEXT );
add_bool( "loop", 0, NULL, PL_LOOP_TEXT, PL_LOOP_LONGTEXT ); add_bool( "enqueue", 0, NULL, ENQUEUE_TEXT, ENQUEUE_LONGTEXT );
add_bool( "loop", 0, NULL, LOOP_TEXT, LOOP_LONGTEXT );
/* Misc options */ /* Misc options */
add_category_hint( N_("Miscellaneous"), NULL ); add_category_hint( N_("Miscellaneous"), NULL );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* playlist.c : Playlist management functions * playlist.c : Playlist management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: playlist.c,v 1.10 2002/08/12 09:34:15 sam Exp $ * $Id: playlist.c,v 1.11 2002/08/16 12:31:04 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -105,7 +105,7 @@ int playlist_Add( playlist_t *p_playlist, const char * psz_target, ...@@ -105,7 +105,7 @@ int playlist_Add( playlist_t *p_playlist, const char * psz_target,
{ {
playlist_item_t *p_item; playlist_item_t *p_item;
msg_Warn( p_playlist, "adding playlist item %s ", psz_target ); msg_Dbg( p_playlist, "adding playlist item %s ", psz_target );
/* Create the new playlist item */ /* Create the new playlist item */
p_item = malloc( sizeof( playlist_item_t ) ); p_item = malloc( sizeof( playlist_item_t ) );
...@@ -213,7 +213,7 @@ int playlist_Delete( playlist_t * p_playlist, int i_pos ) ...@@ -213,7 +213,7 @@ int playlist_Delete( playlist_t * p_playlist, int i_pos )
if( i_pos >= 0 && i_pos < p_playlist->i_size ) if( i_pos >= 0 && i_pos < p_playlist->i_size )
{ {
msg_Warn( p_playlist, "deleting playlist item %s ", msg_Dbg( p_playlist, "deleting playlist item %s ",
p_playlist->pp_items[i_pos]->psz_name ); p_playlist->pp_items[i_pos]->psz_name );
free( p_playlist->pp_items[i_pos]->psz_name ); free( p_playlist->pp_items[i_pos]->psz_name );
...@@ -435,7 +435,17 @@ static void SkipItem( playlist_t *p_playlist, int i_arg ) ...@@ -435,7 +435,17 @@ static void SkipItem( playlist_t *p_playlist, int i_arg )
} }
/* Increment */ /* Increment */
if( config_GetInt( p_playlist, "random" ) )
{
/* Simple random stuff */
srand( mdate() );
p_playlist->i_index += 1 + (int) ( 1.0 * p_playlist->i_size * rand()
/ ( RAND_MAX + 1.0 ) );
}
else
{
p_playlist->i_index += i_arg; p_playlist->i_index += i_arg;
}
/* Boundary check */ /* Boundary check */
if( p_playlist->i_index >= p_playlist->i_size ) if( p_playlist->i_index >= p_playlist->i_size )
...@@ -443,7 +453,8 @@ static void SkipItem( playlist_t *p_playlist, int i_arg ) ...@@ -443,7 +453,8 @@ static void SkipItem( playlist_t *p_playlist, int i_arg )
if( p_playlist->i_status == PLAYLIST_STOPPED if( p_playlist->i_status == PLAYLIST_STOPPED
|| config_GetInt( p_playlist, "loop" ) ) || config_GetInt( p_playlist, "loop" ) )
{ {
p_playlist->i_index = 0; p_playlist->i_index -= p_playlist->i_size
* ( p_playlist->i_index / p_playlist->i_size );
} }
else else
{ {
......
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