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 @@
* decoders.
*****************************************************************************
* 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>
*
......@@ -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 );
p_info = input_InfoCategory( p_input, "General");
input_AddInfo( p_info, "Playlist item", p_input->psz_source );
p_info = input_InfoCategory( p_input, "General" );
input_AddInfo( p_info, "playlist item", p_input->psz_source );
vlc_object_attach( p_input, p_parent );
/* Create thread and wait for its readiness. */
......
......@@ -2,7 +2,7 @@
* libvlc.h: main libvlc header
*****************************************************************************
* 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>
* Samuel Hocevar <sam@zoy.org>
......@@ -263,17 +263,22 @@
"If your processor supports the AltiVec instructions set, vlc can take "\
"advantage of them.")
#define PL_LAUNCH_TEXT N_("launch playlist on startup")
#define PL_LAUNCH_LONGTEXT N_( \
#define RANDOM_TEXT N_("play files randomly forever")
#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.")
#define PL_ENQUEUE_TEXT N_("enqueue items in playlist")
#define PL_ENQUEUE_LONGTEXT N_( \
#define ENQUEUE_TEXT N_("enqueue items in playlist")
#define ENQUEUE_LONGTEXT N_( \
"If you want vlc to add items to the playlist as you open them, then " \
"enable this option.")
#define PL_LOOP_TEXT N_("loop playlist on end")
#define PL_LOOP_LONGTEXT N_( \
#define LOOP_TEXT N_("loop playlist on end")
#define LOOP_LONGTEXT N_( \
"If you want vlc to keep playing the playlist indefinitely then enable " \
"this option.")
......@@ -421,9 +426,10 @@ vlc_module_begin();
/* Playlist options */
add_category_hint( N_("Playlist"), NULL );
add_bool( "playlist", 0, NULL, PL_LAUNCH_TEXT, PL_LAUNCH_LONGTEXT );
add_bool( "enqueue", 0, NULL, PL_ENQUEUE_TEXT, PL_ENQUEUE_LONGTEXT );
add_bool( "loop", 0, NULL, PL_LOOP_TEXT, PL_LOOP_LONGTEXT );
add_bool_with_short( "random", 'Z', 0, NULL, RANDOM_TEXT, RANDOM_LONGTEXT );
add_bool( "playlist", 0, NULL, LAUNCH_TEXT, LAUNCH_LONGTEXT );
add_bool( "enqueue", 0, NULL, ENQUEUE_TEXT, ENQUEUE_LONGTEXT );
add_bool( "loop", 0, NULL, LOOP_TEXT, LOOP_LONGTEXT );
/* Misc options */
add_category_hint( N_("Miscellaneous"), NULL );
......
......@@ -2,7 +2,7 @@
* playlist.c : Playlist management functions
*****************************************************************************
* 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>
*
......@@ -105,7 +105,7 @@ int playlist_Add( playlist_t *p_playlist, const char * psz_target,
{
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 */
p_item = malloc( sizeof( playlist_item_t ) );
......@@ -213,8 +213,8 @@ int playlist_Delete( playlist_t * p_playlist, int i_pos )
if( i_pos >= 0 && i_pos < p_playlist->i_size )
{
msg_Warn( p_playlist, "deleting playlist item %s ",
p_playlist->pp_items[i_pos]->psz_name );
msg_Dbg( p_playlist, "deleting playlist item %s ",
p_playlist->pp_items[i_pos]->psz_name );
free( p_playlist->pp_items[i_pos]->psz_name );
free( p_playlist->pp_items[i_pos] );
......@@ -435,7 +435,17 @@ static void SkipItem( playlist_t *p_playlist, int i_arg )
}
/* Increment */
p_playlist->i_index += i_arg;
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;
}
/* Boundary check */
if( p_playlist->i_index >= p_playlist->i_size )
......@@ -443,7 +453,8 @@ static void SkipItem( playlist_t *p_playlist, int i_arg )
if( p_playlist->i_status == PLAYLIST_STOPPED
|| 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
{
......
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