summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-08-21 15:51:50 +0200
committerwm4 <wm4@nowhere>2015-08-21 15:53:24 +0200
commit8565073f6825e8ea9b2b9b120f6995029a7db445 (patch)
tree75ea84064af36e3080723703c14cb46b512c07ce
parent2e3ce738f566cfa8fbb8b7eb5826fe2fe6b8b8f6 (diff)
downloadmpv-8565073f6825e8ea9b2b9b120f6995029a7db445.tar.bz2
mpv-8565073f6825e8ea9b2b9b120f6995029a7db445.tar.xz
command: make the playback-time property writable
Provides a simplistic way to seek without having to care about weird situations like timestamp vs. playback time. This is good, because the seek command is currently timestamp based, so when using the seek command the user _does_ have to care.
-rw-r--r--DOCS/man/input.rst6
-rw-r--r--player/command.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 049b221758..c49587eabf 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -933,8 +933,10 @@ Property list
``playtime-remaining``
``time-remaining`` scaled by the current ``speed``.
-``playback-time``
- Return the playback time, which is the time difference between start PTS and current PTS.
+``playback-time`` (RW)
+ The playback time, which is the time relative to playback start. (This can
+ be different from the ``time-pos`` property if the file does not start at
+ position ``0``, in which case ``time-pos`` is the source timestamp.)
``chapter`` (RW)
Current chapter number. The number of the first chapter is 0.
diff --git a/player/command.c b/player/command.c
index a74cde2b23..8514be98f7 100644
--- a/player/command.c
+++ b/player/command.c
@@ -686,6 +686,11 @@ static int mp_property_playback_time(void *ctx, struct m_property *prop,
if (!mpctx->playback_initialized)
return M_PROPERTY_UNAVAILABLE;
+ if (action == M_PROPERTY_SET) {
+ double target = get_start_time(mpctx) + *(double *)arg;
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, target, MPSEEK_DEFAULT, true);
+ return M_PROPERTY_OK;
+ }
return property_time(action, arg, get_playback_time(mpctx));
}