[vlc-devel] [PATCH 4/8] playlist/item: add_subitem_tree: fix next	on flat playlist and empty node
    Filip Roséen 
    filip at atch.se
       
    Sun May 21 20:48:14 CEST 2017
    
    
  
---
 src/playlist/item.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff --git a/src/playlist/item.c b/src/playlist/item.c
index e912b0bcbc..5be9bba118 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -190,6 +190,26 @@ 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 the 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).
+             *
+             * By resetting the currently playing to the item immediately
+             * before the insertion point of the non-existing children, or the
+             * start of the playlist if we are at offset 0, this problem is
+             * fixed.
+             **/
+            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.13.0
    
    
More information about the vlc-devel
mailing list