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

commands: parse seek time arguments like time options

This means a commands like "seek 13:00 absolute" actually behaves like
"--start=13:00", instead of interpreting the argument as fraction as
with normal float options. This is probably slightly closer to what
you'd expect.

As a consequence, the seek argument's type changes from float to double
internally.
This commit is contained in:
wm4 2013-02-24 21:16:23 +01:00
parent 7af2bc6607
commit 2254416a5d
3 changed files with 4 additions and 2 deletions

View File

@ -1723,7 +1723,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
int osdl = msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
switch (cmd->id) {
case MP_CMD_SEEK: {
float v = cmd->args[0].v.f;
double v = cmd->args[0].v.d;
int abs = cmd->args[1].v.i;
int exact = cmd->args[2].v.i;
if (abs == 2) { // Absolute seek to a timestamp in seconds

View File

@ -92,6 +92,7 @@ struct key_name {
#define ARG_STRING { .type = {"", NULL, &m_option_type_string} }
#define ARG_CHOICE(c) { .type = {"", NULL, &m_option_type_choice, \
M_CHOICES(c)} }
#define ARG_TIME { .type = {"", NULL, &m_option_type_time} }
#define OARG_FLOAT(def) { .type = {"", NULL, &m_option_type_float}, \
.optional = true, .v.f = def }
@ -117,7 +118,7 @@ static const mp_cmd_t mp_cmds[] = {
{ MP_CMD_RADIO_STEP_FREQ, "radio_step_freq", {ARG_FLOAT } },
{ MP_CMD_SEEK, "seek", {
ARG_FLOAT,
ARG_TIME,
OARG_CHOICE(0, ({"relative", 0}, {"0", 0},
{"absolute-percent", 1}, {"1", 1},
{"absolute", 2}, {"2", 2})),

View File

@ -121,6 +121,7 @@ struct mp_cmd_arg {
union {
int i;
float f;
double d;
char *s;
} v;
};