player: allow passing number of loops to --loop-file

E.g. --loop-file=2 will play the file 3 times (one time normally, and 2
repeats).

Minor syntax issue: "--loop-file 5" won't work, you have to use
"--loop-file=5". This is because "--loop-file" still has to work for
compatibility, so the "old" syntax with a space between option name and
value can't work.
This commit is contained in:
wm4 2014-09-22 22:56:00 +02:00
parent 9ce4526139
commit 9fe076f02a
3 changed files with 14 additions and 6 deletions

View File

@ -205,11 +205,15 @@ Playback Control
Note that ``--playlist`` always loads all entries, so you use that instead Note that ``--playlist`` always loads all entries, so you use that instead
if you really have the need for this functionality. if you really have the need for this functionality.
``--loop-file`` ``--loop-file=<N|inf|no>``
Loop a single file. The difference to ``--loop=inf`` is that this doesn't Loop a single file N times. ``inf`` means forever, ``no`` means normal
loop the playlist, just the file itself. If the playlist contains only a playback. For compatibility, ``--loop-file`` and ``--loop-file=yes`` are
single file, the difference between the two option is that this option also accepted, and are the same as ``--loop-file=inf``.
performs a seek on loop, instead of reloading the file.
The difference to ``--loop`` is that this doesn't loop the playlist, just
the file itself. If the playlist contains only a single file, the difference
between the two option is that this option performs a seek on loop, instead
of reloading the file.
``--ordered-chapters``, ``--no-ordered-chapters`` ``--ordered-chapters``, ``--no-ordered-chapters``
Enabled by default. Enabled by default.

View File

@ -481,7 +481,9 @@ const m_option_t mp_opts[] = {
OPT_CHOICE_OR_INT("loop", loop_times, M_OPT_GLOBAL, 2, 10000, OPT_CHOICE_OR_INT("loop", loop_times, M_OPT_GLOBAL, 2, 10000,
({"no", -1}, {"1", -1}, ({"no", -1}, {"1", -1},
{"inf", 0})), {"inf", 0})),
OPT_FLAG("loop-file", loop_file, 0), OPT_CHOICE_OR_INT("loop-file", loop_file, M_OPT_OPTIONAL_PARAM, 0, 10000,
({"yes", -1}, {"", -1}, {"no", 0}, // compat
{"inf", -1})),
OPT_FLAG("resume-playback", position_resume, 0), OPT_FLAG("resume-playback", position_resume, 0),
OPT_FLAG("save-position-on-quit", position_save_on_quit, 0), OPT_FLAG("save-position-on-quit", position_save_on_quit, 0),

View File

@ -756,6 +756,8 @@ static void handle_loop_file(struct MPContext *mpctx)
mpctx->stop_play = KEEP_PLAYING; mpctx->stop_play = KEEP_PLAYING;
set_osd_function(mpctx, OSD_FFW); set_osd_function(mpctx, OSD_FFW);
queue_seek(mpctx, MPSEEK_ABSOLUTE, get_start_time(mpctx), 0, true); queue_seek(mpctx, MPSEEK_ABSOLUTE, get_start_time(mpctx), 0, true);
if (opts->loop_file > 0)
opts->loop_file--;
} }
} }