From 70b6c163ff5077910670475f7e25842db84308cd Mon Sep 17 00:00:00 2001 From: xylosper Date: Fri, 28 Feb 2014 23:04:10 +0900 Subject: [PATCH] client API: add two properties, 'time-start' and 'seekable' --- player/command.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/player/command.c b/player/command.c index 4997056be4..7b2115b12e 100644 --- a/player/command.c +++ b/player/command.c @@ -383,6 +383,15 @@ static int mp_property_percent_pos(m_option_t *prop, int action, return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_time_start(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + double start = get_start_time(mpctx); + if (start < 0) + return M_PROPERTY_UNAVAILABLE; + return property_time(prop, action, arg, start); +} + /// Current position in seconds (RW) static int mp_property_time_pos(m_option_t *prop, int action, void *arg, MPContext *mpctx) @@ -908,6 +917,14 @@ static int mp_property_clock(m_option_t *prop, int action, void *arg, return M_PROPERTY_UNAVAILABLE; } +static int mp_property_seekable(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + if (!mpctx->demuxer) + return M_PROPERTY_UNAVAILABLE; + return m_property_int_ro(prop, action, arg, !!mpctx->demuxer->seekable); +} + /// Volume (RW) static int mp_property_volume(m_option_t *prop, int action, void *arg, MPContext *mpctx) @@ -2076,6 +2093,8 @@ static const m_option_t mp_properties[] = { { "avsync", mp_property_avsync, CONF_TYPE_DOUBLE }, { "percent-pos", mp_property_percent_pos, CONF_TYPE_DOUBLE, M_OPT_RANGE, 0, 100, NULL }, + { "time-start", mp_property_time_start, CONF_TYPE_TIME, + M_OPT_MIN, 0, 0, NULL }, { "time-pos", mp_property_time_pos, CONF_TYPE_TIME, M_OPT_MIN, 0, 0, NULL }, { "time-remaining", mp_property_remaining, CONF_TYPE_TIME }, @@ -2098,6 +2117,8 @@ static const m_option_t mp_properties[] = { M_OPTION_PROPERTY("hr-seek"), { "clock", mp_property_clock, CONF_TYPE_STRING, 0, 0, 0, NULL }, + { "seekable", mp_property_seekable, CONF_TYPE_FLAG, + M_OPT_RANGE, 0, 1, NULL }, M_PROPERTY("chapter-list", mp_property_list_chapters), M_PROPERTY("track-list", property_list_tracks),