diff options
author | Mike Will <myQwil@gmail.com> | 2023-09-27 08:00:14 -0400 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-29 20:25:50 +0000 |
commit | 233f1e46f67fef71d7a270f798f6a4e3198a1606 (patch) | |
tree | 5e07fe6b8cc68cf7fdc08f573f6999a5f9a1a790 /player/loadfile.c | |
parent | 27ef1725e7724f4b6899e3992ac3a884db9fbe13 (diff) | |
download | mpv-233f1e46f67fef71d7a270f798f6a4e3198a1606.tar.bz2 mpv-233f1e46f67fef71d7a270f798f6a4e3198a1606.tar.xz |
playloop: make chapter property more accurate when seeking chapters
When seeking chapters, `last_chapter_seek` acts as a projection of
what the current chapter will be once mpv has a chance to seek to it.
This allows for more accurate results from the `chapter` property.
It works by comparing the projection to the actual current chapter
and returning the larger of the two indexes, but this only works when
seeking forward.
If we want it to work for both forward and backward chapter seeking,
we can instead use a boolean called `last_chapter_flag`, which gets
switched on when a chapter seek request is made, and then
switched off when the seek has been performed.
We should also check to ensure that we don't allow the chapter index
to be set to -1 unless there is a span of time between the very
beginning of the track and the start of the first chapter.
Since the new approach to resetting `last_chapter_seek` no longer
depends on `last_chapter_pts`, that member variable can be removed.
Diffstat (limited to 'player/loadfile.c')
-rw-r--r-- | player/loadfile.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/player/loadfile.c b/player/loadfile.c index 521a20d459..2730746dd2 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1592,7 +1592,7 @@ static void play_current_file(struct MPContext *mpctx) mpctx->shown_aframes = 0; mpctx->shown_vframes = 0; mpctx->last_chapter_seek = -2; - mpctx->last_chapter_pts = MP_NOPTS_VALUE; + mpctx->last_chapter_flag = false; mpctx->last_chapter = -2; mpctx->paused = false; mpctx->playing_msg_shown = false; |