summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-29 22:08:22 +0100
committerwm4 <wm4@nowhere>2014-12-29 22:08:22 +0100
commit6618e5d69ab2f1eef70769e46f4129d13bd7ff29 (patch)
treeff20ad08cc4673073543fbd866a4fff2bc8478e6 /player/loadfile.c
parent40755180113ac58cd98fb0f6758c1466e56d5f94 (diff)
downloadmpv-6618e5d69ab2f1eef70769e46f4129d13bd7ff29.tar.bz2
mpv-6618e5d69ab2f1eef70769e46f4129d13bd7ff29.tar.xz
player: make --shuffle/--merge-files affect runtime loaded playlists
Until now, these options took effect only at program start. This could be confusing when e.g. doing "mpv list.m3u --shuffle". Make them always take effect when a playlist is loaded either via a playlist file, or with the "loadlist" command.
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 624f6beebc..2f75a5bea9 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -737,12 +737,30 @@ struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename)
STREAM_SUB);
}
+// Do stuff to a newly loaded playlist. This includes any processing that may
+// be required after loading a playlist.
+void prepare_playlist(struct MPContext *mpctx, struct playlist *pl)
+{
+ struct MPOpts *opts = mpctx->opts;
+
+ if (opts->shuffle)
+ playlist_shuffle(pl);
+
+ if (opts->merge_files)
+ merge_playlist_files(pl);
+
+ pl->current = mp_check_playlist_resume(mpctx, pl);
+ if (!pl->current)
+ pl->current = pl->first;
+}
+
// Replace the current playlist entry with playlist contents. Moves the entries
// from the given playlist pl, so the entries don't actually need to be copied.
static void transfer_playlist(struct MPContext *mpctx, struct playlist *pl)
{
if (pl->first) {
- struct playlist_entry *new = mp_check_playlist_resume(mpctx, pl);
+ prepare_playlist(mpctx, pl);
+ struct playlist_entry *new = pl->current;
playlist_transfer_entries(mpctx->playlist, pl);
// current entry is replaced
if (mpctx->playlist->current)