Commit 7019a8c5 authored by Benjamin Pracht's avatar Benjamin Pracht

* Go back to the first item when hitting "next" on the last item. Go to the...

* Go back to the first item when hitting "next" on the last item. Go to the last item with "prev" on the 1st item.

parent 4c8fb0de
...@@ -54,6 +54,35 @@ int playlist_vaControl( playlist_t * p_playlist, int i_query, va_list args ); ...@@ -54,6 +54,35 @@ int playlist_vaControl( playlist_t * p_playlist, int i_query, va_list args );
void playlist_PreparseEnqueueItemSub( playlist_t *, playlist_item_t * ); void playlist_PreparseEnqueueItemSub( playlist_t *, playlist_item_t * );
playlist_item_t *playlist_RecursiveFindLast(playlist_t *p_playlist,
playlist_item_t *p_node );
/*****************************************************************************
* Helper Function for NextItem
*****************************************************************************/
playlist_item_t *playlist_RecursiveFindLast(playlist_t *p_playlist,
playlist_item_t *p_node )
{
int i;
playlist_item_t *p_item;
for ( i = p_node->i_children - 1; i >= 0; i-- )
{
if( p_node->pp_children[i]->i_children == -1 )
return p_node->pp_children[i];
else if(p_node->pp_children[i]->i_children > 0)
{
p_item = playlist_RecursiveFindLast( p_playlist,
p_node->pp_children[i] );
if ( p_item != NULL )
return p_item;
}
else if( i == 0 )
return NULL;
}
return NULL;
}
/** /**
* Create playlist * Create playlist
...@@ -957,22 +986,15 @@ static playlist_item_t * NextItem( playlist_t *p_playlist ) ...@@ -957,22 +986,15 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
p_new ); p_new );
if( p_new == NULL ) if( p_new == NULL )
{ {
if( b_loop )
{
#ifdef PLAYLIST_DEBUG #ifdef PLAYLIST_DEBUG
msg_Dbg( p_playlist, "looping" ); msg_Dbg( p_playlist, "looping" );
#endif #endif
p_new = playlist_FindNextFromParent( p_playlist, p_new = playlist_FindNextFromParent( p_playlist,
p_playlist->request.i_view, p_playlist->request.i_view,
p_view->p_root, p_view->p_root,
p_playlist->request.p_node, p_playlist->request.p_node,
NULL ); NULL );
if( p_new == NULL ) break; if( p_new == NULL ) break;
}
else
{
break;
}
} }
} }
} }
...@@ -985,6 +1007,13 @@ static playlist_item_t * NextItem( playlist_t *p_playlist ) ...@@ -985,6 +1007,13 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
p_view->p_root, p_view->p_root,
p_playlist->request.p_node, p_playlist->request.p_node,
p_new ); p_new );
if( p_new == NULL )
{
/* We reach the beginning of the playlist.
Go back to the last item. */
p_new = playlist_RecursiveFindLast( p_playlist,
p_view->p_root );
}
if( p_new == NULL ) break; if( p_new == NULL ) break;
} }
......
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