mirror of https://github.com/mpv-player/mpv
player: add ab-loop-count option/property
As requested I guess. It behaves quite similar to the --loop* options. Not quite happy with the idea that 1) the option is mutated on each operation (but at least it's consistent with --loop* and doesn't require more properties), and 2) the ab-loop command will do nothing once all loop iterations are done. As a concession, the OSD shows something about "disabled". Fixes: #7360
This commit is contained in:
parent
3fb0cc203b
commit
e9fc53a10b
|
@ -346,6 +346,14 @@ Playback Control
|
|||
The loop-points can be adjusted at runtime with the corresponding
|
||||
properties. See also ``ab-loop`` command.
|
||||
|
||||
``--ab-loop-count=<N|inf>``
|
||||
Run A-B loops only N times, then ignore the A-B loop points (default: inf).
|
||||
Every finished loop iteration will decrement this option by 1 (unless it is
|
||||
set to ``inf`` or 0). ``inf`` means that looping goes on forever. If this
|
||||
option is set to 0, A-B looping is ignored, and even the ``ab-loop`` command
|
||||
will not enable looping again (the command will show ``(disabled)`` on the
|
||||
OSD message if both loop points are set, but ``ab-loop-count`` is 0).
|
||||
|
||||
``--ordered-chapters``, ``--no-ordered-chapters``
|
||||
Enabled by default.
|
||||
Disable support for Matroska ordered chapters. mpv will not load or
|
||||
|
|
|
@ -427,6 +427,8 @@ static const m_option_t mp_opts[] = {
|
|||
|
||||
OPT_TIME("ab-loop-a", ab_loop[0], 0, .min = MP_NOPTS_VALUE),
|
||||
OPT_TIME("ab-loop-b", ab_loop[1], 0, .min = MP_NOPTS_VALUE),
|
||||
OPT_CHOICE_OR_INT("ab-loop-count", ab_loop_count, 0, 0, INT_MAX,
|
||||
({"inf", -1})),
|
||||
|
||||
OPT_CHOICE_OR_INT("playlist-start", playlist_pos, 0, 0, INT_MAX,
|
||||
({"auto", -1}, {"no", -1})),
|
||||
|
@ -940,6 +942,7 @@ static const struct MPOpts mp_default_opts = {
|
|||
.cache_pause = 1,
|
||||
.cache_pause_wait = 1.0,
|
||||
.ab_loop = {MP_NOPTS_VALUE, MP_NOPTS_VALUE},
|
||||
.ab_loop_count = -1,
|
||||
.edition_id = -1,
|
||||
.default_max_pts_correction = -1,
|
||||
.correct_pts = 1,
|
||||
|
|
|
@ -232,6 +232,7 @@ typedef struct MPOpts {
|
|||
int rebase_start_time;
|
||||
int play_frames;
|
||||
double ab_loop[2];
|
||||
int ab_loop_count;
|
||||
double step_sec;
|
||||
int position_resume;
|
||||
int position_check_mtime;
|
||||
|
|
|
@ -3731,7 +3731,8 @@ static const struct property_osd_display {
|
|||
{"vf", "Video filters", .msg = "Video filters:\n${vf}"},
|
||||
{"af", "Audio filters", .msg = "Audio filters:\n${af}"},
|
||||
{"ab-loop-a", "A-B loop start"},
|
||||
{"ab-loop-b", .msg = "A-B loop: ${ab-loop-a} - ${ab-loop-b}"},
|
||||
{"ab-loop-b", .msg = "A-B loop: ${ab-loop-a} - ${ab-loop-b}"
|
||||
"${?=ab-loop-count==0: (disabled)}"},
|
||||
{"audio-device", "Audio device"},
|
||||
{"hwdec", .msg = "Hardware decoding: ${hwdec-current}"},
|
||||
{"video-aspect-override", "Aspect ratio override"},
|
||||
|
|
|
@ -123,6 +123,9 @@ bool get_ab_loop_times(struct MPContext *mpctx, double t[2])
|
|||
t[0] = opts->ab_loop[0];
|
||||
t[1] = opts->ab_loop[1];
|
||||
|
||||
if (!opts->ab_loop_count)
|
||||
return false;
|
||||
|
||||
if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
|
||||
return false;
|
||||
|
||||
|
|
|
@ -885,6 +885,10 @@ static void handle_loop_file(struct MPContext *mpctx)
|
|||
|
||||
double ab[2];
|
||||
if (get_ab_loop_times(mpctx, ab) && mpctx->ab_loop_clip) {
|
||||
if (opts->ab_loop_count > 0) {
|
||||
opts->ab_loop_count--;
|
||||
m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->ab_loop_count);
|
||||
}
|
||||
target = ab[0];
|
||||
prec = MPSEEK_EXACT;
|
||||
} else if (opts->loop_file) {
|
||||
|
|
Loading…
Reference in New Issue