From d5c1b16b557ed657541ce7aa664b4ba8a87c510c Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 16 May 2019 13:02:52 +0200 Subject: [PATCH] playlist: update the randomizer on media change When the player notifies that the current media has changed, it must be considered "selected" by the randomizer. Otherwise, when the player requests the next media to play, the playlist will always "peek" the same next item from the randomizer, which will never actually "select" it. Signed-off-by: Jean-Baptiste Kempf --- src/playlist/player.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/playlist/player.c b/src/playlist/player.c index bbdc39ba0e..6ca6ea0636 100644 --- a/src/playlist/player.c +++ b/src/playlist/player.c @@ -48,8 +48,19 @@ player_on_current_media_changed(vlc_player_t *player, input_item_t *new_media, /* nothing to do */ return; - ssize_t index = new_media ? vlc_playlist_IndexOfMedia(playlist, new_media) - : -1; + ssize_t index; + if (new_media) + { + index = vlc_playlist_IndexOfMedia(playlist, new_media); + if (index != -1) + { + vlc_playlist_item_t *item = playlist->items.data[index]; + if (playlist->order == VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM) + randomizer_Select(&playlist->randomizer, item); + } + } + else + index = -1; struct vlc_playlist_state state; vlc_playlist_state_Save(playlist, &state);