mirror of
https://github.com/mpv-player/mpv
synced 2025-01-11 09:29:29 +00:00
core: add --reset-on-next-file option
This option can be used to selectively reset settings when playing the next file in the playlist (i.e. restore mplayer and mplayer2 behavior). Might remove this option again should it turn out that nobody uses it.
This commit is contained in:
parent
62daa08d3b
commit
9df2260506
@ -1739,6 +1739,30 @@
|
||||
--referrer=<string>
|
||||
Specify a referrer path or URL for HTTP requests.
|
||||
|
||||
--reset-on-next-file=<all|option1,option2,...>
|
||||
Normally, mpv will try to keep all settings when playing the next file on
|
||||
the playlist, even if they were changed by the user during playback. (This
|
||||
behavior is the opposite of MPlayer's, which tries to reset all settings
|
||||
when starting next file.)
|
||||
|
||||
This can be changed with this option. It accepts a list of options, and
|
||||
mpv will reset the value of these options on playback start to the initial
|
||||
value. The initial value is either the default value, or as set by the
|
||||
config file or command line.
|
||||
|
||||
In some cases, this might not work as expected. For example, ``--volume``
|
||||
will only be reset the volume if it's explicitly set in the config file
|
||||
or the command line.
|
||||
|
||||
The special name ``all`` resets as many options as possible.
|
||||
|
||||
*EXAMPLE*:
|
||||
|
||||
- ``--reset-on-next-file=fullscreen,speed`` Reset fullscreen and playback
|
||||
speed settings if they were changed during playback.
|
||||
- ``--reset-on-next-file=all`` Try to reset all settings that were changed
|
||||
during playback.
|
||||
|
||||
--reuse-socket
|
||||
(udp:// only)
|
||||
Allows a socket to be reused by other processes as soon as it is closed.
|
||||
|
@ -297,6 +297,7 @@ const m_option_t common_opts[] = {
|
||||
{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
#endif
|
||||
OPT_FLAG("config", load_config, CONF_GLOBAL | CONF_NOCFG | CONF_PRE_PARSE),
|
||||
OPT_STRINGLIST("reset-on-next-file", reset_options, CONF_GLOBAL),
|
||||
|
||||
// ------------------------- stream options --------------------
|
||||
|
||||
|
@ -258,6 +258,22 @@ void m_config_leave_file_local(struct m_config *config)
|
||||
}
|
||||
}
|
||||
|
||||
void m_config_mark_file_local(struct m_config *config, const char *opt)
|
||||
{
|
||||
struct m_config_option *co = m_config_get_co(config, bstr0(opt));
|
||||
if (co) {
|
||||
ensure_backup(config, co);
|
||||
} else {
|
||||
mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, "Option %s not found.\n", opt);
|
||||
}
|
||||
}
|
||||
|
||||
void m_config_mark_all_file_local(struct m_config *config)
|
||||
{
|
||||
for (struct m_config_option *co = config->opts; co; co = co->next)
|
||||
ensure_backup(config, co);
|
||||
}
|
||||
|
||||
// Given an option --opt, add --no-opt (if applicable).
|
||||
static void add_negation_option(struct m_config *config,
|
||||
struct m_config_option *parent,
|
||||
|
@ -97,6 +97,8 @@ void m_config_free(struct m_config *config);
|
||||
|
||||
void m_config_enter_file_local(struct m_config *config);
|
||||
void m_config_leave_file_local(struct m_config *config);
|
||||
void m_config_mark_file_local(struct m_config *config, const char *opt);
|
||||
void m_config_mark_all_file_local(struct m_config *config);
|
||||
|
||||
/* Register some options to be used.
|
||||
* \param config The config object.
|
||||
|
@ -3877,6 +3877,17 @@ static void play_current_file(struct MPContext *mpctx)
|
||||
load_per_file_options(mpctx->mconfig, mpctx->playlist->current->params,
|
||||
mpctx->playlist->current->num_params);
|
||||
|
||||
if (opts->reset_options) {
|
||||
for (int n = 0; opts->reset_options[n]; n++) {
|
||||
const char *opt = opts->reset_options[n];
|
||||
if (strcmp(opt, "all") == 0) {
|
||||
m_config_mark_all_file_local(mpctx->mconfig);
|
||||
} else {
|
||||
m_config_mark_file_local(mpctx->mconfig, opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We must enable getch2 here to be able to interrupt network connection
|
||||
// or cache filling
|
||||
if (opts->consolecontrols && !opts->slave_mode) {
|
||||
|
@ -43,6 +43,8 @@ typedef struct mp_vo_opts {
|
||||
} mp_vo_opts;
|
||||
|
||||
typedef struct MPOpts {
|
||||
char **reset_options;
|
||||
|
||||
char **audio_driver_list;
|
||||
int fixed_vo;
|
||||
char *mixer_device;
|
||||
|
Loading…
Reference in New Issue
Block a user