summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-18 21:33:15 +0100
committerwm4 <wm4@nowhere>2014-11-18 21:34:57 +0100
commit534b08e6ba924f96dfb9edc4a564d7596db35574 (patch)
tree113ea2d69918bb7ff93507a28c57e093b8b6e777
parent5d1a3fb406b1d356155c64b64c9c020e7c245887 (diff)
downloadmpv-534b08e6ba924f96dfb9edc4a564d7596db35574.tar.bz2
mpv-534b08e6ba924f96dfb9edc4a564d7596db35574.tar.xz
command: add an ab_loop command
As suggested in #1241; to make using the feature easier. Also add better OSD-formatting for the ab-loop-a/b properties.
-rw-r--r--DOCS/man/input.rst7
-rw-r--r--DOCS/man/options.rst2
-rw-r--r--input/cmd_list.c2
-rw-r--r--input/cmd_list.h2
-rw-r--r--player/command.c20
5 files changed, 31 insertions, 2 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 0e9b245ad8..d268d6426c 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -544,6 +544,11 @@ Input Commands that are Possibly Subject to Change
(Scripts use this internally to dispatch key bindings, and this can also
be used in input.conf to reassign such bindings.)
+``ab_loop``
+ Cycle through A-B loop states. The first command will set the ``A`` point
+ (the ``ab-loop-a`` property); the second the ``B`` point, and the third
+ will clear both points.
+
Undocumented commands: ``tv_last_channel`` (TV/DVB only), ``get_property`` (?),
``vo_cmdline`` (experimental), ``ao_reload`` (experimental/internal).
@@ -779,7 +784,7 @@ Property list
"default" MPV_FORMAT_FLAG
``ab-loop-a``, ``ab-loop-b`` (TW)
- Set/get A-B loop points. See corresponding options.
+ Set/get A-B loop points. See corresponding options and ``ab_loop`` command.
``angle`` (RW)
Current DVD angle.
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 39fe8ffa92..b2ddd1c12a 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -233,7 +233,7 @@ Playback Control
Set loop points. If playback passes the ``b`` timestamp, it will seek to
the ``a`` timestamp. Seeking past the ``b`` point doesn't loop (this is
intentional). The loop-points can be adjusted at runtime with the
- corresponding properties.
+ corresponding properties. See also ``ab_loop`` command.
``--ordered-chapters``, ``--no-ordered-chapters``
Enabled by default.
diff --git a/input/cmd_list.c b/input/cmd_list.c
index e281c84f9e..b513ff48ab 100644
--- a/input/cmd_list.c
+++ b/input/cmd_list.c
@@ -155,6 +155,8 @@ const struct mp_cmd_def mp_cmds[] = {
{ MP_CMD_DISCNAV, "discnav", { ARG_STRING } },
+ { MP_CMD_AB_LOOP, "ab_loop", },
+
{ MP_CMD_AF, "af", { ARG_STRING, ARG_STRING } },
{ MP_CMD_AO_RELOAD, "ao_reload", },
diff --git a/input/cmd_list.h b/input/cmd_list.h
index c99ac58be9..8dc754c774 100644
--- a/input/cmd_list.h
+++ b/input/cmd_list.h
@@ -78,6 +78,8 @@ enum mp_command_type {
MP_CMD_DISCNAV,
+ MP_CMD_AB_LOOP,
+
/// Audio Filter commands
MP_CMD_AF,
MP_CMD_AO_RELOAD,
diff --git a/player/command.c b/player/command.c
index 0041364c8d..0559221322 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3527,6 +3527,8 @@ static const struct property_osd_display {
{ "tv-hue", "Hue", .osd_progbar = OSD_HUE},
{ "tv-saturation", "Saturation", .osd_progbar = OSD_SATURATION },
{ "tv-contrast", "Contrast", .osd_progbar = OSD_CONTRAST },
+ { "ab-loop-a", "A-B loop point A"},
+ { "ab-loop-b", "A-B loop point B"},
// By default, don't display the following properties on OSD
{ "pause", NULL },
{ "fullscreen", NULL },
@@ -4420,6 +4422,24 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
mp_nav_user_input(mpctx, cmd->args[0].v.s);
break;
+ case MP_CMD_AB_LOOP: {
+ double now = get_current_time(mpctx);
+ int r = 0;
+ if (opts->ab_loop[0] == MP_NOPTS_VALUE) {
+ r = mp_property_do("ab-loop-a", M_PROPERTY_SET, &now, mpctx);
+ show_property_osd(mpctx, "ab-loop-a", on_osd);
+ } else if (opts->ab_loop[1] == MP_NOPTS_VALUE) {
+ r = mp_property_do("ab-loop-b", M_PROPERTY_SET, &now, mpctx);
+ show_property_osd(mpctx, "ab-loop-b", on_osd);
+ } else {
+ now = MP_NOPTS_VALUE;
+ r = mp_property_do("ab-loop-a", M_PROPERTY_SET, &now, mpctx);
+ r = mp_property_do("ab-loop-b", M_PROPERTY_SET, &now, mpctx);
+ set_osd_msg(mpctx, osdl, osd_duration, "Clear A-B loop");
+ }
+ return r > 0;
+ }
+
case MP_CMD_VO_CMDLINE:
if (mpctx->video_out) {
char *s = cmd->args[0].v.s;