From c99321fbb36f5ba67a64c7be6ec04da3a05777fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Filip=20Ros=C3=A9en?= Date: Sun, 21 May 2017 21:34:41 +0200 Subject: [PATCH] playlist/item: add_subitem_tree: fix next on flat playlist and empty node MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: RĂ©mi Denis-Courmont --- src/playlist/item.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/playlist/item.c b/src/playlist/item.c index a8757c7a11..3f4e782177 100644 --- a/src/playlist/item.c +++ b/src/playlist/item.c @@ -190,6 +190,34 @@ static void input_item_add_subitem_tree ( const vlc_event_t * p_event, playlist_ViewPlay( p_playlist, NULL, p_play_item ); } + else if( b_flat && p_playlist->current.i_size > 0 ) + { + /* If the playlist is flat, empty nodes are automatically deleted; + * meaning that moving from the current index (the index of a now + * removed node) to the next would result in a skip of one entry + * (as the empty node is deleted, the logical next item would be + * the one that now resides in its place). + * + * Imagine [ A, B, C, D ], where B (at index 1) is currently being + * played and deleted. C is the logically next item, but since the + * list now looks like [ A, C, D ], advancing to index 2 would mean + * D is played - and not C. + * + * By positioning the playlist-head at index 0 (A), when the + * playlist advance to the next item, C will correctly be played. + * + * Note: Of course, if the deleted item is at index 0, we should + * play whatever item is at position 0 since we cannot advance to + * index -1 (as there cannot possibly be any item there). + **/ + + if( last_pos ) + ResetCurrentlyPlaying( p_playlist, + ARRAY_VAL( p_playlist->current, last_pos - 1 ) ); + else + playlist_ViewPlay( p_playlist, NULL, + ARRAY_VAL( p_playlist->current, 0 ) ); + } } PL_UNLOCK; -- 2.11.4.GIT