command: if only ab-loop-b is set, loop from start of file

Commit 382bafcb changed the behavior for ab-loop-a. This commit changes
ab-loop-b so that the behavior is symmetric.

Adjust the OSD rendering accordingly to the two changes.

Also fix mentions of the "ab_loop" command to the now preferred
"ab-loop".
This commit is contained in:
wm4 2016-04-21 22:15:17 +02:00
parent 78346e9c9a
commit 1944a34c23
6 changed files with 26 additions and 16 deletions

View File

@ -20,8 +20,9 @@ Interface changes
::
--- mpv 0.17.1 ---
- now ab-loops are active even if the "ab-loop-b" property is unset ("no"),
in which case the end of the file is used as B loop point
- now ab-loops are active even if one of the "ab-loop-a"/"-b" properties is
unset ("no"), in which case the start of the file is used if the A loop
point is unsert, and the end of the file for an unset B loop point
--- mpv 0.17.0 ---
- deprecate "track-list/N/audio-channels" property (use
"track-list/N/demux-channel-count" instead)

View File

@ -1081,9 +1081,8 @@ Property list
"default" MPV_FORMAT_FLAG
``ab-loop-a``, ``ab-loop-b`` (RW)
Set/get A-B loop points. See corresponding options and ``ab-loop`` command.
The special value ``no`` on ``ab-loop-a`` disables looping, while setting
``ab-loop-b`` to ``no`` loops when the end of the file is reached.
Set/get A-B loop points. See corresponding options and ``ab-loop`` command
for details.
``angle`` (RW)
Current DVD angle.

View File

@ -261,8 +261,13 @@ Playback Control
``--ab-loop-a=<time>``, ``--ab-loop-b=<time>``
Set loop points. If playback passes the ``b`` timestamp, it will seek to
the ``a`` timestamp. Seeking past the ``b`` point doesn't loop (this is
intentional). The loop-points can be adjusted at runtime with the
corresponding properties. See also ``ab_loop`` command.
intentional).
If both options are set to ``no``, looping is disabled. Otherwise, the
start/end of the file is used if one of the options is set to ``no``.
The loop-points can be adjusted at runtime with the corresponding
properties. See also ``ab-loop`` command.
``--ordered-chapters``, ``--no-ordered-chapters``
Enabled by default.

View File

@ -142,7 +142,7 @@
#CLOSE_WIN quit
#CLOSE_WIN {encode} quit 4
#E cycle edition # next edition
#l ab_loop # Set/clear A-B loop points
#l ab-loop # Set/clear A-B loop points
#L cycle-values loop "inf" "no" # toggle infinite looping
#ctrl+c quit 4

View File

@ -5245,16 +5245,20 @@ void handle_ab_loop(struct MPContext *mpctx)
struct MPOpts *opts = mpctx->opts;
double now = mpctx->restart_complete ? mpctx->playback_pts : MP_NOPTS_VALUE;
if (now != MP_NOPTS_VALUE && opts->ab_loop[0] != MP_NOPTS_VALUE) {
if (now != MP_NOPTS_VALUE && (opts->ab_loop[0] != MP_NOPTS_VALUE ||
opts->ab_loop[1] != MP_NOPTS_VALUE))
{
double start = opts->ab_loop[0];
if (start == MP_NOPTS_VALUE)
start = 0;
double end = opts->ab_loop[1];
if (end == MP_NOPTS_VALUE)
end = INFINITY;
if (ctx->prev_pts >= opts->ab_loop[0] &&
ctx->prev_pts < end &&
if (ctx->prev_pts >= start && ctx->prev_pts < end &&
(now >= end || mpctx->stop_play == AT_END_OF_FILE))
{
mark_seek(mpctx);
queue_seek(mpctx, MPSEEK_ABSOLUTE, opts->ab_loop[0],
queue_seek(mpctx, MPSEEK_ABSOLUTE, start,
MPSEEK_EXACT, false);
}
}

View File

@ -362,14 +362,15 @@ void set_osd_bar_chapters(struct MPContext *mpctx, int type)
mpctx->osd_progbar.num_stops = 0;
double len = get_time_length(mpctx);
if (len > 0) {
if (opts->ab_loop[0] != MP_NOPTS_VALUE &&
opts->ab_loop[1] != MP_NOPTS_VALUE)
{
if (opts->ab_loop[0] != MP_NOPTS_VALUE) {
MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
mpctx->osd_progbar.num_stops, opts->ab_loop[0] / len);
}
if (opts->ab_loop[1] != MP_NOPTS_VALUE) {
MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
mpctx->osd_progbar.num_stops, opts->ab_loop[1] / len);
} else {
}
if (mpctx->osd_progbar.stops == 0) {
int num = get_chapter_count(mpctx);
for (int n = 0; n < num; n++) {
double time = chapter_start_time(mpctx, n);