summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-18 00:09:42 +0100
committerwm4 <wm4@nowhere>2014-11-18 01:36:35 +0100
commit4bd6c91d9b4c4d35d0d71793933947861e45daad (patch)
tree1c22de1369e8ec8028e20560a653d9ba7deba371 /options
parented5923437848bb4c1afa7104c29f21c7a44743f0 (diff)
downloadmpv-4bd6c91d9b4c4d35d0d71793933947861e45daad.tar.bz2
mpv-4bd6c91d9b4c4d35d0d71793933947861e45daad.tar.xz
command: implement A-B loops
Probably needs to be polished a bit more. Also, might require a key binding that can set/clear the loop points in a more intuitive way. For now, something like this can be put into input.conf to use it: ctrl+y set ab-loop-a ${time-pos} # set A ctrl+x set ab-loop-b ${time-pos} # set B ctrl+c set ab-loop-a no # clear (mostly) Fixes #1241.
Diffstat (limited to 'options')
-rw-r--r--options/m_option.c9
-rw-r--r--options/options.c3
-rw-r--r--options/options.h1
3 files changed, 11 insertions, 2 deletions
diff --git a/options/m_option.c b/options/m_option.c
index 97ba467ed4..9ec6ccc427 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -2180,7 +2180,9 @@ static int parse_time(struct mp_log *log, const m_option_t *opt,
if (param.len == 0)
return M_OPT_MISSING_PARAM;
- if (!parse_timestring(param, &time, 0)) {
+ if (opt->min == MP_NOPTS_VALUE && bstr_equals0(param, "no")) {
+ time = MP_NOPTS_VALUE;
+ } else if (!parse_timestring(param, &time, 0)) {
mp_err(log, "Option %.*s: invalid time: '%.*s'\n",
BSTR_P(name), BSTR_P(param));
return M_OPT_INVALID;
@@ -2193,7 +2195,10 @@ static int parse_time(struct mp_log *log, const m_option_t *opt,
static char *pretty_print_time(const m_option_t *opt, const void *val)
{
- return mp_format_time(*(double *)val, false);
+ double pts = *(double *)val;
+ if (pts == MP_NOPTS_VALUE && opt->min == MP_NOPTS_VALUE)
+ return talloc_strdup(NULL, "no"); // symmetry with parsing
+ return mp_format_time(pts, false);
}
const m_option_type_t m_option_type_time = {
diff --git a/options/options.c b/options/options.c
index ba251f6216..4a4d83210b 100644
--- a/options/options.c
+++ b/options/options.c
@@ -180,6 +180,9 @@ const m_option_t mp_opts[] = {
OPT_REL_TIME("end", play_end, 0),
OPT_REL_TIME("length", play_length, 0),
+ 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_FLAG("pause", pause, M_OPT_FIXED),
OPT_FLAG("keep-open", keep_open, 0),
diff --git a/options/options.h b/options/options.h
index 9284320f40..63f77b2b3a 100644
--- a/options/options.h
+++ b/options/options.h
@@ -158,6 +158,7 @@ typedef struct MPOpts {
struct m_rel_time play_end;
struct m_rel_time play_length;
int play_frames;
+ double ab_loop[2];
double step_sec;
int position_resume;
int position_save_on_quit;