Mercurial > mplayer.hg
changeset 23418:f6055798121d
Add new properties percent_pos and time_pos.
author | albeu |
---|---|
date | Thu, 31 May 2007 13:07:52 +0000 |
parents | a829005cbcd5 |
children | 62ef4414ebe0 |
files | DOCS/tech/slave.txt command.c |
diffstat | 2 files changed, 63 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/tech/slave.txt Thu May 31 13:02:51 2007 +0000 +++ b/DOCS/tech/slave.txt Thu May 31 13:07:52 2007 +0000 @@ -401,6 +401,8 @@ stream_end pos 0 X end pos in stream stream_length pos 0 X (end - start) length time X length of file in seconds +percent_pos int 0 100 X X X position in percent +time_pos time 0 X X X position in seconds metadata str list X list of metadata key/value metadata/* string X metadata values volume float 0 100 X X X change volume
--- a/command.c Thu May 31 13:02:51 2007 +0000 +++ b/command.c Thu May 31 13:07:52 2007 +0000 @@ -286,6 +286,63 @@ return m_property_time_ro(prop, action, arg, len); } +/// Current position in percent (RW) +static int mp_property_percent_pos(m_option_t * prop, int action, + void *arg, MPContext * mpctx) { + int pos; + + if (!mpctx->demuxer) + return M_PROPERTY_UNAVAILABLE; + + switch(action) { + case M_PROPERTY_SET: + if(!arg) return M_PROPERTY_ERROR; + M_PROPERTY_CLAMP(prop, *(int*)arg); + pos = *(int*)arg; + break; + case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP_DOWN: + pos = demuxer_get_percent_pos(mpctx->demuxer); + pos += (arg ? *(int*)arg : 10) * + (action == M_PROPERTY_STEP_UP ? 1 : -1); + M_PROPERTY_CLAMP(prop, pos); + break; + default: + return m_property_int_ro(prop, action, arg, + demuxer_get_percent_pos(mpctx->demuxer)); + } + + abs_seek_pos = 3; + rel_seek_secs = pos / 100.0; + return M_PROPERTY_OK; +} + +/// Current position in seconds (RW) +static int mp_property_time_pos(m_option_t * prop, int action, + void *arg, MPContext * mpctx) { + if (!(mpctx->sh_video || (mpctx->sh_audio && mpctx->audio_out))) + return M_PROPERTY_UNAVAILABLE; + + switch(action) { + case M_PROPERTY_SET: + if(!arg) return M_PROPERTY_ERROR; + M_PROPERTY_CLAMP(prop, *(double*)arg); + abs_seek_pos = 1; + rel_seek_secs = *(double*)arg; + return M_PROPERTY_OK; + case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP_DOWN: + rel_seek_secs += (arg ? *(double*)arg : 10.0) * + (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0); + return M_PROPERTY_OK; + } + return m_property_time_ro(prop, action, arg, + mpctx->sh_video ? mpctx->sh_video->pts : + playing_audio_pts(mpctx->sh_audio, + mpctx->d_audio, + mpctx->audio_out)); +} + /// Demuxer meta data static int mp_property_metadata(m_option_t * prop, int action, void *arg, MPContext * mpctx) { @@ -1385,6 +1442,10 @@ M_OPT_MIN, 0, 0, NULL }, { "length", mp_property_length, CONF_TYPE_TIME, M_OPT_MIN, 0, 0, NULL }, + { "percent_pos", mp_property_percent_pos, CONF_TYPE_INT, + M_OPT_RANGE, 0, 100, NULL }, + { "time_pos", mp_property_time_pos, CONF_TYPE_TIME, + M_OPT_MIN, 0, 0, NULL }, { "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL },