0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

command: improve A-B loop behavior

If the B point is set, then loop back to A.

Also, update the OSD bar if necessary.
This commit is contained in:
wm4 2014-11-18 20:28:54 +01:00
parent 71095be5b0
commit 5d1a3fb406
3 changed files with 16 additions and 3 deletions

View File

@ -2935,7 +2935,8 @@ static int mp_property_af(void *ctx, struct m_property *prop,
static int mp_property_ab_loop(void *ctx, struct m_property *prop, static int mp_property_ab_loop(void *ctx, struct m_property *prop,
int action, void *arg) int action, void *arg)
{ {
MPContext *mpctx = ctx; struct MPContext *mpctx = ctx;
struct MPOpts *opts = mpctx->opts;
if (action == M_PROPERTY_KEY_ACTION) { if (action == M_PROPERTY_KEY_ACTION) {
double val; double val;
if (mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &val) < 1) if (mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &val) < 1)
@ -2943,7 +2944,18 @@ static int mp_property_ab_loop(void *ctx, struct m_property *prop,
return property_time(action, arg, val); return property_time(action, arg, val);
} }
return mp_property_generic_option(mpctx, prop, action, arg); int r = mp_property_generic_option(mpctx, prop, action, arg);
if (r > 0 && action == M_PROPERTY_SET) {
if (strcmp(prop->name, "ab-loop-b") == 0) {
double now = mpctx->playback_pts;
if (now != MP_NOPTS_VALUE && opts->ab_loop[0] != MP_NOPTS_VALUE &&
opts->ab_loop[1] != MP_NOPTS_VALUE && now >= opts->ab_loop[1])
queue_seek(mpctx, MPSEEK_ABSOLUTE, opts->ab_loop[0], 1, false);
}
// Update if visible
set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
}
return r;
} }
static int mp_property_version(void *ctx, struct m_property *prop, static int mp_property_version(void *ctx, struct m_property *prop,

View File

@ -423,6 +423,7 @@ bool set_osd_msg(struct MPContext *mpctx, int level, int time,
void set_osd_function(struct MPContext *mpctx, int osd_function); void set_osd_function(struct MPContext *mpctx, int osd_function);
void set_osd_subtitle(struct MPContext *mpctx, const char *text); void set_osd_subtitle(struct MPContext *mpctx, const char *text);
void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size); void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size);
void set_osd_bar_chapters(struct MPContext *mpctx, int type);
// playloop.c // playloop.c
void mp_wait_events(struct MPContext *mpctx, double sleeptime); void mp_wait_events(struct MPContext *mpctx, double sleeptime);

View File

@ -331,7 +331,7 @@ static void update_osd_bar(struct MPContext *mpctx, int type,
} }
} }
static void set_osd_bar_chapters(struct MPContext *mpctx, int type) void set_osd_bar_chapters(struct MPContext *mpctx, int type)
{ {
struct MPOpts *opts = mpctx->opts; struct MPOpts *opts = mpctx->opts;
if (mpctx->osd_progbar.type != type) if (mpctx->osd_progbar.type != type)