summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorHector Martin <marcan@marcan.st>2016-09-20 02:11:14 +0900
committerwm4 <wm4@nowhere>2016-09-19 19:45:24 +0200
commita802afb206736279b0bf1c433f5d92b05a68b34f (patch)
tree7de125f4a9c1554e2707cfb64061d1ce605ea6a7 /player
parent297f9f1bec3c0e3eca6fbfdd8a346b6c1a5b533e (diff)
downloadmpv-a802afb206736279b0bf1c433f5d92b05a68b34f.tar.bz2
mpv-a802afb206736279b0bf1c433f5d92b05a68b34f.tar.xz
command: add audio-pts property to get the audio pts
For audio files, this is identical to time-pos (except read-only). For audio-video files, this returns the audio position. Unlike time-pos, this is not quantized to a video frame. For video-only files, this property is unavailable.
Diffstat (limited to 'player')
-rw-r--r--player/command.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/player/command.c b/player/command.c
index 3e677bfd37..1807f269b9 100644
--- a/player/command.c
+++ b/player/command.c
@@ -796,6 +796,18 @@ static int mp_property_time_pos(void *ctx, struct m_property *prop,
return property_time(action, arg, get_current_time(mpctx));
}
+/// Current audio pts in seconds (R)
+static int mp_property_audio_pts(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ if (!mpctx->playback_initialized || mpctx->audio_status < STATUS_PLAYING ||
+ mpctx->audio_status >= STATUS_EOF)
+ return M_PROPERTY_UNAVAILABLE;
+
+ return property_time(action, arg, playing_audio_pts(mpctx));
+}
+
static bool time_remaining(MPContext *mpctx, double *remaining)
{
double len = get_time_length(mpctx);
@@ -3806,6 +3818,7 @@ static const struct m_property mp_properties_base[] = {
{"time-start", mp_property_time_start},
{"time-pos", mp_property_time_pos},
{"time-remaining", mp_property_remaining},
+ {"audio-pts", mp_property_audio_pts},
{"playtime-remaining", mp_property_playtime_remaining},
{"playback-time", mp_property_playback_time},
{"disc-title", mp_property_disc_title},
@@ -4034,7 +4047,7 @@ static const char *const *const mp_event_property_change[] = {
E(MPV_EVENT_IDLE, "*"),
E(MPV_EVENT_PAUSE, "pause", "paused-on-cache", "core-idle", "eof-reached"),
E(MPV_EVENT_UNPAUSE, "pause", "paused-on-cache", "core-idle", "eof-reached"),
- E(MPV_EVENT_TICK, "time-pos", "stream-pos", "stream-time-pos", "avsync",
+ E(MPV_EVENT_TICK, "time-pos", "audio-pts", "stream-pos", "avsync",
"percent-pos", "time-remaining", "playtime-remaining", "playback-time",
"estimated-vf-fps", "drop-frame-count", "vo-drop-frame-count",
"total-avsync-change", "audio-speed-correction", "video-speed-correction",