diff --git a/player/command.c b/player/command.c index cc9c84e2bc..db89ca4a90 100644 --- a/player/command.c +++ b/player/command.c @@ -5739,7 +5739,7 @@ static void cmd_playlist_next_prev(void *p) int dir = *(int *)cmd->priv; int force = cmd->args[0].v.i; - struct playlist_entry *e = mp_next_file(mpctx, dir, force); + struct playlist_entry *e = mp_next_file(mpctx, dir, force, true); if (!e && !force) { cmd->success = false; return; diff --git a/player/core.h b/player/core.h index 9ce0f1daca..8f1bbfe99f 100644 --- a/player/core.h +++ b/player/core.h @@ -540,7 +540,7 @@ struct track *mp_track_by_tid(struct MPContext *mpctx, enum stream_type type, void add_demuxer_tracks(struct MPContext *mpctx, struct demuxer *demuxer); bool mp_remove_track(struct MPContext *mpctx, struct track *track); struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction, - bool force); + bool force, bool update_loop); void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e); void mp_play_files(struct MPContext *mpctx); void update_demuxer_properties(struct MPContext *mpctx); diff --git a/player/loadfile.c b/player/loadfile.c index 4f204c20e7..b5ad54c9e3 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1257,7 +1257,7 @@ void prefetch_next(struct MPContext *mpctx) if (!mpctx->opts->prefetch_open) return; - struct playlist_entry *new_entry = mp_next_file(mpctx, +1, false); + struct playlist_entry *new_entry = mp_next_file(mpctx, +1, false, false); if (new_entry && !mpctx->open_active && new_entry->filename) { MP_VERBOSE(mpctx, "Prefetching: %s\n", new_entry->filename); start_open(mpctx, new_entry->filename, new_entry->stream_flags, true); @@ -1918,7 +1918,7 @@ terminate_playback: process_hooks(mpctx, "on_after_end_file"); if (playlist_prev_continue) { - struct playlist_entry *e = mp_next_file(mpctx, -1, false); + struct playlist_entry *e = mp_next_file(mpctx, -1, false, true); if (e) { mp_set_playlist_entry(mpctx, e); play_current_file(mpctx); @@ -1930,8 +1930,9 @@ terminate_playback: // it can have side-effects and mutate mpctx. // direction: -1 (previous) or +1 (next) // force: if true, don't skip playlist entries marked as failed +// update_loop: whether to decrement --loop-playlist=N if it was specified struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction, - bool force) + bool force, bool update_loop) { struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction); if (next && direction < 0 && !force) @@ -1941,7 +1942,7 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction, if (mpctx->opts->shuffle) playlist_shuffle(mpctx->playlist); next = playlist_get_first(mpctx->playlist); - if (next && mpctx->opts->loop_times > 1) { + if (next && mpctx->opts->loop_times > 1 && update_loop) { mpctx->opts->loop_times--; m_config_notify_change_opt_ptr(mpctx->mconfig, &mpctx->opts->loop_times); @@ -2000,7 +2001,7 @@ void mp_play_files(struct MPContext *mpctx) if (mpctx->stop_play == PT_NEXT_ENTRY || mpctx->stop_play == PT_ERROR || mpctx->stop_play == AT_END_OF_FILE) { - new_entry = mp_next_file(mpctx, +1, false); + new_entry = mp_next_file(mpctx, +1, false, true); } else if (mpctx->stop_play == PT_CURRENT_ENTRY) { new_entry = mpctx->playlist->current; }