summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-25 02:27:22 +0100
committerwm4 <wm4@nowhere>2014-03-25 02:27:22 +0100
commit6c2cd08afffa6d4fe5c16144b0c883f6997d0399 (patch)
treeb009945e884b862e8e3f84d65b521b0bf54af626 /player
parentc19c777061531d4831f93ddc34490e6537448c19 (diff)
downloadmpv-6c2cd08afffa6d4fe5c16144b0c883f6997d0399.tar.bz2
mpv-6c2cd08afffa6d4fe5c16144b0c883f6997d0399.tar.xz
player: handle chapter range like --start/--end
Instead of comparing the current chapter every time, set the playback end timestamp to the chapter end. Likewise, don't execute an extra seek for the start chapter. Maybe we could also use the timeline facility to restrict playback to the given chapter range, but this would be strange when using --chapter=N to start playback at a given chapter. Then you couldn't seek back, which is possibly not what the user wants.
Diffstat (limited to 'player')
-rw-r--r--player/loadfile.c10
-rw-r--r--player/playloop.c6
2 files changed, 8 insertions, 8 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index ea33e46aee..948142fb45 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1335,17 +1335,17 @@ goto_reopen_demuxer: ;
if (startpos == -1 && mpctx->resolve_result &&
mpctx->resolve_result->start_time > 0)
startpos = mpctx->resolve_result->start_time;
+ if (startpos == -1 && opts->chapterrange[0] > 0) {
+ double start = chapter_start_time(mpctx, opts->chapterrange[0] - 1);
+ if (start != MP_NOPTS_VALUE)
+ startpos = start;
+ }
if (startpos == -1 && mpctx->timeline)
startpos = 0;
if (startpos != -1) {
queue_seek(mpctx, MPSEEK_ABSOLUTE, startpos, 0, true);
execute_queued_seek(mpctx);
}
- if (opts->chapterrange[0] > 0) {
- if (mp_seek_chapter(mpctx, opts->chapterrange[0] - 1))
- execute_queued_seek(mpctx);
- }
-
get_relative_time(mpctx); // reset current delta
if (mpctx->opts->pause)
diff --git a/player/playloop.c b/player/playloop.c
index 6121c7367c..bbcc9a3df7 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -947,9 +947,9 @@ void run_playloop(struct MPContext *mpctx)
}
if (opts->chapterrange[1] > 0) {
- int cur_chapter = get_current_chapter(mpctx);
- if (cur_chapter != -1 && cur_chapter + 1 > opts->chapterrange[1])
- mpctx->stop_play = PT_NEXT_ENTRY;
+ double end = chapter_start_time(mpctx, opts->chapterrange[1]);
+ if (end != MP_NOPTS_VALUE && (endpts == MP_NOPTS_VALUE || end < endpts))
+ endpts = end;
}
if (mpctx->d_audio && !mpctx->restart_playback && !ao_untimed(mpctx->ao)) {