+ if( p_playlist->i_current_index < -1 )
+ p_playlist->i_current_index = -1;
+ for( int i = i_skip; i > 0 ; i-- )
+ {
+ p_playlist->i_current_index++;
+ if( p_playlist->i_current_index >= p_playlist->current.i_size )
+ {
+ PL_DEBUG( "looping - restarting at beginning of node" );
+ p_playlist->i_current_index = 0;
+ }
+ }
+ p_new = ARRAY_VAL( p_playlist->current,
+ p_playlist->i_current_index );
+ }
+ else if( p_playlist->current.i_size && (i_skip < 0) )
+ {
+ for( int i = i_skip; i < 0 ; i++ )
+ {
+ p_playlist->i_current_index--;
+ if( p_playlist->i_current_index <= -1 )
+ {
+ PL_DEBUG( "looping - restarting at end of node" );
+ p_playlist->i_current_index = p_playlist->current.i_size-1;
+ }
+ }
+ p_new = ARRAY_VAL( p_playlist->current,
+ p_playlist->i_current_index );
+ }
+ /* Clear the request */
+ p_sys->request.b_request = false;
+ }
+ /* "Automatic" item change ( next ) */
+ else
+ {
+ bool b_loop = var_GetBool( p_playlist, "loop" );
+ bool b_repeat = var_GetBool( p_playlist, "repeat" );
+ bool b_playstop = var_GetBool( p_playlist, "play-and-stop" );
+
+ /* Repeat and play/stop */
+ if( b_repeat && get_current_status_item( p_playlist ) )
+ {
+ msg_Dbg( p_playlist,"repeating item" );
+ return get_current_status_item( p_playlist );
+ }
+ if( b_playstop )
+ {
+ msg_Dbg( p_playlist,"stopping (play and stop)" );
+ return NULL;
+ }
+
+ /* */
+ if( get_current_status_item( p_playlist ) )
+ {
+ playlist_item_t *p_parent = get_current_status_item( p_playlist );
+ while( p_parent )
+ {
+ if( p_parent->i_flags & PLAYLIST_SKIP_FLAG )
+ {
+ msg_Dbg( p_playlist, "blocking item, stopping") ;
+ return NULL;
+ }
+ p_parent = p_parent->p_parent;
+ }
+ }
+
+ PL_DEBUG( "changing item without a request (current %i/%i)",
+ p_playlist->i_current_index, p_playlist->current.i_size );
+ /* Cant go to next from current item */
+ if( get_current_status_item( p_playlist ) &&
+ get_current_status_item( p_playlist )->i_flags & PLAYLIST_SKIP_FLAG )
+ return NULL;
+
+ if( p_sys->b_reset_currently_playing )
+ ResetCurrentlyPlaying( p_playlist,
+ get_current_status_item( p_playlist ) );
+
+ p_playlist->i_current_index++;
+ assert( p_playlist->i_current_index <= p_playlist->current.i_size );
+ if( p_playlist->i_current_index == p_playlist->current.i_size )
+ {
+ if( !b_loop || p_playlist->current.i_size == 0 )
+ return NULL;
+ p_playlist->i_current_index = 0;