summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-05 06:34:25 +0100
committerwm4 <wm4@nowhere>2015-01-05 06:34:25 +0100
commit862a1b6e7eb3b16aad2d12196bd2410e996a27b1 (patch)
tree40b37f9704a11c5309a61dfa93c1cb45787ef6c0 /player/command.c
parentba9aa55de906f39b408bb187fd3d7d0db7126ac8 (diff)
downloadmpv-862a1b6e7eb3b16aad2d12196bd2410e996a27b1.tar.bz2
mpv-862a1b6e7eb3b16aad2d12196bd2410e996a27b1.tar.xz
command: ignore chapter cycling if there's only 1 chapter
If there's only 1 chapter, the seeking by chapter (using the chapter property) will either jump to the chapter point, or quit playback. This is as designed, but seems like a useless and annoying behavior.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/player/command.c b/player/command.c
index f770d197c9..f136c4cb46 100644
--- a/player/command.c
+++ b/player/command.c
@@ -697,6 +697,7 @@ static int mp_property_chapter(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
int chapter = get_current_chapter(mpctx);
+ int num = get_chapter_count(mpctx);
if (chapter < -1)
return M_PROPERTY_UNAVAILABLE;
@@ -709,7 +710,7 @@ static int mp_property_chapter(void *ctx, struct m_property *prop,
.type = CONF_TYPE_INT,
.flags = M_OPT_MIN | M_OPT_MAX,
.min = -1,
- .max = get_chapter_count(mpctx) - 1,
+ .max = num - 1,
};
return M_PROPERTY_OK;
case M_PROPERTY_PRINT: {
@@ -723,6 +724,8 @@ static int mp_property_chapter(void *ctx, struct m_property *prop,
if (action == M_PROPERTY_SWITCH) {
struct m_property_switch_arg *sarg = arg;
step_all = ROUND(sarg->inc);
+ if (num < 2) // semi-broken file; ignore for user convenience
+ return M_PROPERTY_UNAVAILABLE;
// Check threshold for relative backward seeks
if (mpctx->opts->chapter_seek_threshold >= 0 && step_all < 0) {
double current_chapter_start =
@@ -739,7 +742,7 @@ static int mp_property_chapter(void *ctx, struct m_property *prop,
chapter += step_all;
if (chapter < -1)
chapter = -1;
- if (chapter >= get_chapter_count(mpctx) && step_all > 0) {
+ if (chapter >= num && step_all > 0) {
if (mpctx->opts->keep_open) {
seek_to_last_frame(mpctx);
} else {