From f56fcd71bbf302595afc19b3a8291cd47f485cfc Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 7 Dec 2014 12:49:07 +0100 Subject: options: add a 'once' idle mode This allows to make mpv wait for file open events at start but close after it is done playing the first playlist. --- DOCS/man/options.rst | 5 ++++- options/options.c | 7 ++++++- player/loadfile.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index ad5babb1f4..275f9d084a 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -333,11 +333,14 @@ Program Behavior This option is useful for debugging only. -``--idle`` +``--idle=`` Makes mpv wait idly instead of quitting when there is no file to play. Mostly useful in slave mode, where mpv can be controlled through input commands (see also ``--slave-broken``). + ``once`` will only idle at start and let the player close once the + first playlist has finished playing back. + ``--include=`` Specify configuration file to be parsed after the default ones. diff --git a/options/options.c b/options/options.c index 57cf20afa8..223c3ff666 100644 --- a/options/options.c +++ b/options/options.c @@ -541,7 +541,12 @@ const m_option_t mp_opts[] = { OPT_STRING("osd-msg2", osd_msg[1], 0), OPT_STRING("osd-msg3", osd_msg[2], 0), - OPT_FLAG("idle", player_idle_mode, M_OPT_GLOBAL), + OPT_CHOICE("idle", player_idle_mode, M_OPT_OPTIONAL_PARAM, + ({"no", 0}, + {"once", 1}, + {"yes", 2}, + {"", 2})), + OPT_FLAG("input-terminal", consolecontrols, CONF_GLOBAL), OPT_STRING("input-file", input_file, M_OPT_FILE | M_OPT_GLOBAL), diff --git a/player/loadfile.c b/player/loadfile.c index 5b04451667..d1b77743e6 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1313,7 +1313,7 @@ void mp_play_files(struct MPContext *mpctx) mpctx->playlist->current_was_replaced = false; mpctx->stop_play = 0; - if (!mpctx->playlist->current && !mpctx->opts->player_idle_mode) + if (!mpctx->playlist->current && mpctx->opts->player_idle_mode < 2) break; } } -- cgit v1.2.3