Index: src/playlist/playlist.c
===================================================================
--- src/playlist/playlist.c	(Revision 12543)
+++ src/playlist/playlist.c	(Arbeitskopie)
@@ -892,28 +892,36 @@
         ( p_playlist->request.b_request && ( p_playlist->request.p_item == NULL ||
           p_playlist->request.i_skip == 1 || p_playlist->request.i_skip == -1 ) ) ) )
     {
-        srand( (unsigned int)mdate() );
-        i_new = 0;
-        for( i_count = 0; i_count < p_playlist->i_size - 1 ; i_count ++ )
+        /* how many items to choose from ? */
+        i_count = 0;
+        for ( i = 0; i < p_playlist->i_size; i++ )
         {
-            i_new =
-                (int)((float)p_playlist->i_size * rand() / (RAND_MAX+1.0));
-            /* Check if the item has not already been played */
-            if( p_playlist->pp_items[i_new]->i_nb_played == 0 )
-                break;
+            if ( p_playlist->pp_items[i]->i_nb_played == 0 )
+                i_count++;
         }
-        if( i_count == p_playlist->i_size )
+        /* Nothing left? */
+        if ( i_count == 0 )
         {
-            /* The whole playlist has been played: reset the counters */
-            while( i_count > 0 )
-            {
-                p_playlist->pp_items[--i_count]->i_nb_played = 0;
-            }
+            /* Don't loop? Exit! */
             if( !b_loop )
+                return NULL;
+            /* Otherwise reset the counter */
+            for ( i = 0; i < p_playlist->i_size; i++ )
             {
-                return NULL;
+                p_playlist->pp_items[i]->i_nb_played = 0;
             }
+            i_count = p_playlist->i_size;
         }
+        srand( (unsigned int)mdate() );
+        i = rand() % i_count + 1 ;
+        /* loop thru the list and count down the unplayed items to the selected one */
+        for ( i_new = 0; i_new < p_playlist->i_size && i > 0; i_new++ )
+        {
+            if ( p_playlist->pp_items[i_new]->i_nb_played == 0 )
+                i--;
+        }
+        i_new--;
+
         p_playlist->request.i_skip = 0;
         p_playlist->request.b_request = VLC_FALSE;
         return p_playlist->pp_items[i_new];
Index: modules/gui/wxwidgets/playlist.cpp
===================================================================
--- modules/gui/wxwidgets/playlist.cpp	(Revision 12543)
+++ modules/gui/wxwidgets/playlist.cpp	(Arbeitskopie)
@@ -518,11 +518,13 @@
     if( p_playlist->status.p_item == p_item )
     {
         treectrl->SetItemBold( item, true );
+        treectrl->SetItemTextColour( item, *wxRED );
         treectrl->EnsureVisible( item );
     }
     else
     {
         treectrl->SetItemBold( item, false );
+        treectrl->SetItemTextColour( item, wxNullColour );
     }
     UnlockPlaylist( p_intf->p_sys, p_playlist );
 }
