summaryrefslogtreecommitdiffstats
path: root/mpvcore/mplayer.c
diff options
context:
space:
mode:
authorPhilip Sequeira <phsequei@gmail.com>2013-08-15 15:49:06 -0400
committerwm4 <wm4@nowhere>2013-08-17 21:32:41 +0200
commit8cebec62621cb6e9ed03aab65f5b011393ac588d (patch)
tree8a8a00ee975756e91d3388c34515381a6265622e /mpvcore/mplayer.c
parentab81af477cd58d03a0c2762f4b465a36b2aead34 (diff)
downloadmpv-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/mplayer.c')
-rw-r--r--mpvcore/mplayer.c9
1 files changed, 7 insertions, 2 deletions
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) {