[vlc-devel] [PATCH 7/7] playlist: update the randomizer on media change
Romain Vimont
rom1v at videolabs.io
Thu May 16 17:50:46 CEST 2019
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.
---
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);
--
2.20.1
More information about the vlc-devel
mailing list