From 8cebec62621cb6e9ed03aab65f5b011393ac588d Mon Sep 17 00:00:00 2001 From: Philip Sequeira Date: Thu, 15 Aug 2013 15:49:06 -0400 Subject: 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. --- mpvcore/mplayer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'mpvcore/mplayer.c') 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) { -- cgit v1.2.3