summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-18 20:28:54 +0100
committerwm4 <wm4@nowhere>2014-11-18 20:28:54 +0100
commit5d1a3fb406b1d356155c64b64c9c020e7c245887 (patch)
treea81782846e666ea33ee73f366e9f010ccfda9472
parent71095be5b0ed574c35016301c3b94fc7ec149f04 (diff)
downloadmpv-5d1a3fb406b1d356155c64b64c9c020e7c245887.tar.bz2
mpv-5d1a3fb406b1d356155c64b64c9c020e7c245887.tar.xz
command: improve A-B loop behavior
If the B point is set, then loop back to A. Also, update the OSD bar if necessary.
-rw-r--r--player/command.c16
-rw-r--r--player/core.h1
-rw-r--r--player/osd.c2
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)