mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-19 19:42:24 +02:00
player: don't decrement --ab-loop-count=N and add remaining-ab-loops
Follow up to the previous commit. Stop decreasing --ab-loop-count=N on each iteration so it is preserved across different loops. In particular it is preserved between different files without adding it to --reset-on-next-file. Add a property to expose the remaning A-B loop count instead. The current behavior of --ab-loop-count=N is even worse than --loop-file since it also doesn't reset when defining a new A-B loop in the same file. Defining it has no effect after --ab-loop-count has decreased to 0, and this can't be fixed by adding it to --reset-on-next-file. This commit also resets remaining-ab-loops every time --ab-loop-a and --ab-loop-b are set to fix this.
This commit is contained in:
parent
f411f3145b
commit
6107112b32
@ -1,2 +1,4 @@
|
||||
numerical values of `--loop-file` no longer decrease on each iteration
|
||||
add `remaining-file-loops` property as a replacement to get the remaining loop count
|
||||
numerical values of `--ab-loop-count` no longer decrease on each iteration
|
||||
add `remaining-ab-loops` property as a replacement to get the remaining loop count
|
||||
|
@ -2148,6 +2148,12 @@ Property list
|
||||
times it causes the player to seek to the beginning of the file, so it is 0
|
||||
the last the time is played. -1 corresponds to infinity.
|
||||
|
||||
``remaining-ab-loops``
|
||||
How many more times the current A-B loop is going to be looped, if one is
|
||||
active. This is initialized from the value of ``--ab-loop-count``. This
|
||||
counts the number of times it causes the player to seek to ``--ab-loop-a``,
|
||||
so it is 0 the last the time the loop is played. -1 corresponds to infinity.
|
||||
|
||||
``chapter`` (RW)
|
||||
Current chapter number. The number of the first chapter is 0.
|
||||
|
||||
|
@ -441,11 +441,10 @@ Playback Control
|
||||
|
||||
``--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).
|
||||
``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=<yes|no>``
|
||||
Enable support for Matroska ordered chapters. mpv will load and
|
||||
|
@ -876,6 +876,13 @@ static int mp_property_remaining_file_loops(void *ctx, struct m_property *prop,
|
||||
return m_property_int_ro(action, arg, mpctx->remaining_file_loops);
|
||||
}
|
||||
|
||||
static int mp_property_remaining_ab_loops(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
return m_property_int_ro(action, arg, mpctx->remaining_ab_loops);
|
||||
}
|
||||
|
||||
/// Current chapter (RW)
|
||||
static int mp_property_chapter(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
@ -4007,6 +4014,8 @@ static const struct m_property mp_properties_base[] = {
|
||||
{"playtime-remaining", mp_property_playtime_remaining},
|
||||
M_PROPERTY_ALIAS("playback-time", "time-pos"),
|
||||
{"remaining-file-loops", mp_property_remaining_file_loops},
|
||||
{"remaining-ab-loops", mp_property_remaining_ab_loops},
|
||||
{"chapter", mp_property_chapter},
|
||||
{"edition", mp_property_edition},
|
||||
{"current-edition", mp_property_current_edition},
|
||||
{"chapters", mp_property_chapters},
|
||||
@ -7496,6 +7505,12 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags,
|
||||
mp_notify_property(mpctx, "remaining-file-loops");
|
||||
}
|
||||
|
||||
if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1] ||
|
||||
opt_ptr == &opts->ab_loop_count) {
|
||||
mpctx->remaining_ab_loops = opts->ab_loop_count;
|
||||
mp_notify_property(mpctx, "remaining-ab-loops");
|
||||
}
|
||||
|
||||
if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1]) {
|
||||
update_ab_loop_clip(mpctx);
|
||||
// Update if visible
|
||||
|
@ -422,6 +422,7 @@ typedef struct MPContext {
|
||||
bool playing_msg_shown;
|
||||
|
||||
int remaining_file_loops;
|
||||
int remaining_ab_loops;
|
||||
|
||||
bool paused_for_cache;
|
||||
bool demux_underrun;
|
||||
|
@ -1635,6 +1635,8 @@ static void play_current_file(struct MPContext *mpctx)
|
||||
|
||||
mpctx->remaining_file_loops = mpctx->opts->loop_file;
|
||||
mp_notify_property(mpctx, "remaining-file-loops");
|
||||
mpctx->remaining_ab_loops = mpctx->opts->ab_loop_count;
|
||||
mp_notify_property(mpctx, "remaining-ab-loops");
|
||||
|
||||
mpctx->max_frames = opts->play_frames;
|
||||
|
||||
|
@ -129,7 +129,7 @@ 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)
|
||||
if (!mpctx->remaining_ab_loops)
|
||||
return false;
|
||||
|
||||
if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
|
||||
|
@ -885,8 +885,6 @@ static void handle_sstep(struct MPContext *mpctx)
|
||||
|
||||
static void handle_loop_file(struct MPContext *mpctx)
|
||||
{
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
|
||||
if (mpctx->stop_play != AT_END_OF_FILE)
|
||||
return;
|
||||
|
||||
@ -895,9 +893,9 @@ 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);
|
||||
if (mpctx->remaining_ab_loops > 0) {
|
||||
mpctx->remaining_ab_loops--;
|
||||
mp_notify_property(mpctx, "remaining-ab-loops");
|
||||
}
|
||||
target = ab[0];
|
||||
prec = MPSEEK_EXACT;
|
||||
|
Loading…
Reference in New Issue
Block a user