summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-05 06:34:25 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-01-25 17:00:13 +0900
commit86493730b269efa5391a65d8d52eb9a794e296e1 (patch)
tree98fc70fc83f37d6b38dbf63bd51ef95cfea47c0c
parent87e635e8431ed21df8391f96f51e01b3233610b6 (diff)
downloadmpv-86493730b269efa5391a65d8d52eb9a794e296e1.tar.bz2
mpv-86493730b269efa5391a65d8d52eb9a794e296e1.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. Conflicts: 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 90ddcd4758..71690e5bb3 100644
--- a/player/command.c
+++ b/player/command.c
@@ -695,6 +695,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;
@@ -707,7 +708,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: {
@@ -721,6 +722,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 =
@@ -737,7 +740,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) {
mpctx->stop_play = PT_NEXT_ENTRY;
} else {
mp_seek_chapter(mpctx, chapter);