summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/options.rst4
-rw-r--r--player/command.c10
-rw-r--r--player/core.h1
-rw-r--r--player/loadfile.c20
-rw-r--r--player/main.c10
5 files changed, 26 insertions, 19 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 1635461ec5..0feca9d765 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -363,10 +363,6 @@ Program Behavior
file. This uses timeline/EDL support internally. Note that this won't work
for ordered chapter files.
- This option is interpreted at program start, and doesn't affect for
- example files or playlists loaded with the ``loadfile`` or ``loadlist``
- commands.
-
``--no-resume-playback``
Do not restore playback position from the ``watch_later`` configuration
subdirectory (usually ``~/.config/mpv/watch_later/``).
diff --git a/player/command.c b/player/command.c
index dbf9167fff..4e5fdc6509 100644
--- a/player/command.c
+++ b/player/command.c
@@ -4343,16 +4343,16 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
bool append = cmd->args[1].v.i;
struct playlist *pl = playlist_parse_file(filename, mpctx->global);
if (pl) {
+ prepare_playlist(mpctx, pl);
+ struct playlist_entry *new = pl->current;
if (!append)
playlist_clear(mpctx->playlist);
playlist_append_entries(mpctx->playlist, pl);
talloc_free(pl);
- if (!append && mpctx->playlist->first) {
- struct playlist_entry *e =
- mp_check_playlist_resume(mpctx, mpctx->playlist);
- mp_set_playlist_entry(mpctx, e ? e : mpctx->playlist->first);
- }
+ if (!append && mpctx->playlist->first)
+ mp_set_playlist_entry(mpctx, new ? new : mpctx->playlist->first);
+
mp_notify_property(mpctx, "playlist");
} else {
MP_ERR(mpctx, "Unable to load playlist %s.\n", filename);
diff --git a/player/core.h b/player/core.h
index bb310e0975..8184b133ce 100644
--- a/player/core.h
+++ b/player/core.h
@@ -395,6 +395,7 @@ void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e);
void mp_play_files(struct MPContext *mpctx);
void update_demuxer_properties(struct MPContext *mpctx);
void reselect_demux_streams(struct MPContext *mpctx);
+void prepare_playlist(struct MPContext *mpctx, struct playlist *pl);
// main.c
int mpv_main(int argc, char *argv[]);
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)
diff --git a/player/main.c b/player/main.c
index 700dbfa48f..41a57981e4 100644
--- a/player/main.c
+++ b/player/main.c
@@ -467,15 +467,7 @@ int mp_initialize(struct MPContext *mpctx)
mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
#endif
- if (opts->shuffle)
- playlist_shuffle(mpctx->playlist);
-
- if (opts->merge_files)
- merge_playlist_files(mpctx->playlist);
-
- mpctx->playlist->current = mp_check_playlist_resume(mpctx, mpctx->playlist);
- if (!mpctx->playlist->current)
- mpctx->playlist->current = mpctx->playlist->first;
+ prepare_playlist(mpctx, mpctx->playlist);
MP_STATS(mpctx, "end init");