From 5d1a3fb406b1d356155c64b64c9c020e7c245887 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 18 Nov 2014 20:28:54 +0100 Subject: command: improve A-B loop behavior If the B point is set, then loop back to A. Also, update the OSD bar if necessary. --- player/command.c | 16 ++++++++++++++-- player/core.h | 1 + player/osd.c | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/player/command.c b/player/command.c index 803558f7d9..0041364c8d 100644 --- a/player/command.c +++ b/player/command.c @@ -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, int action, void *arg) { - MPContext *mpctx = ctx; + struct MPContext *mpctx = ctx; + struct MPOpts *opts = mpctx->opts; if (action == M_PROPERTY_KEY_ACTION) { double val; 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 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, diff --git a/player/core.h b/player/core.h index e7402cfe5d..d3fc4195e2 100644 --- a/player/core.h +++ b/player/core.h @@ -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_subtitle(struct MPContext *mpctx, const char *text); 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 void mp_wait_events(struct MPContext *mpctx, double sleeptime); diff --git a/player/osd.c b/player/osd.c index b6a0c1b98d..456822d9f6 100644 --- a/player/osd.c +++ b/player/osd.c @@ -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; if (mpctx->osd_progbar.type != type) -- cgit v1.2.3