1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-12 13:44:56 +02:00

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 <jb@videolan.org>
This commit is contained in:
Romain Vimont 2019-05-16 13:02:52 +02:00 committed by Jean-Baptiste Kempf
parent c1625943f1
commit d5c1b16b55

View File

@ -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);