Skip to content

Commit 731229b

Browse files
na-na-hikasper93
authored andcommitted
options: add --playlist-inherit-options option
This allows controlling whether the files in a playlist inherit the per-file options of the playlist file itself. For playlists created by --autocreate-playlist, --playlist-inherit-options=current allows inheriting only for the item the playlist is created from.
1 parent 19215ef commit 731229b

5 files changed

Lines changed: 13 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add `--playlist-inherit-options` option

DOCS/man/options.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ Playback Control
335335
local files, such as special protocols like ``avdevice://`` (which are
336336
inherently unsafe).
337337

338+
``--playlist-inherit-options=<yes|no|current>``
339+
Whether the per-file options of a playlist file are inherited by its items
340+
when the playlist file is resolved and expanded (default: no). The value
341+
``current`` means that for playlists created by ``--autocreate-playlist``,
342+
only the file from which the playlist is created inherits the options.
343+
338344
``--chapter-merge-threshold=<number>``
339345
Threshold for merging almost consecutive ordered chapter parts in
340346
milliseconds (default: 100). Some Matroska files with ordered chapters

options/options.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@ static const m_option_t mp_opts[] = {
617617

618618
{"playlist-start", OPT_CHOICE(playlist_pos, {"auto", -1}, {"no", -1}),
619619
M_RANGE(0, INT_MAX)},
620+
{"playlist-inherit-options", OPT_CHOICE(playlist_inherit_options,
621+
{"no", 0}, {"yes", 1}, {"current", 2})},
620622

621623
{"pause", OPT_BOOL(pause)},
622624
{"keep-open", OPT_CHOICE(keep_open,

options/options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ typedef struct MPOpts {
283283
char **input_commands;
284284
bool consolecontrols;
285285
int playlist_pos;
286+
int playlist_inherit_options;
286287
struct m_rel_time play_start;
287288
struct m_rel_time play_end;
288289
struct m_rel_time play_length;

player/loadfile.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,10 @@ static void transfer_playlist(struct MPContext *mpctx, struct playlist *pl,
11421142
struct playlist_entry *new = pl->current;
11431143
struct playlist_entry *current = mpctx->playlist->current;
11441144
*num_new_entries = pl->num_entries;
1145-
if (current)
1145+
if (current && mpctx->opts->playlist_inherit_options == 1)
11461146
playlist_set_params(pl, current->params, current->num_params);
1147+
else if (current && new && mpctx->opts->playlist_inherit_options == 2)
1148+
playlist_entry_add_params(new, current->params, current->num_params);
11471149
*start_id = playlist_transfer_entries(mpctx->playlist, pl);
11481150
// current entry is replaced
11491151
if (current)

0 commit comments

Comments
 (0)