mirror of
https://github.com/mpv-player/mpv
synced 2025-02-18 13:47:04 +00:00
player: add a --keep-open=always mode
The --keep-open behavior was recently changed to act only on the last
file due to user requests (see commit 735a9c39
). But the old behavior
was useful too, so bring it back as an additional mode.
Fixes #1332 (or rather, should help with it).
This commit is contained in:
parent
2768ded1b9
commit
98e400216d
@ -1485,26 +1485,37 @@ Window
|
|||||||
|
|
||||||
OS X only. Black out other displays when going fullscreen.
|
OS X only. Black out other displays when going fullscreen.
|
||||||
|
|
||||||
``--keep-open``
|
``--keep-open=<yes|no|always``
|
||||||
Do not terminate when playing or seeking beyond the end of the file, and
|
Do not terminate when playing or seeking beyond the end of the file, and
|
||||||
there is not next file to be played (and ``--loop`` is not used).
|
there is not next file to be played (and ``--loop`` is not used).
|
||||||
Instead, pause the player. When trying to seek beyond end of the file, the
|
Instead, pause the player. When trying to seek beyond end of the file, the
|
||||||
player will pause at an arbitrary playback position (or, in corner cases,
|
player will attempt to seek to the last frame.
|
||||||
not redraw the window at all).
|
|
||||||
|
The following arguments can be given:
|
||||||
|
|
||||||
|
:no: If the current file ends, go to the next file or terminate.
|
||||||
|
(Default.)
|
||||||
|
:yes: Don't terminate if the current file is the last playlist entry.
|
||||||
|
Equivalent to ``--keep-open`` without arguments.
|
||||||
|
:always: Like ``yes``, but also applies to files before the last playlist
|
||||||
|
entry. This means playback will never automatically advance to
|
||||||
|
the next file.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
This option is not respected when using ``--frames``, ``--end``,
|
This option is not respected when using ``--frames``. Explicitly
|
||||||
``--length``, or when passing a chapter range to ``--chapter``.
|
skipping to the next file if the binding uses ``force`` will terminate
|
||||||
Explicitly skipping to the next file or skipping beyond the last
|
playback as well.
|
||||||
chapter will terminate playback as well, even if ``--keep-open`` is
|
|
||||||
given.
|
Also, if errors or unusual circumstances happen, the player can quit
|
||||||
|
anyway.
|
||||||
|
|
||||||
Since mpv 0.6.0, this doesn't pause if there is a next file in the playlist,
|
Since mpv 0.6.0, this doesn't pause if there is a next file in the playlist,
|
||||||
or the playlist is looped. Approximately, this will pause when the player
|
or the playlist is looped. Approximately, this will pause when the player
|
||||||
would normally exit, but in practice there are corner cases in which this
|
would normally exit, but in practice there are corner cases in which this
|
||||||
is not the case (e.g. ``mpv --keep-open file.mkv /dev/null`` will play
|
is not the case (e.g. ``mpv --keep-open file.mkv /dev/null`` will play
|
||||||
file.mkv normally, then fail to open ``/dev/null``, then exit).
|
file.mkv normally, then fail to open ``/dev/null``, then exit). (In
|
||||||
|
mpv 0.8.0, ``always`` was introduced, which restores the old behavior.)
|
||||||
|
|
||||||
``--force-window``
|
``--force-window``
|
||||||
Create a video output window even if there is no video. This can be useful
|
Create a video output window even if there is no video. This can be useful
|
||||||
|
@ -186,7 +186,10 @@ const m_option_t mp_opts[] = {
|
|||||||
OPT_TIME("ab-loop-b", ab_loop[1], 0, .min = MP_NOPTS_VALUE),
|
OPT_TIME("ab-loop-b", ab_loop[1], 0, .min = MP_NOPTS_VALUE),
|
||||||
|
|
||||||
OPT_FLAG("pause", pause, M_OPT_FIXED),
|
OPT_FLAG("pause", pause, M_OPT_FIXED),
|
||||||
OPT_FLAG("keep-open", keep_open, 0),
|
OPT_CHOICE("keep-open", keep_open, M_OPT_OPTIONAL_PARAM,
|
||||||
|
({"no", 0},
|
||||||
|
{"yes", 1}, {"", 1},
|
||||||
|
{"always", 2})),
|
||||||
|
|
||||||
OPT_CHOICE("index", index_mode, 0, ({"default", 1}, {"recreate", 0})),
|
OPT_CHOICE("index", index_mode, 0, ({"default", 1}, {"recreate", 0})),
|
||||||
|
|
||||||
|
@ -807,7 +807,8 @@ static void handle_keep_open(struct MPContext *mpctx)
|
|||||||
{
|
{
|
||||||
struct MPOpts *opts = mpctx->opts;
|
struct MPOpts *opts = mpctx->opts;
|
||||||
if (opts->keep_open && mpctx->stop_play == AT_END_OF_FILE &&
|
if (opts->keep_open && mpctx->stop_play == AT_END_OF_FILE &&
|
||||||
!playlist_get_next(mpctx->playlist, 1) && opts->loop_times < 0)
|
(opts->keep_open == 2 || !playlist_get_next(mpctx->playlist, 1)) &&
|
||||||
|
opts->loop_times < 0)
|
||||||
{
|
{
|
||||||
mpctx->stop_play = KEEP_PLAYING;
|
mpctx->stop_play = KEEP_PLAYING;
|
||||||
if (mpctx->d_video) {
|
if (mpctx->d_video) {
|
||||||
|
Loading…
Reference in New Issue
Block a user