diff options
author | Philip Sequeira <phsequei@gmail.com> | 2013-08-15 15:49:06 -0400 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-08-17 21:32:41 +0200 |
commit | 8cebec62621cb6e9ed03aab65f5b011393ac588d (patch) | |
tree | 8a8a00ee975756e91d3388c34515381a6265622e /mpvcore | |
parent | ab81af477cd58d03a0c2762f4b465a36b2aead34 (diff) | |
download | mpv-8cebec62621cb6e9ed03aab65f5b011393ac588d.tar.bz2 mpv-8cebec62621cb6e9ed03aab65f5b011393ac588d.tar.xz |
command: allow seek to "chapter -1"
This will seek to the start of the file regardless of whether the first real
chapter starts there or not.
Diffstat (limited to 'mpvcore')
-rw-r--r-- | mpvcore/command.c | 2 | ||||
-rw-r--r-- | mpvcore/mplayer.c | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c index d1513bd998..b04c05c9e6 100644 --- a/mpvcore/command.c +++ b/mpvcore/command.c @@ -1721,7 +1721,7 @@ static const m_option_t mp_properties[] = { M_OPT_MIN, 0, 0, NULL }, { "time-remaining", mp_property_remaining, CONF_TYPE_TIME }, { "chapter", mp_property_chapter, CONF_TYPE_INT, - M_OPT_MIN, 0, 0, NULL }, + M_OPT_MIN, -1, 0, NULL }, M_OPTION_PROPERTY_CUSTOM("edition", mp_property_edition), M_OPTION_PROPERTY_CUSTOM("quvi-format", mp_property_quvi_format), { "titles", mp_property_titles, CONF_TYPE_INT, diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c index e7c21cc272..88804939c1 100644 --- a/mpvcore/mplayer.c +++ b/mpvcore/mplayer.c @@ -3229,6 +3229,8 @@ char *chapter_name(struct MPContext *mpctx, int chapter) // returns the start of the chapter in seconds (-1 if unavailable) double chapter_start_time(struct MPContext *mpctx, int chapter) { + if (chapter == -1) + return get_start_time(mpctx); if (mpctx->chapters) return mpctx->chapters[chapter].start; if (mpctx->master_demuxer) @@ -3252,13 +3254,16 @@ bool mp_seek_chapter(struct MPContext *mpctx, int chapter) int num = get_chapter_count(mpctx); if (num == 0) return false; - if (chapter < 0 || chapter >= num) + if (chapter < -1 || chapter >= num) return false; mpctx->last_chapter_seek = -2; double pts; - if (mpctx->chapters) { + if (chapter == -1) { + pts = get_start_time(mpctx); + goto do_seek; + } else if (mpctx->chapters) { pts = mpctx->chapters[chapter].start; goto do_seek; } else if (mpctx->master_demuxer) { |